InterviewHubPRO
Section Overview
Q2

Question 2 of 50

Part 1: Foundational Distributed Systems Concepts & Trade-offs (1 - 10)

4%
System Design (50 Qs)•Part 1: Foundational Distributed Systems Concepts & Trade-offs (1 - 10)

Horizontal vs Vertical Scaling: Architectural Trade-offs and Bottlenecks.

In Simple Words:

  • Vertical Scaling (Scale-Up): Adding more CPU, RAM, or NVMe disk capacity to a single physical or virtual machine.
  • Horizontal Scaling (Scale-Out): Adding more discrete commodity instances into a distributed pool behind a load balancer.
ParameterVertical Scaling (Scale-Up)Horizontal Scaling (Scale-Out)
ComplexityMinimal (no distributed systems logic)High (requires load balancing, statelessness, discovery)
Hardware LimitHard physical ceilings (e.g., AWS u-24tb1.112xlarge)Practically infinite linear capacity
AvailabilitySingle Point of Failure (SPOF) during hardware faultHighly fault-tolerant (node failures auto-healed)
Network OverheadZero network latency (inter-thread IPC)Network serialization, latency, and RPC overhead
Cost CurveExponential cost for high-end enterprise hardwareLinear cost using standard commodity compute
typescript
// Architectural Rule: Designing Stateless Compute Services for Infinite Horizontal Scale
interface UserSession {
  userId: string;
  roles: string[];
  expiresAt: number;
}

// ❌ Anti-pattern: In-memory session state breaks horizontal scaling
const inMemorySessionStore = new Map<string, UserSession>();

// ✅ Optimal Pattern: External shared distributed session store or stateless JWT
export async function getSession(sessionId: string, redisClient: any): Promise<UserSession | null> {
  const data = await redisClient.get(`session:${sessionId}`);
  return data ? JSON.parse(data) : null;
}