System Overview - Concurrency considerations
This system manages multiple tasks running at the same time without interfering with each other. It ensures data stays correct and the system stays fast even when many users or processes work together.
Jump into concepts and practice - no test required
This system manages multiple tasks running at the same time without interfering with each other. It ensures data stays correct and the system stays fast even when many users or processes work together.
User
|
v
Load Balancer
|
v
API Gateway
|
v
+-------------------+ +----------------+
| Worker Service |<----->| Message Queue |
+-------------------+ +----------------+
| ^ |
v | v
+-------------------+ +----------------+
| Shared Database |<----->| Distributed Lock|
+-------------------+ +----------------+
^
|
Cachelock.acquire() is used to obtain the lock before accessing shared data.Thread 1: temp = counter
temp = temp + 1
counter = temp
Thread 2: temp = counter
temp = temp + 1
counter = temp
What is the possible final value of counter if it starts at 0?lock.acquire() shared_data.append(1) # Missing lock.release()