Skip to content

Instantly share code, notes, and snippets.

@lox
Last active December 28, 2015 10:49
Show Gist options
  • Save lox/7489500 to your computer and use it in GitHub Desktop.
Save lox/7489500 to your computer and use it in GitHub Desktop.
Thinking on SOA

Aggregating multiple top-level web applications

Ideally we'd be able to compose 99designs.com out of several top-level web applications. There are many challenges with this, for instance:

  • How do we manage routing and route generation, cross-application?
  • How do we manage sessions without shared db access?
  • How do we handle shared UI like alert bars and unified headers?

On the whole, these problems are solvable. For routing we could just use Varnish, with some custom code to read routemaps from the apps, or we could use something like Mongrel2. Alternately, a Go-lang HTTP/SPDY terminator would be pretty damn quick and flexible.

The one thing I will say about Mongrel2 is that it appears to be dead and has utterly failed to get traction. Still not sure why, but probably worth not ignoring the writing on the wall.

Expose services easily and scalably

The other side of the coin is backend service composition. It should be trivial to write and deploy a monitored, robust, stand-alone service for something like exchange rates, private messaging, etc.

For me, the requirements around this are:

Synchronous and asynchronous semantics (request/response, or request with a callback) Streaming support (e.g. request a large binary file as a stream) Minimal code required to expose useful, robust services

Things that we might care about are:

Versioning, or ways to elegantly change the exposed services incrementally without breaking calls "in-flight" Developer friendly (easy to test, no code generation, good language support)

This is the piece I've spent the most time researching, and the options that appeal to me the most are the light-weight RPC mechanisms built over interesting transports (in order of interest):

  1. https://github.com/blog/531-introducing-bert-and-bert-rpc (this becomes even sexier when you look at Elixer as a language for extending services)
  2. http://zerorpc.dotcloud.com/
  3. https://github.com/nathanmarz/storm/wiki/Distributed-RPC

It's worth noting that most of these systems don't seem to have great answers for versioning, but I'm not sure I care.

I've spent a lot of time trying to like Protobuf (et al) and Thrift, but I just can't get past the bulky formats and painful code generation. It makes testing hard and it's ugly.

The other option is to build some sort of central message bus and use that as the basis for RPC/Service communications. In the above, Bert is similar to this in that it's based on Erlang OTP, and Storm is basically a distributed message processing system.

Service discovery and failure tolerance

Airbnb wrote an awesome post about this: http://nerds.airbnb.com/smartstack-service-discovery-cloud/

They use HAProxy, combined with Zookeeper (or something similar), such that basically every service is exposed as a port number of the local machine. This makes wiring apps easy.

I'd be tempted to basically use this approach, it's elegant. It would work nicely for RESTful services, I'm not sure how it would work with the above RPC layers, will require some thought.

Reading

@lox
Copy link
Author

lox commented Nov 16, 2013

Your second question is a really interesting one. It's possible it is too tech a split. Will do some thinking on this over the next few days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment