Essential Concepts for System Design

Sep 16, 2024

System Design Essentials

Introduction

  • Aim to level up from Junior Dev by mastering 20 essential system design concepts.
  • Concepts include networking, API patterns, databases, and more.
  • Resources available at neetcode.io

Scaling Applications

Vertical Scaling

  • Add more resources like RAM or upgrade CPU.
  • Easier but very limited.

Horizontal Scaling

  • Add server replicas to handle more requests.
  • Allows for near-infinite scaling.
  • Adds redundancy and fault tolerance.
  • More complex than vertical scaling.

Load Balancers

  • Ensure even distribution of traffic across servers.
  • Reverse proxy server that directs incoming requests.
  • Common algorithms: round robin, request ID hashing.
  • Can help route requests to nearest server location.

Content Delivery Networks (CDN)

  • Used for serving static files.
  • Network of servers worldwide that cache data.
  • Can use push or pull method for caching.

Caching Techniques

  • Important for faster data retrieval.
  • Different levels: network request, disk, memory, CPU cache.

Networking Basics

IP Addresses

  • Unique identifier for devices on a network.

TCP/IP Protocol Suite

  • Reliable protocol for data transmission over the internet.
  • Data sent in packets; TCP ensures packets are resent if needed.

Domain Name System (DNS)

  • Translates domains to IP addresses.
  • DNS queries resolve domain name to IP address, cached for efficiency.

HTTP Protocol

  • Client-server model for web communication.
  • Requests include headers (metadata) and body (content).
  • Response includes headers and body.

API Patterns: REST

  • Stateless HTTP APIs.
  • Standardized response codes: 200 (success), 400 (client error), 500 (server error).

API Patterns: GraphQL

  • Allows fetching multiple resources with a single request.

API Patterns: gRPC

  • Framework for server-to-server communication, using Protocol Buffers.
  • More storage-efficient than JSON.

WebSockets

  • Enables bi-directional communication.
  • Useful for real-time applications like chat apps.

Data Storage

SQL Databases

  • Use data structures like B-trees for efficient data storage and retrieval.
  • ACID compliant (Atomicity, Consistency, Isolation, Durability).

NoSQL Databases

  • Drop consistency constraints for scalability.
  • Types: key-value stores, document stores, graph databases.

Sharding

  • Technique to horizontally scale databases.
  • Uses a Shard key to distribute data.

Replication

  • Read-only copies of databases for scaling reads.
  • Leader-follower and leader-leader replication techniques.

CAP Theorem

  • Trade-offs in replicated databases: consistency vs. availability.

Message Queues

  • Durable storage with replication/sharding.
  • Decouple parts of applications for better data processing.

Conclusion

  • Software engineering involves efficient data storage and movement.
  • Further learning resources available at neetcode.io.