⬡ Hub
Skip to content

System Design Concepts

1. Core Principles

1.1 Scalability

  • Vertical Scaling (Scale Up): Adding power to a single machine.
  • Horizontal Scaling (Scale Out): Adding more machines to a pool.

1.2 Reliability

  • System continues to work correctly even when things go wrong.

1.3 Availability

  • System is operational at a given point in time (e.g., 99.99% uptime).

2. Key Components

2.1 Load Balancing

  • Distributes traffic across servers (Nginx, HAProxy, AWS ELB).
  • Algorithms: Round Robin, Least Connections, IP Hash.

2.2 Caching

  • Client Side: Browser cache.
  • CDN: Content Delivery Network (Cloudfront, Akamai) for static assets.
  • Server Side: Redis, Memcached for DB query results or session data.
  • Strategies: Cache-Aside, Write-Through, Write-Back.

2.3 Databases

  • SQL (Relational): MySQL, Postgres. ACID compliance.
  • NoSQL (Non-Relational):
    • Key-Value: DynamoDB, Redis.
    • Document: MongoDB.
    • Wide Column: Cassandra.
    • Graph: Neo4j.
  • Replication: Master-Slave, Master-Master.
  • Sharding: Partitioning data across servers.

2.4 Asynchronous Processing

  • Message Queues: RabbitMQ, Kafka, SQS. Decoupling services.
  • Event Driven Architecture: Pub/Sub models.

3. Communication Protocols

  • REST: Standard HTTP verbs (GET, POST).
  • GraphQL: Flexible queries.
  • gRPC: High performance, Protobuf based.
  • WebSockets: Real-time bi-directional.

4. Theorums

  • CAP Theorem: Consistency, Availability, Partition Tolerance (Pick 2).
    • CP: Banking.
    • AP: Social Media timelines.

5. Common Design Problems

  • URL Shortener (TinyURL).
  • Rate Limiter.
  • Web Crawler.
  • Notification System.
  • Chat Application (WhatsApp).