System Design BASICS: Horizontal vs. Vertical Scaling
7:56

System Design BASICS: Horizontal vs. Vertical Scaling

Gaurav Sen

6 chapters7 takeaways13 key terms5 questions

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.

How was this?

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.
Understanding how to expose code as a service and leverage cloud infrastructure is the foundational step for building any scalable application.
Exposing an algorithm via an API so users can send requests and receive responses over the internet, rather than giving them direct access to the computer.
  • 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.
Scalability is a core requirement for any successful service, directly impacting user experience and business growth.
When your code is running on a machine but can't handle all the incoming connections because too many people are using it.
  • 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.
Vertical scaling is a straightforward way to increase capacity, but it has inherent physical and cost limitations.
Replacing your current computer with a new one that has a faster processor and more memory to handle more tasks.
  • 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.
Horizontal scaling provides greater resilience and potentially unlimited capacity, but introduces complexities in management and communication.
Instead of buying one super-powerful computer, you buy five standard computers and distribute user requests among them.
  • 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.
Understanding these trade-offs is crucial for choosing the right scaling strategy based on specific application needs and constraints.
A transaction involving multiple steps across different servers (horizontal) is harder to keep consistent than the same transaction on a single machine (vertical).
  • 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.
Effective system design requires making informed trade-offs to create a solution that is scalable, reliable, and meets business objectives.
Using powerful individual servers, each with significant resources, and then deploying multiple such servers behind a load balancer to handle a massive user base.

Key takeaways

  1. 1Services are built by exposing code via APIs and hosting them on cloud infrastructure.
  2. 2Scalability is the system's ability to handle increased load, achieved through vertical or horizontal scaling.
  3. 3Vertical scaling means making a single machine more powerful, offering speed and consistency but hitting hardware limits.
  4. 4Horizontal scaling means adding more machines, providing resilience and vast capacity but introducing network and consistency complexities.
  5. 5Load balancing is critical for distributing traffic in horizontal scaling.
  6. 6System design is an exercise in managing trade-offs between scalability, resilience, and data consistency.
  7. 7A hybrid approach, using powerful individual servers distributed horizontally, is common in practice.

Key terms

System DesignAPI (Application Programming Interface)RequestResponseCloud HostingScalabilityVertical ScalingHorizontal ScalingLoad BalancerResilienceData ConsistencyInter-process CommunicationNetwork Calls

Test your understanding

  1. 1What is the fundamental difference between a request and a response in a web service?
  2. 2Why is scalability a critical concern for modern applications?
  3. 3How does vertical scaling differ from horizontal scaling in terms of hardware and architecture?
  4. 4What are the primary advantages and disadvantages of horizontal scaling compared to vertical scaling?
  5. 5Why is a hybrid scaling approach often preferred in real-world system design?

Turn any lecture into study material

Paste a YouTube URL, PDF, or article. Get flashcards, quizzes, summaries, and AI chat — in seconds.

No credit card required