system design system design notes arpit
How to Approach System Design?
- SD is extremely practical and there is a structured way to tackle the situations.
- Take Baby Steps, no matter what!
-
Understand the problem statement
- Without having a through understanding of the problem at hand. we would easily digress
- Always ask the constrains and core features so we don't digress from it.
-
Break problem down into the components
- Eg. Design Facebook - Auth, Notification, Feed - Components / Features
- Do not create components for the sake of it
- Create components which you know are must
-
Dissect each component
- Eg. Feed might have generator, aggregator, webserver ![[Excalidraw/Drawing 2026-05-16 22.47.35.excalidraw.md#^frame=Mvz77Wnc|Feed Generator]]
-
For Each subcompoenent look into
- Database and Caching
- Scaling & Fault Tolerance
- Async Processing (Delegation)
- Communication (How each subcomponent will talk with each other like TCP, UDP, HTTP etc.)
-
Add More subcomponent if needed
- Understand the scope
- Decide how other component will talk to this new one
- Decide on 4 above factors for this new component ![[Excalidraw/Drawing 2026-05-16 22.47.35.excalidraw.md#^clippedframe=yByuS1he|Feed Generator Deepdive]]
How do you know that you have build a good system?
- Every system is infinitely buildable hence when to stop the evolution is important.
- You broker system into components.
- Each component has a clear set of responsibilities and they are mutually exclusive.
- In Feed the web-server -> servers over the HTTP.
- Feed Generator -> Pulls data from multiple services and puts into the db.
- Feed Aggregator -> combines candidate items fetched from generators, filter out redundant, ranks and create a final consumable feed
- For each componenet you've slight technical details figured out
- Database and Caching
- Scaling and Fault tolerance
- Async Processing ( Delegation)
- Communication
- Each component (in isolation) is
- Scalable - horizontally
- Fault tolerant - plan for recovery(to a stable state) in case of failure
- Available - Component functions even when some component fails
Relational Database
- History of Relational Databases
- Everything revolutionary starts with financial applications.
- Like computers first did accounting which uses ledgers which stored data as rows and columns
- Databases were developed to support accounting.
- Hence it's key properties were
- Data Consistency
- Data Durability
- Data integrity
- Constraints
- All in one place
- Everything revolutionary starts with financial applications.
- Because of these reasons, relation databases provides Transcations, Transactions makes our system correct no matter which operation we performe.
- Hence relation database provides ACID property
- A - Atomicity
- C - Consistency
- I - Isolation
- D - Durability
Atomicity
- All systems within a transaction takes effect or none
- Eg. Publish post and increase total post count
- Start Transaction
- Inset into posts
- Update stats set total_posts = total_post + 1
- Commit
- Start Transaction
Consistency
- Data will never go incorrect, no matter what
- Constraints, Cascades, triggers
- Eg.
- Foreign key checks do not allow you to delete parent if child exists - Foreign Key constraints
- If parent is deleted all childs should be deleted - Cascades
- On update you want to update some column or call functions - Triggers
Durability
- When transaction commit, the changes outlives the outage.
Isolation
- When multiple transactions are executing parallely, the isolation level determines how much changes of one transaction are visible to other
- In most cases no need to change the isolation level, when we start the mysql server we defaults to the repeatable reads.
- There 4 standard isolation levels
- Repeatable Reads
- Read Committed
- Read Uncommitted
- Serializable
We pick the relational databases for relations and acid.