| Users | Operations per Second | Data Size | System Changes |
|---|---|---|---|
| 100 users | ~50 CRUD ops/sec | Small (few hundred books) | Single server, simple DB |
| 10,000 users | ~5,000 CRUD ops/sec | Medium (tens of thousands books) | DB indexing, caching, load balancing |
| 1,000,000 users | ~500,000 CRUD ops/sec | Large (millions of books and records) | Sharding DB, horizontal scaling, CDN for static content |
| 100,000,000 users | ~50,000,000 CRUD ops/sec | Very large (global scale) | Multi-region clusters, advanced sharding, event-driven architecture |
Why library management tests CRUD design in LLD - Scalability Evidence
Start learning this pattern below
Jump into concepts and practice - no test required
At small to medium scale, the database is the first bottleneck because CRUD operations require consistent reads and writes. As users and data grow, the database struggles to handle concurrent requests and data volume.
- Read Replicas: Offload read operations to replicas to reduce DB load.
- Caching: Use in-memory caches (e.g., Redis) for frequent reads like book details.
- Horizontal Scaling: Add more application servers behind load balancers to handle more users.
- Database Sharding: Split data by library branches or book categories to distribute load.
- CDN: Serve static content like book images or PDFs closer to users.
- At 10,000 users: ~5,000 CRUD ops/sec, requiring a DB that can handle 5k QPS.
- Storage: Tens of GBs for book data and user records.
- Bandwidth: Moderate, mostly for user requests and book metadata.
- At 1M users: ~500k ops/sec, needing sharded DB and multiple app servers.
- Bandwidth grows significantly, requiring network upgrades.
Start by explaining CRUD basics and their importance in library management. Discuss expected load and data growth. Identify the first bottleneck (usually DB). Propose scaling solutions step-by-step, focusing on read/write separation, caching, and sharding. Use real numbers to show understanding.
Your database handles 1000 QPS. Traffic grows 10x to 10,000 QPS. What do you do first?
Answer: Add read replicas and implement caching to reduce DB load before considering sharding or adding more app servers.
Practice
Solution
Step 1: Understand CRUD in library context
CRUD stands for Create, Read, Update, Delete, which are basic operations to manage library data like books and members.Step 2: Connect CRUD testing to system reliability
Testing CRUD ensures these operations work correctly, keeping data accurate and reliable for users.Final Answer:
To ensure books can be added, viewed, updated, and deleted correctly -> Option AQuick Check:
CRUD testing = data accuracy [OK]
- Confusing CRUD with UI design
- Thinking CRUD affects user count directly
- Ignoring data accuracy importance
Solution
Step 1: Recall CRUD operation definitions
Create adds new data, Read views data, Update changes existing data, Delete removes data.Step 2: Match operation to updating book info
Changing a book's details means modifying existing data, which is Update.Final Answer:
Update -> Option CQuick Check:
Update = modify data [OK]
- Choosing Create instead of Update
- Confusing Read with Update
- Selecting Delete by mistake
if book_id exists:
delete book
return 'Deleted'
else:
return 'Not Found'
What will be the output if book_id does not exist?Solution
Step 1: Analyze condition for book_id existence
The code checks if book_id exists; if not, it goes to else branch.Step 2: Determine output when book_id missing
Else branch returns 'Not Found' when book_id does not exist.Final Answer:
'Not Found' -> Option BQuick Check:
Missing book_id returns 'Not Found' [OK]
- Assuming deletion happens without book_id
- Expecting an error instead of 'Not Found'
- Ignoring else branch output
Solution
Step 1: Identify update function role
Update changes existing data and must save or commit changes to persist them.Step 2: Check common update failure cause
If changes are not saved or committed, updates won't reflect in the system.Final Answer:
The update method is missing a save or commit step -> Option AQuick Check:
Missing save causes update failure [OK]
- Confusing update with delete or create
- Ignoring save/commit step importance
- Blaming read method for update issues
Solution
Step 1: Understand concurrency issues in CRUD
When multiple users update data simultaneously, conflicts can cause data loss or corruption.Step 2: Identify solution for safe concurrent updates
Optimistic locking detects conflicts by checking if data changed before saving, preventing overwrites.Final Answer:
Implement optimistic locking to detect conflicting updates -> Option DQuick Check:
Optimistic locking = safe concurrent updates [OK]
- Ignoring concurrency control
- Disabling updates reduces usability
- Using read-only mode prevents changes
