0
0
LLDsystem_design~20 mins

Order state machine in LLD - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Order State Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Identify the correct next state for an order

An order is currently in the "Processing" state. Which state should it transition to next if the payment is successful?

AReturned
BCancelled
CDelivered
DShipped
Attempts:
2 left
💡 Hint

Think about the typical flow of an order after payment is confirmed.

Architecture
intermediate
2:00remaining
Choose the best component to handle order state transitions

In designing an order state machine, which component is best suited to manage state transitions and enforce valid state changes?

AA dedicated State Machine Service that validates and updates order states
BA UI component that changes states based on user clicks
CA database trigger that automatically changes states
DA logging service that records state changes
Attempts:
2 left
💡 Hint

Consider where the logic for valid state changes should reside for consistency and control.

scaling
advanced
2:30remaining
Scaling order state machine for high traffic

Your order system handles thousands of orders per second. Which approach best ensures the order state machine scales without losing consistency?

AHandle state transitions only on the client side to reduce server load
BUse a distributed state machine with event sourcing and a message queue
CUse local in-memory state machines on each server without synchronization
DStore all states in a single database table with frequent polling
Attempts:
2 left
💡 Hint

Think about how to keep state consistent across multiple servers and handle high throughput.

tradeoff
advanced
2:00remaining
Tradeoff between strict and eventual consistency in order states

Choosing between strict consistency and eventual consistency for order state updates impacts system design. Which statement best describes a tradeoff?

AStrict consistency allows faster processing but risks stale data
BEventual consistency guarantees immediate state accuracy but increases latency
CStrict consistency ensures immediate state accuracy but may reduce system availability under load
DEventual consistency prevents any state conflicts by locking all orders
Attempts:
2 left
💡 Hint

Consider how consistency models affect availability and latency.

estimation
expert
3:00remaining
Estimate storage needed for order state history

Your system processes 1 million orders daily. Each order has on average 5 state transitions. Each state transition record requires 200 bytes. Estimate the storage needed to keep 30 days of order state history.

A30 GB
B3 GB
C300 GB
D60 GB
Attempts:
2 left
💡 Hint

Calculate total records and multiply by size per record, then convert bytes to GB.