Manage a Series of Tasks
Learn to use the async_stream function to manage a series of tasks.
Pressure on the system
Let’s imagine we have one million users, and want to send an email to all of them. We can use Enum.map/2
and Task.async/1
as before.
Start one million processes
Starting one million processes will put sudden pressure on our system resources. It can degrade the system’s performance and potentially make other services unresponsive. Our email service provider will not be happy either, since we also put a lot of pressure on their email infrastructure.
Start processes one by one
If we send emails one by one, it will be slow and inefficient. It seems that we are at a crossroads, and whichever way we take, we end up in peril. We don’t want to choose between performance and reliability. We want ...