Skip to content

Latest commit

 

History

History
21 lines (15 loc) · 812 Bytes

File metadata and controls

21 lines (15 loc) · 812 Bytes

Make Your Node.js Server Scalable with Multithreads

Node.js Cluster Documentation: https://nodejs.org/dist/latest-v16.x/docs/api/cluster.html#how-it-works

Installation

  • Import web server file in multithread.js line 47
  • Add multithreads.js into your project
  • Add your Node.js server file path into the require for multithreads.js

Run

node multithreads.js

Deployment

  • This file requires more space on an EC2 than T2.Micro due to the memory needed for worker processes.
  • Use a T2 Small by default, then if you scale past 8 threads, it is suggested that you auto-scale your EC2s (Using more than 8 threads can cause cross-thread errors due to poor API design, if you increase the threads past 8 increase the size of your server to meet the needs of your threads)
node multithreads.js