-
-
Notifications
You must be signed in to change notification settings - Fork 27.3k
Description
Leader/Followers pattern is also a concurrency pattern. This pattern behaves like a taxi stand where one of the threads acts as leader thread which listens for event from event sources, de-multiplexes, dispatches and handles the request. It promotes the follower to be the new leader. When processing completes the thread joins the followers queue, if there are no followers then it becomes the leader and cycle repeats again.
This pattern can be used in lieu of Half-Sync/Half-Async that we described in #109
In Half-Sync/Half-Async there is a dedicated I/O thread which listens for incoming requests and then dispatches them to workers which is not good for performance due to context switching and cache coherency problems. Cache coherency problems occur because memory for request is allocated in I/O thread and then is accessed in worker threads.
There is a great reference for this http://www.cs.wustl.edu/~schmidt/PDF/lf.pdf