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?