惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

宝玉的分享
宝玉的分享
Recent Commits to openclaw:main
Recent Commits to openclaw:main
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tailwind CSS Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
罗磊的独立博客
V
Visual Studio Blog
爱范儿
爱范儿
H
Help Net Security
J
Java Code Geeks
I
InfoQ
Recent Announcements
Recent Announcements
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Recorded Future
Recorded Future
Jina AI
Jina AI
Microsoft Security Blog
Microsoft Security Blog
WordPress大学
WordPress大学
GbyAI
GbyAI
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Y
Y Combinator Blog
Google DeepMind News
Google DeepMind News
Scott Helme
Scott Helme
S
SegmentFault 最新的问题
S
Securelist
L
LINUX DO - 热门话题
Cyberwarzone
Cyberwarzone
C
Cisco Blogs
Simon Willison's Weblog
Simon Willison's Weblog
G
Google Developers Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 叶小钗
T
The Blog of Author Tim Ferriss
博客园_首页
B
Blog
F
Fortinet All Blogs
AWS News Blog
AWS News Blog
V
Vulnerabilities – Threatpost
S
Secure Thoughts
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Forbes - Security
Forbes - Security
S
Security @ Cisco Blogs
T
Threat Research - Cisco Blogs
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
S
Schneier on Security
Project Zero
Project Zero
Martin Fowler
Martin Fowler
C
Cybersecurity and Infrastructure Security Agency CISA
N
Netflix TechBlog - Medium
N
News and Events Feed by Topic

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
How NodeJS Handles Multiple Requests with a Single Thread
Ritam Saha · 2026-05-08 · via DEV Community

Introduction

NodeJS has revolutionized server-side development by proving that a single-threaded runtime can handle thousands (or even tens of thousands) of concurrent requests efficiently. This often surprises developers coming from traditional multi-threaded environments like Java or PHP, where each request typically gets its own thread.

But how does NodeJS achieve this without blocking or crashing under load? The secret lies in its event-driven, non-blocking I/O architecture, powered by the event loop and smart delegation of work using thread pool with the help of Event Queue. It emphasizes on concurrency (handling many things at once) rather than parallelism (doing many things simultaneously on multiple CPU cores).

If you've read my previous articles — A Gentle Introduction to the Foundation of Node.js Architecture, Deep Dive into Node.js Architecture and Internal Workings, and What is Node.js: JavaScript on the Server Explained — you'll already have a solid foundation. This post builds on those by focusing specifically on request handling at scale.

Imagine a busy restaurant. In a traditional multi-threaded setup, each customer order gets its own dedicated chef. With 100 customers, you need 100 chefs — expensive in resources (memory & CPU overhead for thread management). In NodeJS, there's one highly efficient chef (the main thread) who takes orders quickly, delegates cooking (I/O tasks) to the kitchen staff (libuv thread pool), and moves on to the next customer without waiting. When the kitchen finishes an order, the chef is notified and serves it promptly. This model shines for I/O-heavy workloads common in web apps.

Let's break it down step by step.

The Single-Threaded Nature of NodeJS

NodeJS runs JavaScript on a single main thread for your application code. When you execute node app.js, a single process starts with one primary execution thread managed by the V8 engine.

Thread vs Process:

  • A process is like a full kitchen with its own resources (memory space, file handles).
  • A thread is a worker inside that kitchen sharing the same resources.

Creating new processes is heavier than threads, but threads may introduce complexities like synchronization, race conditions, and deadlocks.

NodeJS chooses single-threaded JavaScript execution to avoid these pitfalls. JavaScript was designed as a single-threaded scripting language for browsers focusing for front-end development; NodeJS extends this model. Many people believe that NodeJS is not single-thread because: NodeJS built on top of V8 Engine and LibUV; LibUV (the C library underneath NodeJS) has the thread pool which contains some worker-threads (by default it provides a default thread pool of 4 worker threads (configurable via UV_THREADPOOL_SIZE)) that NodeJS can use, so basically, NodeJS has more than 1 thread, therefore, it’s not true that NodeJS is single-threaded. But in this argument, I’m on the side of people think that NodeJS is single-threaded. Let me explain why, it's true that NodeJS can take advantage of using threads provided by LibUV. But we need to keep in mind that, Node application code runs on one thread i.e, main thread. The libuv thread pool is only used for specific offloadable operations and does not allow parallel execution of your JavaScript code.

The Event Loop: The Heart of Concurrency

The event loop is what makes non-blocking I/O possible. It's a continuous loop in libuv that checks for and processes events/callbacks.

How it enables concurrency: When a request arrives (e.g., via HTTP server), NodeJS registers the necessary callback and continues. Most operations in NodeJS are asynchronous and non-blocking by default.

If the operation is non-blocking I/O (network requests, database queries using async drivers, modern file operations, etc.), libuv registers the operation with the operating system (using epoll, kqueue, or IOCP) and immediately returns control to the event loop. The main thread is never blocked.

Only specific operations (DNS lookups, some filesystem operations, crypto functions, and any synchronous code) are offloaded to main thread.

Important: True CPU-intensive work or synchronous code (e.g. heavy loops, JSON parsing of huge objects, image processing) runs on the main thread and blocks the event loop. This is why NodeJS is not ideal for CPU-bound tasks unless you use Worker Threads.

Key phases of the event loop (simplified):

  • Timers: Execute setTimeout and setInterval.
  • Poll: Retrieve completed I/O events (most important phase for web servers).
  • Check: Execute setImmediate callbacks.
  • Close Callbacks: Handle closed connections.

This is concurrency, not parallelism. The single thread interleaves work efficiently by never idly waiting on I/O.

Delegating Tasks to Background Workers

Not everything can run on the main thread without blocking:

  • Non-blocking I/O (most network and database operations): Handled directly by the OS kernel. The main thread registers interest and moves on. When the operation completes, the callback is queued for the event loop.

  • Blocking operations (DNS lookups via dns.lookup(), some fs functions without Sync, crypto functions, zlib): These are automatically offloaded by libuv to its worker thread pool (default size: 4).

  • Synchronous / CPU-heavy JavaScript code: Runs directly on the main thread and blocks the event loop. Avoid this in production code.

Key Point: NodeJS is single-threaded for JavaScript execution. The thread pool only helps with certain I/O-bound blocking tasks. CPU-bound work must be moved off the main thread using worker_threads or external services.

Event Loop + Worker Thread Interaction Flow

CPU task must be executed in the main thread of NodeJS, while I/O task can be executed in threads within the thread pool provided by LibUV. That’s the reason why NodeJS is not suitable for application with CPU intensive tasks. In those cases, use Worker Threads (modern Node.js), separate microservices, or queues.

Handling Multiple Client Requests

Here's the flow for thousands of concurrent requests:

  1. Client requests hit the Node.js HTTP server.
  2. They enter the event queue.
  3. The event loop picks them up one by one (quickly).
  4. For each: Register async operations (DB query, etc.) and move on.
  5. OS or thread pool handles the actual work in the background.
  6. When ready, callbacks are queued.
  7. Event loop executes callbacks, sending responses.

A slow request (e.g., a heavy DB query) doesn't block others because the main thread isn't waiting — it's processing other events. This interleaving is why Node.js excels at high concurrency.

Concurrent requests

Why Node.js Scales Well

  • Low memory overhead: No per-request thread stack.
  • Efficient CPU use for I/O-bound apps (most web apps).
  • Horizontal scaling: Use Node's cluster module to spawn multiple processes (one per CPU core) behind a load balancer.
  • Vertical scaling: Increase thread pool size if needed, but usually unnecessary.

Real-world examples: Netflix, LinkedIn, and PayPal handle massive traffic with Node.js by keeping operations async and non-blocking.

Conclusion

NodeJS's single-threaded event loop isn't a limitation — it's a deliberate, elegant design for the real world of network applications where waiting on I/O dominates. By delegating work, avoiding unnecessary thread overhead, and interleaving tasks efficiently, it achieves impressive concurrency and scalability with simplicity.

The chef doesn't cook every dish personally; they orchestrate. Similarly, your NodeJS main thread orchestrates thousands of requests without breaking a sweat.

Understanding this architecture (V8 + libuv + event queuevent loop + thread pool) empowers you to write better, more performant code — avoiding blocking calls and leveraging async patterns properly.

If you're building with NodeJS, focus on keeping the event loop unblocked. Use promises, async/await, and proper drivers. For CPU-heavy work, explore modern features like Worker Threads or offload to other services.

What are your experiences with NodeJS at scale? Have you hit event loop blocking issues? Share in the comments — I'd love to discuss or reference in future posts. Keep building!

Further Reading (My Series):