Chapter 4 - Building Scalable Web Applications
Chapter 4 - Building Scalable Web Applications
Development
and Emerging
Technologies
Building
Scalable
Web
Applications
Building Web
Scalable Applications
Creating a website for a small audience can be
straightforward: you deploy simple server-side
logic, connect a database, and serve static or
dynamic pages. But as your user base grows and
traffic surges, performance bottlenecks can quickly
emerge, pushing your system beyond its initial
limits. This chapter delves into the architectural
designs, strategies, and tools that enable
developers to build scalable web applications.
UnderstandinScalability
g At its core, scalability means that a system can
handle increased workload without compromising
performance or requiring extensive restructuring. A
scalable web application responds quickly to user
requests even as traffic grows exponentially.
Scalability can be measured in terms of throughput
(requests per second), latency (response times), or
the ability to store and retrieve large amounts of
data without delays.
Horizontal vs Vertical
Scaling
Vertical Scaling (Scaling Up) involves adding more
resources—such as CPU, RAM, or disk space—to an
existing server. This approach is often easier in the
short term but has practical limits (hardware
constraints, cost).
Database Replication
In replication, one or more replica
databases hold copies of the main
(primary) database. Queries for reading
data can be routed to replicas, reducing
the load on the primary. Writing still
happens on the primary, which then
propagates updates to replicas.
ScalingThe Database
Layer
Database Sharding
Sharding splits large datasets into smaller,
more manageable pieces (shards), each hosted
on different servers. The challenge here is
determining a sharding key (e.g., user ID) that
distributes data evenly without overwhelming
any single shard.
ScalingThe Database
Layer
NoSQL Solutions
Some projects benefit from using NoSQL databases (e.g.,
MongoDB, Cassandra, DynamoDB) instead of, or
alongside, relational databases. NoSQL solutions often
provide horizontal scalability out of the box, making them
ideal for massive data handling.
Cynthia Sayo