Bird
0
0
LLDsystem_design~20 mins

Concurrency considerations in LLD - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Concurrency Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding race conditions in concurrent systems

In a system where multiple threads update a shared counter without synchronization, what is the most likely outcome?

AThe counter always increments correctly without any lost updates.
BThe system throws a runtime error when multiple threads access the counter.
CThe counter may have incorrect values due to lost updates caused by race conditions.
DThe counter resets to zero automatically after each update.
Attempts:
2 left
💡 Hint

Think about what happens when two threads try to update the same value at the same time.

Architecture
intermediate
2:00remaining
Choosing synchronization mechanisms for shared resources

You have a shared resource accessed by multiple threads. Which synchronization mechanism is best to ensure only one thread accesses it at a time?

AUse a mutex (lock) to allow only one thread to access the resource at a time.
BUse a thread pool to manage multiple threads accessing the resource simultaneously.
CUse a queue to store all requests and process them in parallel without locks.
DUse a timer to delay access to the resource by each thread.
Attempts:
2 left
💡 Hint

Think about how to prevent multiple threads from entering a critical section simultaneously.

scaling
advanced
2:00remaining
Scaling a system with concurrent database writes

You design a system where many users write data concurrently to a database. What is a common strategy to handle high write loads without causing contention?

AUse a single-threaded application server to queue all writes sequentially.
BUse a single database server with a global lock to serialize all writes.
CDisable transactions to speed up writes and avoid locking overhead.
DUse database sharding to split data across multiple servers, reducing contention on any single server.
Attempts:
2 left
💡 Hint

Think about dividing the workload to avoid bottlenecks on one server.

tradeoff
advanced
2:00remaining
Tradeoffs between optimistic and pessimistic concurrency control

Which statement best describes a tradeoff between optimistic and pessimistic concurrency control?

AOptimistic control is slower because it always locks; pessimistic control is faster because it assumes no conflicts.
BOptimistic control assumes conflicts are rare and retries on conflict; pessimistic control locks resources to prevent conflicts but can reduce concurrency.
COptimistic control locks resources before access; pessimistic control never uses locks and always retries.
DBoth optimistic and pessimistic control always lock resources but differ in lock duration.
Attempts:
2 left
💡 Hint

Consider how each method handles conflicts and resource locking.

estimation
expert
2:00remaining
Estimating throughput for a concurrent system with locks

A system has 10 threads trying to access a shared resource protected by a lock. Each thread holds the lock for 5 milliseconds per operation. Assuming no other delays, what is the maximum number of operations the system can perform per second?

A200 operations per second
B100 operations per second
C500 operations per second
D50 operations per second
Attempts:
2 left
💡 Hint

Calculate how many operations fit in one second considering the lock is held exclusively.