Bird
Raised Fist0
HLDsystem_design~20 mins

Shopping cart and session management in HLD - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Shopping Cart & Session Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Architecture
intermediate
2:00remaining
Designing a scalable shopping cart system

You are tasked with designing a shopping cart system that supports millions of users simultaneously. Which architectural choice best ensures scalability and low latency?

AStore shopping cart data in a centralized relational database accessed synchronously for every user action.
BUse client-side cookies to store the entire shopping cart data to avoid server load.
CImplement a distributed in-memory cache (like Redis) to store shopping cart sessions with periodic persistence to a database.
DSave shopping cart data only after checkout to reduce storage needs during browsing.
Attempts:
2 left
💡 Hint

Think about fast access and handling many users without bottlenecks.

🧠 Conceptual
intermediate
2:00remaining
Session management strategies for shopping carts

Which session management approach best balances security and user experience for a shopping cart on a web application?

AStore session IDs in secure, HttpOnly cookies with a short expiration time and renew on activity.
BUse URL rewriting to pass session IDs in every link to track user sessions.
CKeep session data entirely on the client side without any server validation.
DUse long-lived sessions without expiration to avoid forcing users to log in repeatedly.
Attempts:
2 left
💡 Hint

Consider security risks like session hijacking and user convenience.

scaling
advanced
2:00remaining
Handling session data in a load-balanced environment

In a load-balanced web application with multiple servers, what is the best way to manage shopping cart sessions to ensure consistency and availability?

AKeep session data on the client side and send it with every request to avoid server-side session management.
BStore session data only in the database and query it on every request to ensure consistency.
CUse sticky sessions so that each user always connects to the same server storing their session data locally.
DStore session data in a shared distributed cache accessible by all servers to avoid dependency on any single server.
Attempts:
2 left
💡 Hint

Consider fault tolerance and server failures in your design.

tradeoff
advanced
2:00remaining
Tradeoffs in session persistence frequency

What is the main tradeoff when choosing how frequently to persist shopping cart session data from cache to permanent storage?

APersisting too frequently increases database load but reduces data loss risk; persisting too infrequently reduces load but risks losing recent cart changes.
BPersisting frequently reduces database load but increases network latency; infrequent persistence improves latency but increases storage costs.
CFrequent persistence improves user experience but causes session data fragmentation; infrequent persistence consolidates data but slows checkout.
DPersistence frequency does not affect system performance or data safety significantly.
Attempts:
2 left
💡 Hint

Think about balancing system load and data durability.

estimation
expert
3:00remaining
Estimating storage requirements for shopping cart sessions

Your e-commerce platform expects 10 million active users daily. Each shopping cart session averages 5 items, with each item record requiring 200 bytes. Sessions are stored in cache for 24 hours. Estimate the approximate memory needed to store all active shopping cart sessions in the cache.

AApproximately 50 GB
BApproximately 100 GB
CApproximately 1 TB
DApproximately 10 GB
Attempts:
2 left
💡 Hint

Calculate total bytes: users × items per cart × bytes per item, then convert to GB.