Tuesday, May 31, 2016

Concurrency vs. parallelism

    I like to present some examples when describing any technical aspect. That's make it easier to understand. Today I am going to describe concurrency and parallelism - the differences between them and the similarities they share.

Let's assume that our unit of work that is going to be completed is to handle the customers. We want to sell them the tickets to the cinema. We have the following options to do that:

1. Organize people in a one queue and expose one ticket office.
That's a pretty straightforward approach. It will do the trick but the performance is poor.

2. Organize people in two or more queues and expose one ticket office.
This approach is a little bit less effective than the first one. If we have multiple queues then there may occur some arguing (context switching) between the customers about the order if they do not pay enough attention to their turn.

3. Organize people in two or more queues and expose two or more ticket offices. Each queue is dedicated to one particular ticket office.
This approach performs better than the first one and the second one. It is still suboptimal. What if the first ticket office performs better than the second one? The queue handled by the second ticket office will wait longer to buy the tickets - people cannot change the ticket office once chosen.

4. Organize people in one queue and expose two or more ticket offices.
This solution provides the best performance. All ticket offices are fully utilized.

That's it:


No more, no less. My description is technology agnostic but if you want to back it up then you can check Toptal blog entry - click.

Have a nice day!

No comments :

Post a Comment