System Design
A guide to system design fundamentals.
What is System Design?
Section titled “What is System Design?”System design is the strategic process of defining the architecture, components, modules, interfaces, and data for a software system to satisfy specified functional and non-effective business requirements. It acts as the blueprint that transforms high-level concepts into scalable, reliable, and efficient production-ready structures.
We can design a system in two different levels.
-
High Level Design(HLD)
- Outlines the macro level architecture and system wide interactions of an application.
- Defines whether the application uses a monolithic structure or microservices.
- Maps how major services communicate using protocols like HTTP, gRPC, or message queues.
- Selects between SQL and NoSQL databases, caching layers, and storage replication strategies.
- Plans for global scalability, high availability, fault tolerance, and disaster recovery.
-
Low Level Design(LLD)
- Specifies the micro level internal logic, class structures, and algorithms for individual components.
- Applies object-oriented programming (OOP) principles and defines explicit class fields, interfaces, and methods.
- Implements structural, behavioral, and creational patterns like Singleton, Factory, or Strategy.
- Specifies precise API request and response payloads, error handling rules, and data validation constraints.
- Writes out pseudocode or module-level algorithms to govern how code executes within a specific function.
Core Components
Section titled “Core Components”- Server
- Load Balancers
- API Gateways
- Caching
- Databases
- Message Queues
- Content Delivery Networks(CDN)
Key Principles and Metrics
Section titled “Key Principles and Metrics”- Scalability - Horizontal vs vertical scaling
- Reliability & Availability
- CAP Theorem
- Trade-offs - Every architectural choice introduces complexity; good design balances cost, latency, throughput, and maintenance overhead
Designing Process
Section titled “Designing Process”-
Clarify Requirements and Scope
- Functional Requirements: Define what features the system must support and what is out of scope (e.g., focus on video upload and feed generation while ignoring payments).
- Non-Functional Requirements: Identify system qualities like low latency, high availability, consistency, and fault tolerance.
- Scale and Constraints: Estimate daily active users, read/write ratios, requests per second (QPS), and storage needs.(Back of the envelope calculation)
-
Define Core Data Models and APIs
- API Endpoints: Outline basic contracts (like REST or gRPC endpoints) for core actions.
- Data Schemas: Identify primary data entities, database choices (SQL vs. NoSQL), and data access patterns.
-
Sketch High-Level Design
- Core Components: Draw out major building blocks like clients, load balancers, web servers, databases, and caches.
- Data Flow: Trace a user request or data journey through the system from start to finish to ensure functional requirements are met.
-
Address Scale, Failures, and Trade-offs
- Failure Modes: Identify single points of failure (SPOFs) and how to handle them using replicas, fallbacks, or retries.
- Scaling Strategies: Explain how the architecture handles 10x or 100x traffic growth using horizontal scaling, partitioning, or CDNs.
-
Wrap Up
- Summarize your design choices, review against the initial requirements contract, and mention any monitoring or operational overhead.
SQL VS NO SQL
Section titled “SQL VS NO SQL”Relational databases are vertically scalable but it has a limit.
Relational databases like MySQL and PostgreSQL are highly qualified for most of the applications but there are few scenarios when you should look for non relational databases.
-
Data Structure
- Serialized Data: Does your sql database store serialized data like json, xml or yaml in any column as they can’t follow a schema?
- Complex Relationship: Does you schema has many-many relationship or use tree structure with recursive foreign keys(also called a self-referencing foreign key) where a column in a table points directly to the primary key of the same table?
- Frequent Schema Changes: Do you frequently change schema for new application changes?
- Spars Table: Does your table contain large number of columns and they are irrelevant for few rows?
-
Scalability
- Data Volume: Is your dataset very large to store in a single server?
- Write Concurrency: Does your application reaching write limit with a single server?
- Performance: Are you running analytical processing that degrading your application performance?
NO SQL Databases:
Section titled “NO SQL Databases:”- Document DB
- For semi structure data sets
- Dynamic schema or nested schema
- support index withing the document
- Useful for content management, product catalogs etc.
- Example: MongoDB, Amazon DocumentDB
- Key-Value Store
- Insert/Update data using unique keys.
- Highly distributed and fast lookups.
- Useful for session store, caching, configurations etc.
- Example: DynamoDB, Redis
- Wide Column DB
- Data lives in a top-level keyspace, containing tables where columns are logically grouped into column families
- Different rows in the same table can have completely different sets of columns.
- Efficiently stores sparse data where many rows lack values for specific attributes without wasting disk space
- Example: Cassandra
- Graph DB
- Stores data as nodes, edges and properties.
- Complex relational data like many-many relation.
- Useful for social networking apps, fraud detection etc.
- Example: Neo4j, Amazon Neptune
Time-Series Database
Section titled “Time-Series Database”A Time Series Database (TSDB) is a software system optimized for storing, processing, and querying sequences of data points indexed in chronological order.
- Time is the primary axis of organization and querying rather than just a secondary column
- Built for append-only, high-frequency write workloads (such as continuous sensor streams or server metrics).
- Automatically splits data into time windows (e.g., daily or hourly chunks), making retention policies, downsampling, and dropping old data fast and efficient
e.g:
- Purpose-Built TSDBs: InfluxDB, Prometheus, QuestDB.
- Relational Extensions: TimescaleDB (built on PostgreSQL).
Commonly used terms
Section titled “Commonly used terms”- Load/Traffic
- Downtime
- Bandwidth
- Availability
- Scalability
- Auto Scaling
- Consistency
- QPS(Queries per second) Also known as Requests Per Second(RPS)
- Rate Limiting
- Latency
- Throughput
- Throttling
- Fault Tolerant
- Partition Tolerant
- DAU(Daily Active Users)