DEV Community

Cover image for Why async programming exists
Khashayar Nourian
Khashayar Nourian

Posted on Originally published at knourian.ir on

Why async programming exists

A slow HTTP request is not the same thing as a slow calculation. When an application waits for a database, file system, or remote service, most of that time is spent waiting on work outside the process.

Async lets the application yield during that wait and return to work that is ready. A UI can stay responsive, and a server can use its available capacity for other requests. The external operation still takes as long as it takes; async does not make the database or API faster.

I use async for meaningful I/O waits, not for a short calculation that already has its data in memory.

Top comments (0)