Node.js – Day 5/30 Blocking vs Non-Blocking I/O One of the most important ideas in Node.js is the difference between blocking and non-blocking operations Blocking I/O: o) The program waits until a task completes o) The main thread is blocked o) Other requests must wait Non-Blocking I/O (Node.js default): o) The task is started and delegated o) The main thread continues processing other requests o) Results are handled asynchronously when ready Why this matters in Node.js: o) Prevents the event loop from getting stuck o) Allows better concurrency with fewer resources o) Improves performance for I/O-heavy applications This concept explains why Node.js performs well for APIs, file handling, and real-time services. #NodeJS #BackendDevelopment #JavaScript #NonBlockingIO #LearningInPublic
Blocking vs Non-Blocking I/O in Node.js
More Relevant Posts
-
Node.js – Day 6/30 What is the Event Loop? The Event Loop is the core mechanism that allows Node.js to handle multiple operations without blocking the main thread At a high level, this is what happens: o) Node.js executes synchronous code first o) Async operations (I/O, timers, promises) are offloaded o) Once completed, their callbacks are queued o) The Event Loop continuously checks these queues and executes callbacks when the call stack is free This is how Node.js: o) Remains single-threaded o) Handles thousands of concurrent requests o) Stays fast for I/O-heavy applications Understanding the Event Loop helped me clearly connect async/await, non-blocking I/O, and performance behavior in Node.js. #NodeJS #BackendDevelopment #EventLoop #JavaScript #LearningInPublic
To view or add a comment, sign in
-
Bun vs Node.js 👀 The JavaScript performance conversation is changing. ⚡ ~98,000 requests/sec vs Node’s ~36,000 🧠 ~66% lower peak memory usage in comparable workloads 📦 Up to 30× faster package installs with global caching + native hardlinks 🟦 Native TypeScript & JSX support out of the box 🧰 Runtime + bundler + package manager in one fast binary Node.js is still rock-solid, battle-tested, and everywhere. But Bun is clearly pushing the limits on speed, DX, and simplicity. Benchmarks vary by workload, but the trend is hard to ignore: Bun is fast — especially for modern backends and tooling-heavy projects. Curious to hear from the community: Are you experimenting with Bun already, planning a migration, or sticking with Node for now? ⚡ Team Bun 🛤️ Team Node #BunJS #NodeJS #JavaScript #Backend #WebDevelopment #TypeScript #Performance #DevTools
To view or add a comment, sign in
-
-
Node.js – Day 12/30 process & Environment Variables In Node.js, the process object provides information and control over the current running application. One of its most important uses is handling environment variables, which helps keep configuration separate from code. Why environment variables matter: o) Keep sensitive data (API keys, DB URLs) out of the codebase o) Allow different configs for development, staging, and production o) Make applications easier to deploy and maintain Common usage: o) process.env to access environment variables o) process.exit() to exit the process when needed o) process.argv to read command-line arguments Using environment variables is a simple habit that leads to more secure and flexible backend applications. #NodeJS #JavaScript #BackendDevelopment #LearningInPublic #WebDevelopment
To view or add a comment, sign in
-
Node.js – Day 7/30 Call Stack, Callback Queue & Microtask Queue To really understand how async code works in Node.js, it’s important to know what happens behind the scenes. Call Stack o) Executes synchronous code o) Runs one function at a time o) Must be empty before async callbacks are executed Callback (Task) Queue o) Holds callbacks from async operations like setTimeout and I/O o) These are executed after the call stack is clear Microtask Queue o) Holds promise callbacks (.then, catch, finally) o) Has higher priority than the callback queue Execution order: 1). Call Stack 2). Microtask Queue 3). Callback Queue This explains why promise-based code often runs before timers. #NodeJS #EventLoop #JavaScript #BackendDevelopment #LearningInPublic
To view or add a comment, sign in
-
Day 6 – Node.js Understanding async/await Today’s topic: async/await in Node.js. async/await is built on top of Promises and makes asynchronous code easier to read and maintain. Instead of using .then() and .catch(), we can write asynchronous code that looks like synchronous code. Key points: • async makes a function return a Promise • await pauses execution until the Promise resolves • Error handling is done using try/catch • Avoids callback nesting async/await improves readability and structure in real-world backend applications. Next: Node.js Core Modules (fs, path, os) #NodeJS #BackendDevelopment #JavaScript #AsyncProgramming #SoftwareEngineering
To view or add a comment, sign in
-
-
🧠 Most Developers Use Node.js… But Don’t Understand This 😮 Node.js is single-threaded, yet it handles thousands of requests. How? 👉 Event Loop + libuv 🔁 Flow: Timers → Pending → Poll → Check → Close ⚡ Between every phase: ✔ process.nextTick() (highest priority) ✔ Promises 💥 The real game-changer: Poll Phase Handles all I/O operations (DB, APIs, Files) 🚨 Overusing process.nextTick() can block the loop! Master this → Become a better backend developer 🚀 #NodeJS #EventLoop #JavaScript #BackendDevelopment #Coding#LearningInPublic
To view or add a comment, sign in
-
-
Most beginners struggle with Node.js not because it’s hard, but because core concepts are misunderstood or skipped. Async flow, request/response cycles, middleware, and error handling form the foundation of Node — and everything breaks without them. Understanding why these concepts exist makes Node feel logical instead of confusing. Next post: Before building APIs in Node, understand this #nodejs #javascript #webdevelopment #learninginpublic #beginners #backend
To view or add a comment, sign in
-
This Express bug wasted more time than I want to admit ⚠️ Everything looked correct. The API was working. Then randomly I got: “Cannot set headers after they are sent to the client” The reason was simple: I sent a response… but my function didn’t stop. So later in the code, another res.json() ran. Now I do this every time: if (!user) { return res.status(404).json({ message: "User not found" }); } That return is not “optional”. It’s basically telling Express: “Done. Don’t touch this request anymore.” If you build APIs, this tiny habit saves you from a lot of silent chaos. #Nodejs #Expressjs #BackendDevelopment #JavaScript #WebDevelopment
To view or add a comment, sign in
-
Node.js – Day 9/30 The path Module When working with files in Node.js, hardcoding file paths can easily break across different operating systems. The path module helps handle file paths in a safe and consistent way. What the path module solves: o) Different path separators (/ vs \) o) Absolute vs relative paths o) Cleaner and more readable file handling Common usage: o) path.join() – safely joins paths o) path.resolve() – gets absolute paths o) __dirname with path for reliable file access Using the path module avoids environment-specific bugs and makes backend code more portable. #NodeJS #BackendDevelopment #JavaScript #FileHandling #LearningInPublic
To view or add a comment, sign in
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development