DSA

Part 20 — Design Problems

A Staff/Principal-level guide to approaching design-oriented interview problems through requirements, constraints, architecture, trade-offs, scale, reliability, and technical judgment.

Deepak Mishra12 min read


As coding interviews progress from algorithms toward senior and Staff-level engineering, the nature of the problems changes.

The available interview material explicitly places Chapter 20+ in the area of Staff/Principal-oriented design and domain topics, after the foundational data structures and advanced algorithmic chapters. It also notes that senior candidates should expect greater emphasis on system design and architecture.

That transition is important.

A coding problem asks:

Can you produce a correct algorithm?

A design problem asks something broader:

Can you turn ambiguous requirements into a system that is correct, scalable, reliable, maintainable, and appropriate for the business constraints?


1. From Algorithm to Architecture

The progression looks like:

Part 1–14
Data Structures + Core Algorithms

Part 15–18
Advanced Algorithms

Part 19
Parallel Computing

Part 20
Design Problems

The available source describes the later chapters as moving toward more advanced material and identifies Chapter 20+ with Staff/Principal-oriented design/domain topics.

At this point, memorizing solutions becomes less useful.

You need a reusable design framework.


2. Start With Requirements

Do not begin a design interview with:

Let's use Kafka.
Let's use Kubernetes.
Let's use Redis.
Let's use PostgreSQL.

Start with:

What problem are we solving?
Who are the users?
What are the critical use cases?
What scale should we support?
What are the latency requirements?
What consistency is required?
What availability is required?

The source repeatedly emphasizes clarification before solving: input, output, constraints, edge cases, and performance targets should be established before choosing an approach.

The same principle applies at system-design level.


3. Functional vs Non-Functional Requirements

Separate requirements into two categories.

Functional

What should the system do?

Create
Read
Update
Delete
Search
Process
Notify
Recommend
Analyze

Non-functional

How should the system behave?

Latency
Availability
Scalability
Durability
Consistency
Security
Cost
Observability

A strong design starts by making both explicit.


4. Clarify the Scale

A system serving:

1,000 users

is fundamentally different from one serving:

100 million users

Ask:

Requests per second?
Data volume?
Read/write ratio?
Peak traffic?
Growth rate?
Geographic distribution?
Retention period?

Scale determines architecture.


5. Back-of-the-Envelope Estimation

Before selecting infrastructure, estimate the workload.

For example:

100 million requests/day

Average requests per second:

100,000,000 / 86,400
≈ 1,157 requests/sec

If peak traffic is 5× average:

Peak ≈ 5,785 requests/sec

This immediately gives architectural intuition.

The exact numbers are less important than demonstrating the reasoning.


6. API Design

Once requirements are understood, define the interface.

For example:

POST /users
GET  /users/{id}
PUT  /users/{id}
DELETE /users/{id}

For each API clarify:

Request
Response
Authentication
Authorization
Idempotency
Error behavior
Pagination
Rate limits
Timeouts

The source emphasizes that even coding problems require understanding the function interface, arguments, return value, mutation, and expected input/output.

The same discipline scales naturally to API design.


7. High-Level Architecture

A common design decomposition is:

Clients

API / Load Balancer

Application Services

 ┌───────────┬───────────┐
 ↓           ↓           ↓
Cache      Database    Queue

                    Workers

Do not treat this as a template to memorize.

The architecture should emerge from:

Requirements
+
Constraints
+
Workload

8. Data Storage

Ask:

What data do we store?
How is it accessed?
How frequently is it updated?
Do we need transactions?
Do we need joins?
Do we need flexible schemas?
Do we need strong consistency?

Then choose the storage model.

For example:

Relational
→ transactions + structured relationships

Key-value
→ simple high-scale lookups

Document
→ flexible aggregate-oriented data

Search index
→ text/search workloads

Object storage
→ large immutable objects

The Staff-level skill is not knowing the names of databases.

It is knowing why a particular storage model fits the access pattern.


9. Caching

Caching can reduce:

database load
latency
network traffic

But introduces questions:

What is cached?
How long?
Who invalidates it?
What happens when it is stale?
What happens on cache failure?

The classic trade-off is:

Freshness

Performance

Never propose a cache without explaining its invalidation strategy.


10. Asynchronous Processing

Not every operation needs to complete synchronously.

Suppose a request triggers:

Send email
Generate report
Update analytics
Generate recommendation

These may be asynchronous.

Request

API

Queue

Worker

Background processing

The user-facing request can return without waiting for every downstream operation.


11. Queues and Backpressure

Queues also provide a buffer:

Producer

Queue

Consumers

If producers temporarily become faster than consumers:

queue depth ↑

This creates a useful signal.

A production system should define:

maximum queue size
retry policy
dead-letter behavior
backpressure
consumer scaling

12. Reliability

A Staff-level design must answer:

What happens when something fails?

Consider:

Database unavailable
Cache unavailable
Worker crashes
Network timeout
Queue unavailable
Dependency returns errors
Region becomes unavailable

Failure should be part of the design rather than an afterthought.


13. Retry Carefully

Retries can help recover from transient failures.

But uncontrolled retries can create:

failure

retry

more load

more failure

more retries

This can become a retry storm.

Good designs consider:

timeouts
exponential backoff
jitter
retry limits
idempotency
circuit breakers

14. Idempotency

An operation is idempotent when repeating it produces the same intended result.

This matters when:

client retries
network response is lost
worker crashes after processing
message is delivered twice

For example:

POST payment

must be carefully designed if the client might retry.

A common approach is an idempotency key:

request
+
idempotency_key

deduplicate

single logical operation

15. Consistency

A distributed system often has to choose where it needs strong consistency and where eventual consistency is acceptable.

Ask:

Does every reader need the newest value immediately?
Can stale data be tolerated?
For how long?

For example:

Account balance
→ stronger consistency

Recommendation feed
→ eventual consistency may be acceptable

The right answer depends on business semantics.


16. Availability

Availability asks:

Can users continue using the system when components fail?

Techniques include:

replication
redundancy
failover
health checks
multi-zone deployment
multi-region deployment

But every increase in availability usually adds complexity and cost.

Therefore:

Availability requirement

Architecture

Cost + operational complexity

17. Scalability

There are two fundamental directions.

Vertical scaling

Bigger machine

Horizontal scaling

More machines

Horizontal scaling generally requires additional thinking around:

load balancing
partitioning
shared state
data replication
coordination

The source’s Staff-level material repeatedly emphasizes reasoning from constraints rather than blindly choosing a technique.


18. Partitioning

Large datasets can be partitioned:

Dataset
├── Partition A
├── Partition B
├── Partition C
└── Partition D

Possible partition keys include:

user_id
tenant_id
region
time
hash

The partition key is a major architectural decision.

A poor key can create:

hot partitions
uneven load
expensive rebalancing

19. Hotspots

Suppose:

99% of requests

target one partition.

Even if the system has:

100 servers

one server may become overloaded.

This is a hotspot.

Therefore Staff-level design asks:

Is the workload evenly distributed?

not merely:

Can we add more machines?

20. Observability

A production system needs to tell us what is happening.

Three major pillars are:

Logs
Metrics
Traces

Useful metrics include:

QPS
p50 latency
p95 latency
p99 latency
error rate
CPU
memory
queue depth
cache hit rate
database latency

A design without observability is difficult to operate.


21. SLO Thinking

Instead of saying:

“The system should be fast.”

define something measurable:

99% of requests < 200 ms

or:

99.9% monthly availability

This converts vague requirements into engineering constraints.


22. Security

Security should be part of the architecture.

Consider:

Authentication
Authorization
Encryption
Secrets management
Input validation
Audit logging
Rate limiting
Data isolation

Ask:

Who can access this data?
Who can modify it?
What happens if credentials are compromised?

23. Multi-Tenancy

Enterprise systems often serve multiple customers.

A design must consider:

tenant isolation
authorization
quotas
rate limits
data partitioning
billing
noisy-neighbor protection

The architecture should make tenant boundaries explicit.


24. Cost Is a Design Constraint

A technically excellent architecture can still be a poor design if it is unnecessarily expensive.

Ask:

How much traffic?
How much storage?
How much compute?
How much network?
How much redundancy?
How much operational overhead?

Then compare alternatives.

The source explicitly encourages Staff candidates to reason about trade-offs such as CPU vs memory, latency vs throughput, preprocessing vs query time, and simplicity vs flexibility.


25. Architecture Trade-offs

A strong design discussion sounds like:

Option A
→ simpler
→ cheaper
→ lower scale

Option B
→ more complex
→ higher cost
→ better scalability

Given the current requirement,
I would choose A.

If traffic grows by 10×,
I would move toward B.

That demonstrates judgment.


26. Design for Failure

A useful mental model is:

Component

How can it fail?

What does the user experience?

Can we recover automatically?

What happens during prolonged failure?

Repeat this for every major dependency.


27. Staff-Level Design Framework

Use this sequence:

1. Clarify requirements

2. Define scale

3. Identify core entities

4. Define APIs

5. Draw high-level architecture

6. Design data storage

7. Define caching

8. Define asynchronous processing

9. Analyze consistency

10. Analyze availability

11. Analyze failure modes

12. Add observability

13. Discuss security

14. Estimate cost

15. Discuss bottlenecks and alternatives

28. What Interviewers Are Really Looking For

The source describes Staff-level interviews as evaluating more than coding: system design, architecture, leadership, communication, and judgment also matter.

Therefore, a Staff-level design interview is testing whether you can:

Frame ambiguity
      +
Make architectural decisions
      +
Explain trade-offs
      +
Predict failure modes
      +
Reason about scale
      +
Communicate clearly

29. Avoid Technology-First Design

Weak:

Kafka
Redis
Kubernetes
Postgres
Elastic

Strong:

Requirement

Constraint

Workload

Design decision

Technology choice

Technology should be the consequence of architecture, not the starting point.


30. Design Communication

The source strongly recommends thinking out loud and exposing decisions rather than narrating every keystroke.

The same principle applies to system design.

Say:

“I considered synchronous processing, but because report generation can take several seconds, I would move it to an asynchronous worker.”

That communicates:

Alternative

Constraint

Decision

This is far stronger than simply drawing a queue.


31. A Complete Design Conversation

A strong interview flow can sound like:

"I'll start by clarifying requirements."



"At peak we expect approximately X requests/sec."



"The workload is read-heavy."



"I'll use a cache to reduce database pressure."



"The write path requires stronger consistency."



"Long-running processing will be asynchronous."



"I'll partition data by tenant/user."



"The main scaling risk is a hot partition."



"I'll monitor p95/p99 latency and queue depth."



"If traffic increases 10×, I would revisit partitioning
and horizontal scaling."

This is Staff-level architectural reasoning.


32. Design Review Checklist

Before finishing a design, ask:

□ Are requirements clear?

□ Do we know the expected scale?

□ Are APIs defined?

□ Is the data model clear?

□ Is the storage choice justified?

□ What is cached?

□ What is asynchronous?

□ What happens when dependencies fail?

□ What consistency model is required?

□ How does the system scale?

□ How is data partitioned?

□ Can hotspots occur?

□ What happens during traffic spikes?

□ How do we monitor the system?

□ How is the system secured?

□ What does it cost?

□ What are the major bottlenecks?

□ What alternative architecture did we reject?

33. The Staff-Level Difference

A junior answer often focuses on:

"What technology should I use?"

A senior answer focuses on:

"How should I build it?"

A Staff answer focuses on:

"Why should the organization build it this way,
what trade-offs are we accepting,
how will it behave at scale,
and how will we evolve it?"

That is the real transition from implementation to architecture.


34. Part 19 → Part 20

The progression is now:

Part 18 — Graphs

Model relationships and dependencies

Part 19 — Parallel Computing

Exploit independent work
while controlling coordination

Part 20 — Design Problems

Turn requirements into
scalable, reliable systems

The jump is significant.

We move from:

How do I solve this computation?

to:

How do I build a system that performs this computation
reliably at production scale?

35. Final Takeaway

Design problems are not primarily about drawing boxes.

They are about making decisions under constraints.

The core mental model is:

Requirements

Constraints

Workload

Architecture

Data

Scale

Failure

Observability

Cost

Trade-offs

The strongest Staff/Principal candidates do not claim that one architecture is universally correct.

They explain:

“Given these requirements and constraints, this is the architecture I would choose, these are the trade-offs I accept, these are the failure modes I would address, and this is how I would evolve the system as scale changes.”

That is the essence of Staff-level design reasoning.


Source Note

The available uploaded material identifies Chapter 20+ as Staff/Principal-oriented design/domain topics, and it explicitly states that senior candidates should expect increased emphasis on system design and architecture.

However, the available extracted source does not provide the complete original Chapter 20 text or its complete numbered problem set. Therefore, this article does not invent source-specific Chapter 20 problems. It uses the source-supported design/interview framework and presents it as Part 20 — Design Problems, with the requested Chapter → Part terminology.