320x100
320x100
IPC 통신
: 프로세스 간 데이터를 주고 받는 통신
NodeJS에서의 IPC 통신
: Master와 Worker로 이루어진 Cluster를 통해 프로세스를 만들어내서 수행
// 자식 프로세스 생성
let worker = cluser.fork();
// Server (Master) 측
worker.on('message', (res) => {
console.log(res);
worker.send('you are worker');
});
// Client (Worker) 측
process.on('message', (msg) => {
process.send(msg);
});
: .on() = 첫번째 인자의 시그널을 수신했을 때 콜백 함수 내의 이벤트를 실행
: .send() = 인자를 전송
NodeJS process 관련 메서드 공식문서
: https://nodejs.org/api/process.html
Process | Node.js v18.8.0 Documentation
Process# Source Code: lib/process.js The process object provides information about, and control over, the current Node.js process. import process from 'node:process';const process = require('node:process'); Process events# The process object is an instance
nodejs.org
Refference
[node.js] clustering을 이용한 멀티쓰레드 IPC
IPC 통신이란 프로세스간 통신을 의미한다. 즉, 프로세스간 데이터를 주고 받는 행위를 의미한다. clust...
blog.naver.com
300x250
728x90
'Programming > NodeJS' 카테고리의 다른 글
NodeJS와 메모리 1 - V8 엔진 (0) | 2022.09.12 |
---|---|
NodeJS --inspect (NodeJS 디버깅 / 힙 스냅샷 생성하고 분석 하기) (0) | 2022.09.01 |
NodeJS memory leak 추적하는 방법 (메모리를 낭비하는 함수 추적) (0) | 2022.08.26 |
NodeJS 유닛 테스트 (0) | 2022.08.16 |
NodeJS에서 로깅하기 (0) | 2022.08.13 |