Introduce Types of Concurrency in 3 Minutes
Contents
Concurrency
Parallelism
- One task in multiprocessor, map the task to the multiple nodes and reduce the results into one node after the computation
- Usually is used on the complex computation or large simulation
Asynchronous
Coroutine
- Why we need coroutine?
- If we handle the IO bound through the multiple blocking system call directly, we would increase the frequency of the context switch
- A lightweight mechanism to switch between the IO operation in single thread at programmer perspective
- Avoid the overhead of the context switch caused by OS
- What does coroutine do?
- Hang on the IO bound task with non-blocking system call
- While we waiting on the gathered hang on tasks, we check the status in event loop continuously
Publisher Subscriber
- Use event broker to decouple the publisher and subscriber
Producer Consumer
- The communication between producer and consumer is not restrict in message queue, it also could be just a in-memory buffer to exchange the event message for increasing the performance