System Design: Requirements

Requirements are the foundation of good system design.

Golden Rule:
Do not start with Kafka, Redis, databases or microservices. Start with requirements.

1. Core Principle

VAGUE PROBLEM
      |
      v
CLARIFY REQUIREMENTS
      |
 +----+----+
 |         |
 v         v
FUNCTIONAL     NON-FUNCTIONAL
 "WHAT?"        "HOW WELL?"
 |              |
 +------+-------+
        |
        v
CAPACITY ESTIMATE
        |
        v
CONSTRAINTS
        |
        v
TRADE-OFFS
        |
        v
ARCHITECTURE

Key idea: Requirements → Constraints → Trade-offs → Architecture.

2. Functional Requirements

What should the system do?
USER
 |
 +--> Send Message
 |
 +--> Receive Message
 |
 +--> Create Group
 |
 +--> View History
 |
 +--> Get Notification

Functional requirements describe the actual behavior and features of the system.

  • Messaging: send, receive, group chat, history
  • YouTube: upload, watch, search, like/comment
  • Payment: initiate, validate, process, view transaction

3. Identify Actors

Who interacts with the system?
SYSTEM
 /     |      \
/      |       \
v      v        v
Customer Admin External System

Actors may include customers, administrators, internal teams, external systems, and other services.

4. User Journey

Don't just list features. Understand the workflow.

User
 |
 v
Select Product
 |
 v
Validate
 |
 v
Create Order
 |
 v
Payment
 |
 v
External System
 |
 v
Update Status
 |
 v
Notify User
Key takeaway: User journeys reveal system boundaries.

5. Scope

Do not try to design the entire product.

REQUIREMENTS
     |
     +--> MUST HAVE
     |
     +--> NICE TO HAVE
     |
     +--> OUT OF SCOPE

Example: Messaging

Must: Send, Receive, History

Nice: Typing indicator, Read receipt, Reactions

Out: Video calling, Voice calling

6. APIs

Once functionality is clear, express it through APIs.

Functional Requirement
          |
          v
         API
POST /messages

GET /users/{id}/messages

POST /conversations

GET /conversations/{id}/messages
Do not start with APIs before understanding the user journey.

7. Non-Functional Requirements

How well should the system work?
ScalabilityPerformanceAvailabilityReliabilityDurabilityConsistencySecurityMaintainabilityObservabilityCost

NFRs describe system qualities and constraints rather than features.

8. Quantify Everything

Avoid vague statements.

"System should be fast"
"System should scale"
"Highly available"

Instead:

Users        = 10M
Messages     = 100M/day
Latency      = p95 < 200ms
Availability = 99.99%
RPO          = 0
Senior architects convert adjectives into measurable targets.

9. Scalability

Can the system handle growth?
Users
 |
 +--> 1M → 10M → 100M

Traffic
 |
 +--> 1K → 10K → 100K RPS

Data
 |
 +--> GB → TB → PB

Geography
 |
 +--> India → Asia → Global

Horizontal Scaling

          Load Balancer
          /     |      \
         v      v       v
      Server  Server  Server

Horizontal scaling means adding more instances rather than continuously making one server bigger.

10. Capacity Estimation

Example: 10 million messages/day.

10,000,000
-----------
  86,400

≈ 116 messages/sec

Then estimate peak traffic.

Average = 116/sec

Peak = Average × Peak Factor

If peak factor = 10

Peak ≈ 1,160/sec

Then ask: servers, DB writes, queue partitions, storage, bandwidth.

11. Performance

Performance is not just average latency.

p50 < 50ms
p95 < 200ms
p99 < 500ms
99 users → 20ms
1 user   → 10 seconds

Average can hide the problem.
p99 exposes it.
Tail latency matters.

12. Availability

How often must the system be operational?
AvailabilityApprox. Downtime / Year
99%3.65 days
99.9%8.76 hours
99.99%52.6 minutes
99.999%5.26 minutes

High Availability Usually Requires

High Availability
       |
       +--> Replication
       +--> Redundancy
       +--> Failover
       +--> Multi-AZ
       +--> Health Checks

13. Availability vs Reliability

AVAILABILITY
     |
     v
"Can I access the system?"
RELIABILITY
     |
     v
"Does the system do the correct thing?"

Example

Payment API → HTTP 200
       |
       v
Transaction NOT persisted
       |
       v
Available = YES
Reliable  = NO

14. Durability

Once data is successfully written, can we lose it?
WRITE
  |
  v
DURABLE STORAGE
  |
  +--> Replication
  +--> Backup
  +--> Persistence
  +--> Recovery

RPO

Recovery Point Objective: Maximum acceptable data loss.

RPO = 5 minutes
→ Potentially lose up to 5 minutes of data

For financial transactions, the target may be close to zero data loss.

15. RTO

Recovery Time Objective: How quickly must the system recover?

System Failure
      |
      v
    10 min
      |
      v
System Restored

RTO = 10 min
Remember:
RPO → How much data can I lose?
RTO → How much time can I be down?

16. Consistency

When multiple copies exist, when should they agree?
           Database
          /        \
         v          v
     Replica 1   Replica 2
         |          |
         +----?-----+
              |
         Consistency

Strong Consistency

WRITE
  |
  v
Reads see latest committed value

Eventual Consistency

WRITE
  |
  +--> Replica A updated
  |
  +--> Replica B updates later
              |
              v
       Eventually consistent

17. Consistency Trade-off

        STRONG CONSISTENCY
                |
                v
        More coordination
                |
                v
        Potential latency
                |
                v
      Availability trade-off

Strong consistency

  • Bank balance
  • Payment state
  • Account ownership

Eventual consistency

  • Likes
  • Views
  • Social counters
  • Recommendations

18. Reliability / Failure Handling

Assume everything can fail.

Server       → FAIL
Database     → FAIL
Network      → FAIL
Kafka        → FAIL
Dependency   → TIMEOUT
Deployment   → FAIL
Region       → FAIL
Failure
  |
  +--> Timeout
  +--> Retry
  +--> Circuit Breaker
  +--> Failover
  +--> Idempotency
  +--> Dead Letter Queue

19. Idempotency

Especially important for payment systems.

Client
  |
  | Payment ₹1000
  v
Server
  |
  X Timeout

The client may retry, potentially charging twice.

Solution

Request
  |
  +--> Idempotency-Key: ABC123
                    |
                    v
              Process ONCE
Same request repeated → same result, no duplicate side effect.

20. Maintainability

Can engineers safely change this system later?
Maintainability
      |
      +--> Modularity
      +--> Testing
      +--> Documentation
      +--> Automation
      +--> Clean APIs
      +--> Observability
      +--> CI/CD
More microservices ≠ better architecture.

21. Security

SECURITY
   |
   +--> Authentication
   |       "Who are you?"
   |
   +--> Authorization
   |       "What can you do?"
   |
   +--> Encryption
   |       "Can others read it?"
   |
   +--> Audit
   |       "Who did what?"
   |
   +--> Abuse Protection
           "Can someone misuse it?"

Security Layers

Data in Transit → TLS
Data at Rest    → Encryption
Sensitive Data  → Masking / Tokenization
APIs            → Auth + Rate Limiting

22. Observability

              OBSERVABILITY
                   |
       +-----------+-----------+
       |           |           |
      Logs       Metrics     Traces
       |           |           |
   What?        How much?    Where?

Useful Metrics

RPS
Error Rate
Latency
CPU
Memory
DB Connections
Queue Depth

Distributed Trace

API
 |
 | 20ms
 v
Order Service
 |
 | 30ms
 v
Payment Service
 |
 | 200ms
 v
Bank

Tracing identifies where a request spends its time.

23. Cost

Architecture is also economics.

             BUSINESS
                |
                v
       Required SLA / SLO
                |
                v
          Architecture
                |
                v
              COST
Build for the required SLA, not an imaginary SLA.

24. Requirements → Architecture

RequirementArchitectural Consequence
High TrafficHorizontal Scaling
High AvailabilityReplication + Redundancy
Low LatencyCache + Efficient Communication
High WritesPartitioning / Sharding
Heavy ReadsCache + Read Replicas
Strong ConsistencyTransactions / Coordination
Eventual Consistency OKAsync / Event Driven
Zero Data LossDurable Storage + Replication
Global UsersMulti-Region
SecurityAuth + Encryption + IAM + Audit
Easy OperationsAutomation + Observability
Low CostRight-size Infrastructure

25. Architecture Decision Chain

When choosing a technology, think in this order:

Requirement
     |
     v
Constraint
     |
     v
Trade-off
     |
     v
Pattern
     |
     v
Technology

Example

Need:
High write throughput
       |
       v
Constraint:
Single DB cannot handle writes
       |
       v
Trade-off:
Partition data
       |
       v
Pattern:
Sharding / Partitioning
       |
       v
Technology:
Choose appropriate DB / Queue
Technology is the final decision, not the starting point.

Quick Revision — 25 Points

  1. Start with requirements, not technology.
  2. Functional requirements = WHAT the system does.
  3. Identify all important actors.
  4. Understand user journeys.
  5. Clearly define scope.
  6. Translate core functions into APIs.
  7. NFRs = HOW WELL the system works.
  8. Quantify NFRs wherever possible.
  9. Understand scalability dimensions.
  10. Estimate average and peak capacity.
  11. Use latency percentiles such as p95/p99.
  12. Define availability targets.
  13. Understand availability vs reliability.
  14. Define durability and RPO.
  15. Define recovery time using RTO.
  16. Choose an appropriate consistency model.
  17. Understand consistency trade-offs.
  18. Design explicitly for failures.
  19. Use idempotency for retryable operations.
  20. Design for maintainability.
  21. Build security into the architecture.
  22. Make the system observable.
  23. Consider infrastructure/business cost.
  24. Map requirements directly to architecture.
  25. Choose technology only after requirements, constraints, trade-offs and patterns are clear.

Ultimate Mental Model

WHAT?
  |
Functional
  |
  v
HOW WELL?
  |
Non-Functional
  |
  v
HOW MUCH?
  |
Capacity
  |
  v
WHAT IF?
  |
Failure
  |
  v
WHAT TRADE-OFF?
  |
  v
ARCHITECTURE

Requirements → Constraints → Trade-offs → Architecture