Deploying Subway broker with BOSH

When we originally released Subway – a service broker that allows you to scale out single-server service brokers for Cloud Foundry – we showed how to deploy it as a Cloud Foundry app. That was convenient because deploying apps to Cloud Foundry is convenient.

Unfortunately, everytime you scaled out your backend service – say a single node Docker-based service broker – you were then required to update the environment variables for the Subway app, and restart it. We automated this via our Concourse deployment pipelines and so we didn’t feel too much pain from it.

But we think we can have even fewer moving parts – we can remove the need for a Cloud Foundry application, and we can remove the need to manually update it – if we colocate Subway on each server.

BOSH release

Introducing the Subway BOSH release: cf-subway-boshrelease

If you have three servers each running exactly the same single-server service broker – such as Pivotal’s Redis service broker cf-redis-release – then we can run Subway on each of them. Any inbound request to Subway could safely arrive at any Subway broker, which would then schedule the work to any backend broker (redis or docker or whatever).

In the example below, the service being offered is the cf-containers-broker backed by a local socket Docker daemon.

Subway broker is colocated on every server. Every subway broker is configured to know the host:port of every backend cf-containers-broker.

All subway brokers are advertised on NATS to the Gorouter. Any request coming into gorouter can be safely received by any Subway broker. In the example above, the gorouter forwarded the create-service HTTP request to one of the Subway broker processes (say running on port :8000).

The Subway broker will then schedule the service instance to one of the three cf-containers-brokers. (See README for information on scheduler)

Advertising on gorouter

Subway itself does not know how to advertise its host:port to the gorouter via NATS.

Instead we’re using the route-registrar component which can advertise any colocated process to the gorouter via NATS.

We use the route-registrar-boshrelease to include it in our Subway/backend broker BOSH deployment.

Spread the word

twitter icon facebook icon linkedin icon