Skip to content

System Design Core Principles

The system should handle increasing traffic without degrading performance.

Increase the number of application instances.

Load Balancer
/ | \
App1 App2 App3

Advantages

  • High availability
  • Fault tolerance
  • Better scaling

Increase machine resources.

4 CPU
8 CPU
16 CPU

Advantages

  • Simpler architecture

Disadvantages

  • Hardware limits
  • Single point of failure

The system should remain operational.

Techniques

  • Replication
  • Failover
  • Load balancing
  • Multi-region deployment

The system should consistently produce correct results.

Common techniques

  • Retry
  • Timeout
  • Circuit Breaker
  • Monitoring
  • Logging

The system continues operating even if components fail.

Examples

  • Kafka replication
  • Database replicas
  • Kubernetes self-healing
  • Auto restart

Services should depend minimally on each other.

Communication methods

  • REST APIs
  • Kafka
  • RabbitMQ
  • Events

Benefits

  • Independent deployment
  • Easier maintenance
  • Better scalability

Related functionality should remain together.

class UserService {
createUser();
updateUser();
deleteUser();
}

Avoid mixing unrelated responsibilities.


Distributed systems can guarantee only two of the following:

  • Consistency
  • Availability
  • Partition Tolerance
graph TD

CAP --> Consistency

CAP --> Availability

CAP --> PartitionTolerance

Data becomes consistent over time rather than immediately.

Examples

  • Cassandra
  • DynamoDB
  • Event-driven microservices

flowchart LR
Client --> LB[Load Balancer]
LB --> API[API Servers]
API --> Cache[(Redis)]
API --> DB[(MySQL)]
API --> MQ[Kafka/RabbitMQ]
  • URL Shortener
  • Payment System
  • Rate Limiter
  • Notification Service
  • Chat Application
  • Ticket Booking
  • Distributed Cache
  • API Gateway
  • Email Service
  • Video Streaming

  • Scale horizontally (more instances) for availability and fault tolerance; scale vertically (more resources) only as a simpler stopgap since it hits hardware limits and remains a single point of failure.
  • Loose coupling and high cohesion work together: services depend minimally on each other, while related functionality stays grouped within a service.
  • CAP theorem forces a trade-off during a network partition: a distributed system can only guarantee two of Consistency, Availability, and Partition Tolerance at once.
  • Eventual consistency (Cassandra, DynamoDB, event-driven microservices) trades immediate consistency for availability and partition tolerance.