Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Real World SOA (Austin on Rails)

Real World SOA (Austin on Rails)

I gave this talk about building a service oriented architecture at Austin on Rails on 10/22.

Hayes Davis

October 22, 2013
Tweet

More Decks by Hayes Davis

Other Decks in Programming

Transcript

  1. @hayesdavis Austin on Rails: SOA What should be a service?

    • Things that are big context switches • It needs resources your app doesn’t • It does things that are hard to do in Rails • There are clear inputs and outputs
  2. @hayesdavis Austin on Rails: SOA How SoA saves your ass

    • Simpler logic • Simpler deployments • Better division of labor • Easier scaling • Use the right tool/language for the job
  3. @hayesdavis Austin on Rails: SOA How SoA kicks your ass

    • More codebases == more dependencies • Data drift • More hardware • Tricky dev environment • Communication complexity
  4. @hayesdavis Austin on Rails: SOA Knowing little • Minimize the

    scope of the environment your service knows about • Keep things stateless • Don't store data you don't need
  5. @hayesdavis Austin on Rails: SOA Be lazy for fun and

    profit • Don't add speculative functionality • Fail fast on errors • Don't cache
  6. @hayesdavis Austin on Rails: SOA transport  =  Thrift::BufferedTransport.new(    Thrift::Socket.new('localhost',

     9090)) protocol  =  Thrift::BinaryProtocol.new(transport) client  =  BookService::Client.new(protocol) transport.open() book  =  client.get_book(1) transport.close() - or - $  curl  http://bookinator:9090/books/1.json {"id":  1,  "title":  "Cool  Story"}
  7. @hayesdavis Austin on Rails: SOA The world is out to

    get you • You will get poorly formed data • You will get out of order data • You will get too much data too fast • You will get the same data repeatedly
  8. @hayesdavis Austin on Rails: SOA What can you do? •

    Check your inputs • Don't depend on temporal ordering • Be idempotent • Log • Graph
  9. @hayesdavis Austin on Rails: SOA Your service will fail •

    Your hardware will fail • Your network will fail • Your code will fail • They’ll fail hard, soft, in cascades and in ways you never imagined
  10. @hayesdavis Austin on Rails: SOA Failure as the default •

    Make sure you have timeouts • Define separate exceptions for down, timeout, service-level errors • Test clients at HTTP level • Decide how your app will respond when this service is gone
  11. @hayesdavis Austin on Rails: SOA Not as easy as it

    sounds • As a rule, always retry on writes • Under what conditions should you retry? • What kind of backoff? • Avoiding herding
  12. @hayesdavis Austin on Rails: SOA After you retry... • Have

    to move on at some point • Service might be 100% down for a while • If possible, keep accepting writes • Queue them for later processing • Consider local read-only or down setting for service
  13. @hayesdavis Austin on Rails: SOA On being dumb 1. Know

    little 2. Do little 3. Communicate clearly 4. Be paranoid
  14. @hayesdavis Austin on Rails: SOA On failing 1. Treat failure

    as the default 2. Retry, retry, retry 3. When all else fails, defer