Chapter 3. Your Toolbox to Reactive
Now that you understand what a reactive system is and what it sets out to achieve, how do you go about implementing it? Within this chapter, we delve into tools and implementation patterns that you can use to transform your application into a reactive system.
Getting Responsive: Concurrency and Parallelism
If it’s your goal to build responsive applications, the first order of business is making sure you’re getting the most out of your hardware. We do this through concurrency and parallelism. Even though these concepts sound like the same thing, there’s an important distinction in the context of computer systems. For the moment, let’s just focus on these concepts in the context of a single CPU.
Two tasks are said to be running concurrently when they begin, run, and finish within the same time window. Parallelism is when two (or more) tasks are running at the same time. Figure 3-1 illustrates the difference between concurrency and parallelism.
Say you’ve been told to dig two holes and make progress on them both along the way. To accomplish this, you take a shovelful from hole A, then one from hole B, another from hole A, and so on. Every time the boss comes back to check on you, they’d see both holes getting deeper; you’re working on them concurrently even though you obviously can scoop a shovelful from only one hole at a time.
Get Reactive Systems Explained now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.