简体   繁体   中英

Node.js Cluster

I am writing an application in Node.js which serves dynamic web pages. I would like this application to scale over multiple CPU cores, so I have decided to use cluster to create a worker for each CPU core.

I also use a 3rd party API which needs to be polled frequently checking for changes, and often needs to be queried and cached based on user input. As there are rate limits on this API, I would like to have a single instance of the API and cache between all workers.

What is the best way to share and communicate with a resource (cache and 3rd party API) between multiple workers? Should I create a separate worker for the resource, or use the master one?

As there are rate limits on this API, I would like to have a single instance of the API and cache between all workers.

Ideally you would make these API queries from the master and then use process.send to send them to the workers if you want.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM