It’s the classic champagne problem that most successful web apps will deal with — there are so many users on your site that things are starting to get bogged down.
Pages load slowly, network connections start timing out and your servers are starting to creak under heavy load. Congratulations — your web app has hit scale!
But now what? You need to keep everything online and want the user’s experience to be fast — speed is a feature after all.
Scaling Comes at a Price
But before we go any further, an important caveat — you shouldn’t attempt to “scale” your web app before you’ve actually run into real scaling problems.
While it may be fun to read about Facebook’s architecture on their engineering blog, it can be disastrous to think that their solutions apply to your fledgling project.
A lot of the solutions to common scaling bottleneck introduce complexity, abstraction and indirection which makes systems more difficult to reason about. This can create all sorts of problems:
- Adding new features takes longer
- Code can be harder to test
- Finding and fixing bugs is more frustrating
- Getting local and production environments to match is more difficult
You should only be willing to accept these tradeoffs if your app is actually at the limits of what it can handle. Don’t introduce complexity until it’s warranted.
As the famous quote goes:
Premature optimization is the root of all evil.
— Donald Knuth