WalzoneInterview Prep
📞 Interviewing soon? Practice with a realistic AI mock phone interview — it calls you, then scores you. First 15 min FREE →

Software Engineering · Advanced · question 44 of 100

What is the difference between horizontal and vertical scaling in a distributed system?

📕 Buy this interview preparation book: 100 Software Engineering questions & answers — PDF + EPUB for $5

Scaling in a distributed system refers to the ability of the system to handle increasing amounts of workload by adding more resources to the system. There are two fundamental approaches to scaling a distributed system - horizontal scaling and vertical scaling.

Horizontal scaling refers to adding more nodes to a distributed system. Nodes can be added to increase computational power, storage capacity, or any other system resource. This allows the system to handle a greater volume of requests, transactions or other workloads. In a horizontally scaled system, each node typically performs the same function and is interchangeable with any other node. This means that the system can cope with increasing demand by adding more commodity hardware to the system, without relying on any specialized, expensive hardware.

Vertical scaling, on the other hand, refers to adding more resources to an existing node in a distributed system. This can be achieved by upgrading hardware components such as CPU, memory, or storage, to increase the capacity of the node. Vertical scaling is commonly referred to as "scaling up". It allows a single node to handle increasingly demanding workloads, which means that fewer nodes are required to handle the same level of traffic as a horizontally scaled system.

To illustrate the difference between horizontal and vertical scaling, let us consider an example of a web application that allows users to search for products and place orders. For this example, let us assume that the application is hosted on a distributed system, which consists of multiple nodes that handle incoming requests.

Horizontal scaling of this system would involve adding more nodes to the system. Each node would handle a portion of incoming requests, and the system would be able to process more requests as the number of nodes increased. For instance, if the system had only two nodes, adding two more nodes could double the capacity of the system.

Vertical scaling, in contrast, would involve upgrading the hardware of each node to handle more requests. For instance, if the system’s nodes had 2 CPU cores each, upgrading them to 4 CPU cores would double the processing power of each node, effectively doubling the capacity of the system.

In general, horizontal scaling is preferred over vertical scaling for several reasons. Horizontal scaling is easier to implement and maintain since new nodes can be added or removed from the system without having a significant impact on the overall performance of the system. It is also more fault tolerant since failures of individual nodes are less likely to cause system-wide failures. Additionally, horizontal scaling is typically more cost-effective since commodity hardware is cheaper than specialized hardware required for vertical scaling. However, there may be cases where vertical scaling is more appropriate, such as when the application requires extremely high-performance or when the underlying infrastructure is fixed and cannot be expanded horizontally.

Reading is step one. Saying it out loud is the interview. Our AI interviewer calls your phone and runs a realistic Software Engineering interview — then scores it.
📞 Practice Software Engineering — free 15 min
📕 Buy this interview preparation book: 100 Software Engineering questions & answers — PDF + EPUB for $5

All 100 Software Engineering questions · All topics