Chapter 9. Scaling Web Applications
While building web applications might be pretty easy, building working web applications that scale is still a difficult task. Techniques and technologies which work at the small scale can fail as you start to grow. To avoid wasting a lot of time and effort down the road, thinking about scale up front can help you to build applications that work well on a small scale and can be built up to handle large volumes of traffic and data without requiring major architectural redesigns.
In a medium-sized web application serving 10 million pages a day, you'll also be serving another few million requests for Ajax interactions (assuming your application needs some kind of API, which we'll talk about). For 10 million pages a day, you'll need to sustain 116 pages per second, although depending on your traffic profile, it might reach double or triple that at popular times of the day. If you have 10 data queries per page on average, that's over 1,000 queries per second (QPS), or 3,000 QPS at peak. That's a lot of database traffic for a single machine, so how do we design our systems to reach that rate, scale past it, and do it all in a reliable and redundant way?