Sinatra Series: Introduction to SOA

Goal

  • Service Oriented Architecture
  • Build a system from a collection of services
  • Services talk to each other over the internal network
  • REST or similar communications schemes
  • Services that are internal to the system
  • Not designed as an external API but as a way to structure a system
  • Contrast with Rails “Magestic Monolith” approaches
  • Big design and architecture question is how many services to have
  • What is the “right size”?
  • A very important pattern, but not uncontroversial

Benefits of SOA

  • Isolation
    • Each service is its own code base, database, and team
    • Each can be tested separately
    • Makes “scaling out” more possible
  • Robustness
    • If one service fails or errors out, it shouldnt affect the others
    • Analogous to encapsulation in OOP
  • Scalability
    • Services become the unit of scalability
    • We can run 1,2,3 or more of the same service
    • A service can be moved to another server
  • Flexibility and Interoperability
    • No service can know or depend on how another service is implemented
    • Services will interoperate without worrying about the language or platform
    • Or it could be reimplemented in another language or another platform
  • Reuse
    • A service that is well designed can be reused in different contexts
    • There are services that different applications or products will require
    • Or a service designed by one group or company can be reused

Mechanics

  • Describe the “API” of the service
  • Usually an HTTP request and response
  • Long running services should be implemented as multiple calls
    • One to initiate
    • One to request results if any
    • So as not to “block” the caller
    • But then, what happens if the service has crashed or is hung?
  • Synchronous calls need to be very fast
  • Another excellent way to communicate is with a queue
  • Sinatra is especially suited for SOA services because it is lightweight

Discussion Questions

  • How would you recognize a system that is designed in an Service Oriented Architecture?
  • What are some of the advantages and disadvantages of this approach?
  • What is in an http response? And what would be somewhat different about the http response produced from an SOA system?