Asynchronous (async) programming is a way of writing code so that a slow operation, such as an HTTP request, file read or database query, runs in the background while the program keeps doing other work. The result arrives later through a callback, a promise or an await expression.
Why it matters
Servers and user interfaces spend most of their time waiting. If every wait blocks, a web server handles one request at a time and an app freezes. Async code lets one thread juggle thousands of waiting operations, which is how Node.js and many modern Python servers scale.
Example
async function check(urls) {
const results = await Promise.all(
urls.map(u => fetch(u).then(r => r.status))
);
return results; // all requests ran at the same time
}
Fetching three URLs sequentially might take 900 ms if each takes 300 ms; running them concurrently takes about 300 ms.
Common mistakes
- Forgetting
await, so you work with an unfinished promise instead of its result. - Running a CPU-heavy loop inside async code, which blocks everything else.
- Not handling errors from rejected promises, which then fail silently.
Related
Get notified when this term updates
Plus occasional practical tips on uptime and monitoring, nothing else. Unsubscribe anytime.
यह पेज सामान्य जानकारी है, जिसे हमारी संपादकीय टीम ने लिखा है और दस्तावेज़ीकरण बदलने पर अपडेट किया जाता है। सर्वर और प्रदाता अलग-अलग होते हैं, इसलिए बदलाव पहले सुरक्षित तरीके से जाँचें। देखें: संपादकीय नीति और अस्वीकरण.