Tuesday 10 July 2012

Scale when you need to....

In my post one node I talked about a kind of scaling within a single node (a server), where you run multiple instances of you service and let a load balancer round robin the requests.  This is a sort of horizontal intra-node scaling that helps keep your service handling requests and if one of your instances dies then you can still rely on the other ones to keep serving.

If you found that the load was becoming to high you could launch more instances, but you will come to a point where this doesn't really help due to resource problems, such as CPU/memory or IO saturation.  It is tempting at this point to start to architect an elaborate multi-node setup ripping your application stack into layers. For example having 3 separate database nodes with replication and 4 app server nodes with auto scaling and a few load balancing nodes, maybe a few memcache nodes. However you will soon disappear down a rabbit hole of complexity and stress,  unless you have setup a similar infrastructure before.

Keeping everything on one node means all the parts of your application are as close as possible and keeps configuration to a minimum.  Scaling vertically by adding memory/cpu cores and better IO will keep you going and most cloud providers offer big fat nodes for you to grow into.  Of course this can only go so far and eventually you will have to spin up another node, but you shouldn't do this until you need to. 

There are usually a few arguments against running on a single node (assuming your service can run well on a single node).
One is having only one node puts you at risk of outages as you have no fallback if your server goes bye bye. Another is when it does come time to scale horizontally by adding more nodes you will have to pick apart you application stack, causing a delay in getting the load under control.

These arguments are valid however they can be easily overcome by making you configuration modular and being able to recreate your node from scratch in a few minutes as well as using a decent VPS service, that has good uptime guarantees. So you can keep things simple and scale as and when you really need to.

I will go into these in more detail in my next post.


No comments:

Post a Comment