A backend spends most of its time waiting: for the database, for a payment provider, for an SMS service. If it simply stopped and waited each time, one slow request would hold up everyone else. Asynchronous code lets a server start a task, deal with other customers while it waits, and come back when the answer arrives. Some of the remote adverts we read mention asynchronous processing by name.
The idea, with a chop bar
Picture Amina's chop bar. A good server (the person) takes Fuseini's order, passes it to the kitchen and goes to take the next order. She does not stand at the kitchen door until the food is ready. When the food is ready, she brings it out. That is asynchronous work.
Promises, async and await
In JavaScript, a task that finishes later returns a promise. The await keyword pauses only the current function until the promise settles, while the server keeps handling other requests.
async function getOrder(id) {
const order = await db.findOrder(id);
return order;
}Python has the same idea with async def and await.