VibeKoding / Ensiklopedia ยท Fondasi KuatEnsiklopedia ยท Fondasi Kuat / System Design MethodologySystem Design Methodology
VK

System Design MethodologySystem Design Methodology

๐Ÿ“š Ensiklopedia ยท Fondasi KuatEnsiklopedia ยท Fondasi Kuat ๐ŸŒ Dual Bahasa (ID / EN) โšก VibeKoding Native

Ensiklopedia VibeKoding: System Design Methodology.Ensiklopedia VibeKoding: System Design Methodology.

๐Ÿ’ก Tips Praktis๐Ÿ’ก Pro Tip

System design is not about sketching architecture diagrams on a whim โ€” it's a structured methodology. Whether it's a system design interview question or real-world architecture design, both follow a similar thinking framework: first understand the problem, then estimate the scale, then design the solution, and finally dive deep into optimization.System design is not about sketching architecture diagrams on a whim โ€” it's a structured methodology. Whether it's a system design interview question or real-world architecture design, both follow a similar thinking framework: first understand the problem, then estimate the scale, then design the solution, and finally dive deep into optimization.

What will you learn from this article?What will you learn from this article?

After reading this chapter, you will gain:After reading this chapter, you will gain:

ChapterContentCore Concepts
Chapter 1Four-Step Design MethodRequirements clarification, capacity estimation, architecture design, deep optimization
Chapter 2Capacity EstimationQPS, storage, bandwidth, back-of-envelope estimation
Chapter 3Core Design PatternsCaching, database sharding, message queues, CDN
Chapter 4Trade-off ThinkingConsistency vs. availability, performance vs. cost
Chapter 5Classic Case StudiesURL shortener, feed system, flash sale system

------

1. The Four-Step System Design Method1. The Four-Step System Design Method

System design is not about drawing architecture diagrams right away. Whether in an interview or in practice, you should follow a structured process.System design is not about drawing architecture diagrams right away. Whether in an interview or in practice, you should follow a structured process.

๐Ÿ’ก Tips Praktis๐Ÿ’ก Pro Tip

Many people start drawing diagrams as soon as they get the prompt, only to design a system that is "correct but not what the interviewer wanted." Spending 5 minutes clarifying requirements can prevent 30 minutes of rework later. Common clarification questions: - What are the core features of the system? (Don't design every feature) - What is the user scale? (Determines whether distribution is needed) - What is the read/write ratio? (Determines caching strategy) - How long does data need to be retained? (Determines the storage solution)Many people start drawing diagrams as soon as they get the prompt, only to design a system that is "correct but not what the interviewer wanted." Spending 5 minutes clarifying requirements can prevent 30 minutes of rework later. Common clarification questions: - What are the core features of the system? (Don't design every feature) - What is the user scale? (Determines whether distribution is needed) - What is the read/write ratio? (Determines caching strategy) - How long does data need to be retained? (Determines the storage solution)

------

2. Capacity Estimation: The Art of Back-of-Envelope Calculations2. Capacity Estimation: The Art of Back-of-Envelope Calculations

"Back-of-envelope estimation" is a core skill in system design. You don't need precise calculations โ€” just knowing the order of magnitude is enough."Back-of-envelope estimation" is a core skill in system design. You don't need precise calculations โ€” just knowing the order of magnitude is enough.

Quick Reference for Common ConversionsQuick Reference for Common Conversions

MagnitudeConversionMemory Trick
1 day86,400 secondsโ‰ˆ 100K seconds
100M requests/dayโ‰ˆ 1,200 QPSDivide by 100K
1 KB ร— 100Mโ‰ˆ 100 GB100M small records
1 MB ร— 1Mโ‰ˆ 1 TB1M images

The 80/20 Rule in EstimationThe 80/20 Rule in Estimation

Most systems follow the 80/20 rule: 20% of the data handles 80% of the requests. This means:Most systems follow the 80/20 rule: 20% of the data handles 80% of the requests. This means:

------

3. Core Design Patterns3. Core Design Patterns

Patterns that appear repeatedly in system design โ€” mastering these will prepare you for most scenarios.Patterns that appear repeatedly in system design โ€” mastering these will prepare you for most scenarios.

3.1 Caching Patterns3.1 Caching Patterns

PatternRead PathWrite PathUse Cases
Cache-AsideCheck cache first; on miss, query DB and backfillWrite DB first, then invalidate cacheGeneral purpose, most commonly used
Read-ThroughCache layer automatically loads from DBSame as Cache-AsideRequires caching framework support
Write-BehindSame as Cache-AsideWrite to cache first, async write to DBWrite-heavy, can tolerate data loss
๐Ÿ’ก Tips Praktis๐Ÿ’ก Pro Tip

Updating the cache is prone to data inconsistency in concurrent scenarios: threads A and B update simultaneously, A writes to DB first but B updates the cache first, resulting in B's stale value in the cache. Invalidating the cache causes the next read request to reload from DB, naturally avoiding this problem.Updating the cache is prone to data inconsistency in concurrent scenarios: threads A and B update simultaneously, A writes to DB first but B updates the cache first, resulting in B's stale value in the cache. Invalidating the cache causes the next read request to reload from DB, naturally avoiding this problem.

3.2 Database Sharding3.2 Database Sharding

When a single table exceeds tens of millions of rows, or when a single database's QPS hits a bottleneck, it's time to consider database sharding.When a single table exceeds tens of millions of rows, or when a single database's QPS hits a bottleneck, it's time to consider database sharding.

StrategyApproachAdvantagesDisadvantages
Vertical shardingSplit databases by business domainBusiness decoupling, independent scalingCross-database JOINs are difficult
Horizontal shardingSplit one table into multiple tables by ruleControllable data volume per tableShard key selection is critical
Vertical table splittingSplit large columns into a separate tableReduces I/O, improves query efficiencyRequires additional JOINs

Shard Key Selection Principles:Shard Key Selection Principles:

3.3 Message Queues3.3 Message Queues

Message queues are the "shock absorbers" of distributed systems. Their core roles are decoupling, async processing, and peak shaving.Message queues are the "shock absorbers" of distributed systems. Their core roles are decoupling, async processing, and peak shaving.

ScenarioWithout QueueWith Queue
Send notification after orderOrder API calls notification service synchronously; notification failure causes order failureSend message after order success; notification service consumes asynchronously
Flash saleBurst traffic overwhelms the databaseRequests enter queue first; backend processes at its own pace
Data synchronizationService A calls Service B's API directlyService A publishes event; Service B subscribes and handles it

------

4. Trade-off Thinking: There Are No Silver Bullets4. Trade-off Thinking: There Are No Silver Bullets

The essence of architecture design is trade-offs. Every decision has a cost โ€” the key is understanding the cost and making choices appropriate for the current stage.The essence of architecture design is trade-offs. Every decision has a cost โ€” the key is understanding the cost and making choices appropriate for the current stage.

Trade-off DimensionOption AOption BDecision Basis
Consistency vs. AvailabilityStrong consistency (CP)High availability (AP)Can the business tolerate brief inconsistency?
Performance vs. CostFull cachingOn-demand cachingData volume and budget
Simplicity vs. FlexibilityMonolithic architectureMicroservicesTeam size and business complexity
Real-time vs. BatchStream processingBatch processingData timeliness requirements
Self-managed vs. HostedBuild your own MySQLUse cloud database RDSOperations capability and cost
๐Ÿ’ก Tips Praktis๐Ÿ’ก Pro Tip

Every important architecture decision should be documented: what was the context, what options were considered, why this one was chosen, and what the trade-offs are. This isn't about assigning blame โ€” it's about helping future teams understand "why it was designed this way." The format is simple: - Title: Using X instead of Y - Context: What problem we encountered - Decision: What solution we chose - Rationale: Why we chose this - Consequences: The drawbacks and risks of this decisionEvery important architecture decision should be documented: what was the context, what options were considered, why this one was chosen, and what the trade-offs are. This isn't about assigning blame โ€” it's about helping future teams understand "why it was designed this way." The format is simple: - Title: Using X instead of Y - Context: What problem we encountered - Decision: What solution we chose - Rationale: Why we chose this - Consequences: The drawbacks and risks of this decision

Common Trade-off MistakesCommon Trade-off Mistakes

MistakeManifestationCorrect Approach
Premature optimizationSharding at 1,000 daily active usersStart with a single database; shard when you hit bottlenecks
Technology-driven"I want to use Kafka" instead of "I need async processing"Start from the problem, not the technology
Ignoring operations costChoosing the optimal solution that the team can't maintainSolutions must match team capability
Pursuing perfect consistencyUsing distributed transactions for every scenarioEventual consistency is sufficient for most scenarios

------

5. Classic Case Studies5. Classic Case Studies

Let's connect the methodology we've learned through three classic examples.Let's connect the methodology we've learned through three classic examples.

5.1 URL Shortener (TinyURL)5.1 URL Shortener (TinyURL)

The URL shortener is a classic system design interview question โ€” small but comprehensive.The URL shortener is a classic system design interview question โ€” small but comprehensive.

Requirements Clarification:Requirements Clarification:

Capacity Estimation:Capacity Estimation:

MetricCalculationResult
Write QPS100M / 100 / 86,400โ‰ˆ 12 QPS
Read QPS100M / 86,400โ‰ˆ 1,200 QPS
Peak read QPS1,200 ร— 3โ‰ˆ 3,600 QPS
5-year storage1M/day ร— 365 ร— 5 ร— 100Bโ‰ˆ 18 GB
Cache (20%)18 GB ร— 20%โ‰ˆ 3.6 GB

Architecture Design:Architecture Design:

CODE
Write path: Client โ†’ API Server โ†’ ID Generator โ†’ Base62 Encode โ†’ Write to MySQL + Redis Read path: Client โ†’ CDN โ†’ API Server โ†’ Redis lookup โ†’ 302 redirect โ†“ (cache miss) MySQL query โ†’ backfill Redis

Key Design Decisions:Key Design Decisions:

5.2 Feed System5.2 Feed System

Social platform feeds (WeChat Moments, Twitter home timeline) are another classic question.Social platform feeds (WeChat Moments, Twitter home timeline) are another classic question.

Core Challenge: When a user publishes a post, how do all their followers see it?Core Challenge: When a user publishes a post, how do all their followers see it?

ApproachHow It WorksAdvantagesDisadvantages
Pull modelAggregate followees' posts in real time at read timeSimple writes, less storageSlow reads; high latency with many followees
Push modelWrite to all followers' inboxes at publish timeExtremely fast readsSevere write amplification for accounts with many followers
Hybrid (Push-Pull)Push for regular users, pull for celebritiesBalanced read/write performanceComplex implementation

Hybrid Push-Pull Approach:Hybrid Push-Pull Approach:

5.3 Flash Sale System5.3 Flash Sale System

The core challenge of a flash sale: instant ultra-high concurrency + inventory must not be oversold.The core challenge of a flash sale: instant ultra-high concurrency + inventory must not be oversold.

Traffic Characteristics:Traffic Characteristics:

Layered Peak Shaving Strategy:Layered Peak Shaving Strategy:

CODE
User request โ†’ CDN (static pages) โ†’ Gateway (rate limiting) โ†’ Message queue (peak shaving) โ†’ Inventory service (deduction)
LayerStrategyEffect
FrontendButton gray-out + random delay + CAPTCHAFilters bots, disperses requests
CDNStatic resource cachingReduces 90% of page requests
GatewayToken bucket rate limitingOnly allows traffic the system can handle
Message queueRequests queued, processed asynchronouslyPeak shaving, protects the database
Inventory serviceRedis pre-deduction + Lua atomic operationsPrevents overselling, millisecond response
๐Ÿ’ก Tips Praktis๐Ÿ’ก Pro Tip

1. Intercept upstream whenever possible: If you can block it at the CDN, don't let it reach the application layer 2. Separate reads and writes: Product detail pages use cache; only orders go to the database 3. Async processing: After the user clicks "buy," immediately return "queuing" and process in the background 4. Fallback plans: Rate limiting, circuit breaking, degradation โ€” every layer needs a Plan B1. Intercept upstream whenever possible: If you can block it at the CDN, don't let it reach the application layer 2. Separate reads and writes: Product detail pages use cache; only orders go to the database 3. Async processing: After the user clicks "buy," immediately return "queuing" and process in the background 4. Fallback plans: Rate limiting, circuit breaking, degradation โ€” every layer needs a Plan B

------

SummarySummary

System design is a highly practical skill. The core lies in structured thinking and making trade-offs.System design is a highly practical skill. The core lies in structured thinking and making trade-offs.

Key takeaways from this chapter:Key takeaways from this chapter:

  1. Four-Step Framework: Requirements clarification โ†’ capacity estimation โ†’ architecture design โ†’ deep optimization โ€” every step is essentialFour-Step Framework: Requirements clarification โ†’ capacity estimation โ†’ architecture design โ†’ deep optimization โ€” every step is essential
  2. Back-of-Envelope Estimation: Precision isn't needed โ€” just knowing the order of magnitude guides architecture decisionsBack-of-Envelope Estimation: Precision isn't needed โ€” just knowing the order of magnitude guides architecture decisions
  3. Core Patterns: Caching, database sharding, message queues, CDN, rate limiting, circuit breaking โ€” these are the "building blocks" of system designCore Patterns: Caching, database sharding, message queues, CDN, rate limiting, circuit breaking โ€” these are the "building blocks" of system design
  4. Trade-off Thinking: There are no perfect solutions, only solutions appropriate for the current stage โ€” document the rationale and cost of every decisionTrade-off Thinking: There are no perfect solutions, only solutions appropriate for the current stage โ€” document the rationale and cost of every decision
  5. Classic Cases: URL shorteners for fundamentals, feed systems for push-pull models, flash sales for high concurrency โ€” mastering these three lets you reason by analogyClassic Cases: URL shorteners for fundamentals, feed systems for push-pull models, flash sales for high concurrency โ€” mastering these three lets you reason by analogy
  6. Further ReadingFurther Reading

    • [System Design Interview](https://www.amazon.com/System-Design-Interview-insiders-Second/dp/B08CMF2CQF) - Alex Xu's system design interview classic[System Design Interview](https://www.amazon.com/System-Design-Interview-insiders-Second/dp/B08CMF2CQF) - Alex Xu's system design interview classic
    • [Designing Data-Intensive Applications](https://dataintensive.net/) - Martin Kleppmann's data-intensive application design[Designing Data-Intensive Applications](https://dataintensive.net/) - Martin Kleppmann's data-intensive application design
    • [The System Design Primer](https://github.com/donnemartin/system-design-primer) - The most comprehensive system design learning resource on GitHub[The System Design Primer](https://github.com/donnemartin/system-design-primer) - The most comprehensive system design learning resource on GitHub
    • [ByteByteGo](https://bytebytego.com/) - Alex Xu's visual system design blog[ByteByteGo](https://bytebytego.com/) - Alex Xu's visual system design blog