xxv
INTRODUCTION
tunnel vision here, but it’s worth trying to develop a rounded view of the situation. Although speed
is important, it’s not the “be all and end all.” In your quest for more and more savings, be wary of
stripping down your website too much.
Scaling Up versus Scaling Out
There are two basic approaches to scaling your website:
➤
Scaling up (sometimes referred to as scaling vertical) means keeping the same number of
servers but upgrading the server hardware. For example, you may run your whole setup from
a single server. As your site gets more traf c, you discover that the server is beginning to
struggle, so you throw in another stick of RAM or upgrade the CPU — which is scaling up.
➤
With scaling out (also referred to as scaling horizontally), you increase the number of
machines in your setup. For example, in the previous scenario, you could place your data-
base on its own server, or use a load balancer to split web traf c across two web servers.
So, which method is best? You’ll hear a lot of criticism of vertical scaling, but in reality, it is a viable
solution for many. The majority of websites do not achieve overnight success. Rather, the user base
steadily increases over the years. For these sites, vertical scaling is perfectly ne. Advances in hard-
ware mean that each time you want to upgrade, a machine with more CPU cores, or more memory,
or faster disks will be available.
Scaling up isn’t without its problems, though. You pay a premium for top-of-the-range hardware.
The latest monster server will usually cost more than two mid-range servers with the same overall
power. Also, additional CPU cores and RAM don’t tend to result in a linear increase in perfor-
mance. For example, no matter how much RAM you have, access to it is still along a xed-width
bus, which can transfer only at a nite rate. Additional CPU cores aren’t a great bene t if your bot-
tleneck is with a single-threaded application. So, scaling up offers diminishing returns, and it also
fails to cope when your site goes stratospheric. For that, you need a topology where you can easily
add additional mid-range servers to cope with demand.
Scaling out is trickier, because it involves more planning. If you have a pool of web servers, you
must think about how sessions are handled, user uploads, and so on. If you split your database over
several machines, you must worry about keeping data in sync. Horizontal scaling is the best long-
term solution, but it requires more thought as to how to make your setup scalable.
Finally, be wary of taking the idea of horizontal scaling to extremes. Some people take the idea
too far, setting up clusters of Pentium I machines because “that’s how Google does it.” Actually,
Google doesn’t do this. Although Google scales out to a high degree, it still uses decent hardware
on each node.
Scaling out isn’t without its drawbacks either. Each additional node means extra hardware
to monitor and replace, and time spent installing and deploying code. The most satisfactory
arrangement tends to be through a combination of scaling up and scaling out.
flast.indd xxvflast.indd xxv 05/11/12 4:57 PM05/11/12 4:57 PM