В этом докладе, я хочу сравнить кластеризацию HTTP, TCP, UDP на процессах и потоках в NodeJS. Оценить производительность и использование ресурсов при разных подходах.
Python Notes for mca i year students osmania university.docx
JS Fest 2019/Autumn. Виталий Кухар. Сравнение кластеризации HTTP, TCP и UDP на процессах и потоках в NodeJS
1. Comparing Node.js
processes and threads
for clustering
HTTP, TCP, and UDP
Vitalii Kukhar
Full Stack Software Engineer at Metarhia
8-9 NOVEMBER ‘19 KIEV, UKRAINEPROFESSIONAL JS CONFERENCE
3. Asynchronous I/O
● Rack: a Ruby Webserver Interface
● NGINX uses an asynchronous, event-driven approach
● an asynchronous event-driven JavaScript runtime
● JavaScript + asynchronous IO + HTTP server stuff
4. Performing CPU-intensive operations
● long-running JavaScript functions
● unresponsive page
● limit to perform new asynchronous I / O tasks
● bad user experience
5. Inter process communication (IPC)
● child_process module
● cluster module
● net module (tcp client-server)
● BroadcastChannel API, Web Storage API, etc.
● no shared memory
6. The worker_threads module
● enables to use threads
● execute JavaScript in parallel
● useful for performing CPU-intensive operations
● shared memory
8. What the worker_threads module gave us(before)?
● one process
● one thread
● one event loop
● one JS Engine instance
● one NodeJS instance process
thread
V8 libuv
NodeJS
JavaScript
9. What the worker_threads module gave us(after)?
● one process
● multiple threads
● one event loop per thread
● one JS Engine Instance per thread
● one NodeJS Instance per thread process
thread
V8 libuv
NodeJS
JavaScript
thread
V8 libuv
NodeJS
JavaScript