
System Design BASICS: Horizontal vs. Vertical Scaling
Gaurav Sen
Overview
This video introduces the fundamental concepts of system design, focusing on how to handle increasing user demand. It explains the basics of exposing code via APIs, the role of cloud hosting, and the critical concept of scalability. The core of the video contrasts two primary scaling strategies: vertical scaling (making a single machine more powerful) and horizontal scaling (adding more machines). It details the pros and cons of each, highlighting trade-offs in performance, resilience, data consistency, and hardware limitations. Finally, it suggests a hybrid approach often used in real-world applications, emphasizing that system design involves balancing these factors to meet specific requirements.
Save this permanently with flashcards, quizzes, and AI chat
Chapters
- Code running on a computer can be exposed as a service via an API (Application Programming Interface).
- Users interact with the service by sending requests, and the service responds.
- Cloud platforms provide reliable computing resources (servers) as a service, abstracting away hardware management.
- Hosting services on the cloud ensures higher reliability compared to a single desktop setup.
- Scalability is the ability of a system to handle an increasing number of requests or users.
- When a single machine can no longer handle the load, two main strategies emerge: making the machine bigger or adding more machines.
- These strategies are crucial for ensuring a service remains available and performant as its user base grows.
- Vertical scaling involves upgrading a single server to a more powerful one (e.g., more CPU, RAM).
- This approach offers fast inter-process communication as all operations happen on one machine.
- Data consistency is generally easier to maintain because there's a single source of truth.
- A major limitation is the hardware ceiling; there's a maximum size a single machine can reach.
- Horizontal scaling involves adding more machines (servers) to distribute the workload.
- This requires a load balancer to distribute incoming requests across the available servers.
- It offers resilience, as the failure of one server doesn't bring down the entire system.
- Communication between servers occurs over the network, which is slower than inter-process communication.
- Maintaining data consistency across multiple machines can be complex.
- Vertical scaling excels in speed (inter-process communication) and data consistency but faces hardware limits and single points of failure.
- Horizontal scaling offers resilience and near-linear scalability but introduces network latency and data consistency challenges.
- Load balancing is essential for horizontal scaling but unnecessary for a single vertically scaled machine.
- Network calls between servers in horizontal scaling are slower than inter-process communication within a single server in vertical scaling.
- Real-world systems often use a hybrid approach, combining aspects of both vertical and horizontal scaling.
- This typically means making each individual server as powerful as feasible (vertical) and then adding more of these capable servers (horizontal).
- System design involves balancing competing requirements like scalability, resilience, and consistency.
- Initial growth might favor vertical scaling, while mature systems often adopt horizontal scaling for better long-term resilience and capacity.
Key takeaways
- Services are built by exposing code via APIs and hosting them on cloud infrastructure.
- Scalability is the system's ability to handle increased load, achieved through vertical or horizontal scaling.
- Vertical scaling means making a single machine more powerful, offering speed and consistency but hitting hardware limits.
- Horizontal scaling means adding more machines, providing resilience and vast capacity but introducing network and consistency complexities.
- Load balancing is critical for distributing traffic in horizontal scaling.
- System design is an exercise in managing trade-offs between scalability, resilience, and data consistency.
- A hybrid approach, using powerful individual servers distributed horizontally, is common in practice.
Key terms
Test your understanding
- What is the fundamental difference between a request and a response in a web service?
- Why is scalability a critical concern for modern applications?
- How does vertical scaling differ from horizontal scaling in terms of hardware and architecture?
- What are the primary advantages and disadvantages of horizontal scaling compared to vertical scaling?
- Why is a hybrid scaling approach often preferred in real-world system design?