System Design Building Blocks

Kay Ashaolu - Instructor

Aishwarya Sriram - TA

Building Blocks: Introduction

  • Storage + Tasks = Building Block
  • Reusable, purposeful units
  • Essential for robust architecture

Motivation & Recap

  • Everything reduces to bits: zeros and ones
  • Bits represent Storage (data) and Tasks (instructions)

Storage Units

  • Represent structured data
  • Examples: lists, arrays, dictionaries, trees, graphs
  • Organize data and define relationships

Task Units

  • Represent instructions
  • Executed by CPUs/GPUs
  • Examples: functions, methods, services

Building Blocks Defined

  • Combination of Storage and Task units
  • Purposeful, reusable components
  • Examples: User services, Payment gateways, Search engines

Why Building Blocks?

  • Mirror real-world logic
  • Self-contained data and behavior
  • Form intuitive, stable, complex systems

Example: Simple Web Server

  • Waits for requests
  • Returns files (HTML, images)

Server Building Block

  • Storage: URL paths as keys
  • Task: Instructions generating responses
  • Maps URL to task handlers

Server Internals: Routing Table

  • Dictionary storage unit
  • URL path → Task handler
routing_table = {
    "/": home_page,
    "/post/1": post_one_page,
}

Tasks as Request Handlers

  • URL path → Specific Task unit
  • Executes instructions
  • Returns response

File System Building Block

  • Tree-based storage
  • Hierarchical file paths
  • Retrieves raw data

File System Structure

  • Organized hierarchically
public_html/
├── post/
│   ├── 1.html
│   └── 2.html

Interaction: Server & File System

  • Server receives URL path
  • Task requests file from File System
  • File System returns data
  • Server sends data to user

Architecture Diagram

User → Server → Task Unit → File System → User

Summary: Static Web Server

  • Server handles requests
  • File System provides file data
  • Building blocks create holistic system

Building Blocks & Intuition

  • Data structures: Storage Units
  • Algorithms: Task Units
  • Modules/Components: Building Blocks

Building Blocks as Architecture

  • Combine blocks into architectures
  • Understand strengths, weaknesses
  • Enables debugging, scaling, evolving

Gaining Senior-Level Intuition

  • Recognize common patterns
  • Understand why decisions are made
  • Anticipate architecture behavior

Practical System Design Approach

  • Define clear requirements
  • Match building blocks to needs
  • Learn through case studies

The Seven Building Blocks

Type Building Block Icon
Task Worker
Task Service
Storage Key-Value Store
Storage File Store
Storage Queue
Storage Relational Database
Storage Vector Database

Worker

Strength Weakness
Efficient for long tasks Hard to debug
Built With
Task Unit
What is it?
Workers operate independently of a user's direct interaction, performing tasks like data processing or job execution in the background

Service

Strength Weakness
Delivers requested content efficiently  Responsiveness drops with high load or slow tasks
Built With
Task Units
Dictionary Storage Unit
What is it?
Services map publicly available paths to functions (task units) that centralize resources and services for specific purposes

Key-Value Store

Strength Weakness
Fast and scalable Limited query flexibility
Built With
Dictionary Storage Unit
What is it?
A key-value store is a simple database that stores data as unique key-value pairs for fast retrieval

File Store

Strength Weakness
Organize and store data efficiently Can have slower performance over time due to fragmentation
Built With
Tree Storage Unit
What is it?
A file store organizes data hierarchically using tree structures, where directories are nodes and files are leaf nodes

Queue

Strength Weakness
Ensures fair and orderly processing of tasks Can become a bottleneck if items are added faster than they are processed
Built With
Array Storage Unit
What is it?
A queue is a data structure that processes items in a first-in, first-out (FIFO) order, commonly used for tasks like scheduling and buffering

Relational Database

Strength Weakness
Ensures data is correct and available Massive scale is difficult
Built With
Task Unit
Array and Tree Storage Units
What is it?
A relational database organizes and stores data in structured tables with rows and columns, enabling relationships between tables through keys for efficient querying and management

Vector Database

Strength Weakness
Excels at finding similar items quickly in large datasets Less precise and scalable for very large datasets or exact matches
Built With
Task Unit
Array and Tree Storage Units
What is it?
A vector database stores and searches data as mathematical vectors, often used for finding similar items in applications like AI and recommendations

External Entities

Entity Description Icon
User
 
Represents the end user that is interacting with the system
Time
 
Represents a scheduled and/or recurring external trigger
External
Service
Represents an integration to a service that is outside the system

Wrap-Up

  • Building blocks are core principles
  • Develop intuition over memorization
  • Technology agnostic approach

System Design Building Blocks - Backend Webarch

By kayashaolu

System Design Building Blocks - Backend Webarch

Course Website: https://groups.ischool.berkeley.edu/i253/sp25

  • 62