0 0


On Github 1stvamp / atmosphere-2013-talk

It's HTTP, All The Way Down

Wes Mason



  • @1stvamp (twitter/github)
  • Engineer at ServerDensity
  • I release lots of open source code
  • Curate


  • First version of HTTP implemented by Tim Berners-Lee in 1991
  • Expanded by the HTTP WG in '95.
  • Very little has changed in 22 years.

No really, what?

  • Very simple text based protocol
  • First part contains metadata (headers)
  • Resource centric actions
  • Body can contain any kind of encoded data

What's new?

  • HTTP/1.1 (1999) adds some sugar
  • New new:
    • Server Sent Events
    • WebSockets
  • New protocols:
    • SPDY
    • HTTP/2

A little about our architecture

  • Service Orientated
  • Each service in it's own codebase
  • Their own clusters with load balancers

Our services

  • RESTful
  • Stateless
  • Mostly thinlayers
  • Common documented API
  • Callable from frontend

The web is our API

  • Everything does HTTP
  • REST is great - let's do more of this
  • Almost everything can do HTTP asynchronously

Brave New (Async) World

  • Longpolling, WebSockets and Server Sent Events
  • UIs are responsive or go home
  • Libraries like and SockJS make this pretty easy for devs



  • Non-blocking IO
  • Both client and server
  • Multiple "workers" - scaling


  • Several things
  • Not polling for updates, "real time"
  • Performing backend tasks without blocking the UI
  • WebWorkers

In which Jane clicks a button

$('.button').click(function() {
GET /svc/users/:id
Cookie: session=blah
Content-Type: application/json
Accept: ...

<your application code here>

Content-Type: application/json
Content-Length: 14
X-Barium: foobar
Connection: close

{"foo": "baz"}


  • Multiple backend servers
  • JavaScript powered frontend
  • Authentication/Authorisation?
  • Routing?
  • Cross domain?

Add a little barium

  • Every external request coming in via sockii gets an X-Barium header
  • Our client libraries add this header for internal requests
  • "Unique" ID (UUID-4)
  • Logged
  • A single payload going through our alerting system will maintain this ID
  • We can query for records matching it


  • Many tasks running in a cluster, e.g. polling AWS or Rackspace
  • Need to get a response back from a task to a connected WebSocket
  • Webhooks to the rescue!

# import requests, import pymongo
# setup collection etc. etc.

hooks = webhook_collection.find({"account_id": id}) 
if data and len(data) > 0:
    for hook in hooks:["url"], data)