본문 바로가기
장바구니0 로그인
+1000

Node.js Event Loop: Understanding How Async Works

페이지 정보

작성자 Florencia 작성일 26-07-31 02:49 조회 2 댓글 0

본문


Node.js event loop enables non-blocking I/O despite single-threaded JavaScript. The event loop phases include timers, pending callbacks, idle/prepare, poll, check, close. Timers phase executes setTimeout and setInterval callbacks. Pending callbacks phase handles I/O callbacks deferred to next iteration. Poll phase retrieves new I/O events and executes their callbacks. Check phase runs setImmediate callbacks. Close phase executes close like socket.on('close'). process.nextTick callbacks run between phases, not within phases. Microtasks (Promise callbacks) run after each phase. Blocking the event loop with CPU-intensive operations degrades performance. Worker threads handle CPU-intensive tasks without blocking. Understanding event loop phases helps debug async issues. setImmediate vs setTimeout(fn, 0): setImmediate runs in check phase, setTimeout in timers phase. Unref methods prevent timers from keeping process alive. Error handling requires proper promise rejection handling. The event loop makes Node.js efficient for I/O-bound applications. libuv library implements the event loop in C++. Node.js event loop differs from browser event loop. Mastering the event loop is essential for Node.js performance optimization.

댓글목록 0

등록된 댓글이 없습니다.

태인도김부각 정보

CALL CENTER

061-791-5400

tindobk@naver.com

문의게시판

BANK INFO

예금주 : 태인도부각 협동조합

공지사항

  • 게시물이 없습니다.

COMPANY

태인도부각 협동조합 주소 : 전남 광양시 도촌안길 12-1
사업자등록번호 : 899-82-00478 대표 : 김정숙 전화 : 061-791-5400 팩스 : 061-791-6300 통신판매업신고번호 : 2023-전남광양-0169호 개인정보 보호책임자 : 김정숙 부가통신사업신고번호 : 12345호

Copyright © 2019 태인도부각 협동조합. All Rights Reserved.

상단으로