Concurrency
A story of recruitment

Basic terms
Concurrency
In computer science, concurrency is the ability of different parts or units of a program, algorithm, or problem to be executed out-of-order or in partial order, without affecting the final outcome.
Parallelism
Parallel computing is a type of computation in which many calculations or processes are carried out simultaneously.
Race condition
A race condition or race hazard is the condition of an electronics, software, or other system where the system's substantive behavior is dependent on the sequence or timing of other uncontrollable events. It becomes a bug when one or more of the possible behaviors is undesirable.
Race condition

Race condition

Contention
In computer science, resource contention is a conflict over access to a shared resource such as random access memory, disk storage, cache memory, internal buses or external network devices. A resource experiencing ongoing contention can be described as oversubscribed.
Lock
In computer science, a lock or mutex (from mutual exclusion) is a synchronization primitive: a mechanism that enforces limits on access to a resource when there are many threads of execution. A lock is designed to enforce a mutual exclusion concurrency control policy, and with a variety of possible methods there exists multiple unique implementations for different applications.
Database Lock
Record locking is the technique of preventing simultaneous access to data in a database, to prevent inconsistent results.
Deadlock
In concurrent computing, deadlock is any situation in which no member of some group of entities can proceed because each waits for another member, including itself, to take action, such as sending a message or, more commonly, releasing a lock.
Deadlock

Starvation
In computer science, resource starvation is a problem encountered in concurrent computing where a process is perpetually denied necessary resources to process its work.
Examples
- tickets
- product availability
- money transfer
- counters
- collections
- ?

Let's lock!
Optimistic
When a user wants to update a record, the application determines whether another user has changed the record since it was last read.
Pessimistic
a user who reads a record with the intention of updating it places an exclusive lock on the record to prevent other users from manipulating it
Pessimistic

Optimistic

Advisory lock

Redis lock


Race condition



Deadlock


Starvation




Alternatives to lock

Read more
Questions?
@jandudulski@ruby.social
Concurrency
By Jan Dudulski
Concurrency
- 137
 
   
   
  