Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A proxy server using zeromq and Tornado

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 docs
Octocat-spinner-32 scale0
Octocat-spinner-32 .gitignore
Octocat-spinner-32 README
README
Scale0 - A dynamic service oriented smart load balancer.

What does that mean?

Dynamic - Scale0 is configured by the backend workers that connect to it.
There are no virtual servers, pool members or other configuration necessary.

Service Oriented - Scale0 routes frontend request to backends by the services
the backends announce they support.

Smart Load Balancer - Scale0 uses a least recently used queue methodology to 
route requests.

Huh? I still don't get it.

Say you have a dynamic website and you want to have multiple backend servers
processing requests received by a frontend webserver. A typical scenario might
be several Tornado or node.js servers being proxied by an Nginx server.

A traffic spike happens, you need to get more backends up to handle the load.
You hopefully have your Nginx servers load balanced so you can reconfigure them
to support more backends. Your architecture might look like

                                        ------------------
                                        | Backend Server |
                                        ------------------

                      ----------------  ------------------
                      | Proxy Server |  | Backend Server |
                      ----------------  ------------------

-----------------                       -----------------
| Load Balancer |                       | Backend Server |
-----------------                       ------------------

                      ----------------  ------------------
                      | Proxy Server |  | Backend Server |
                      ---------------   ------------------
                                        ------------------
                                        | Backend Server |
                                        ------------------



Adding more servers will require reconfiguring the proxy servers. Generally you
can do this by turning off one in the pool, adding the new members, bringing it
back up and doing the same on the other. If you're running in active/active
mode on your load balancer you're cutting your input capability in half while
trying to scale up.

Alternatively you could of course stand up another proxy server with new backends
and add it to the pool on the load balancer. Let's not pretend that the solution
is impossible without Scale0, Scale0 just provides an alternative solution that
allows you scale all the way at the backend, instead of messing around with the
front door.

Using Scale0, and something that supports ZeroMQ like Mongrel2 (or a module for
Nginx would nice, hint hint) you could do something like this.

                                                        ------------------
                                                        | Backend Server |
                                                        ------------------

                    ----------------                    ------------------
                    | Proxy Server |                    | Backend Server |
                    ----------------                    ------------------

-----------------                       ----------      ------------------
| Load Balancer |                       | Scale0 |      | Backend Server |
-----------------                       ----------      ------------------

                    ----------------                    ------------------
                    | Proxy Server |                    | Backend Server |
                    ----------------                    ------------------

                                                        ------------------
                                                        | Backend Server |
                                                        ------------------

Here's where the magic starts. Say you need to scale up. Just turn on more
backend servers and connect them to Scale0. That's it, you can increase your
processing capacity, or decrease it, at will. Scale0 is the elasticity that
allows you to scale your system real time for load.

Scale0 is also service agnostic. At this time it's not being designed with
streams in mind, but for protocols like http or smtp it should work great.
It will require services to be built supporting ZeroMQ on the frontend to
support it, Scale0 is the first piece towards a scalable architecture. 

Note: Scale0 is in an early state of development. Some of the current ideas
include using PUSH/PULL sockets for front end communication, allowing you to
stand up more Scale0 servers. Then PUB/SUB for the backend, using ZMQ Identity
to manage subscriptions. Internally Scale0 uses a Least Recently Used Queue
methodology requiring backend servers to announce their readiness for accepting
a request. More information will be in the docs once the project is finished
being fleshed out.

Note2: Hey! Doesn't that make Scale0 a single point of failure in an environment
built for avoiding that? Part of the plans for Scale0 include the ability to set
up failover servers. Backend and proxy servers will need to know about the failover
server, and the plan is to allow Scale0 to provide that information and also build
in a protocol and management interface to allow you to fail over manually as well,
say when you need to do OS upgrades on the Scale0 server.
Something went wrong with that request. Please try again.