iconify / api

Iconify API script. Search engine for icons, provides icon data on demand for icon components, dynamically generates SVG.
MIT License
96 stars 34 forks source link

Multi cores #1

Closed ghost closed 1 year ago

ghost commented 4 years ago

Hi!

Can you create a multi-core version for this node app?

I'm beginner in node and i want to run this app on my dedicated server with 8 cores.

Thanks !

cyberalien commented 4 years ago

You can assign port via PORT environmental variable, use pm2 to start and manage multiple processes, then use nginx to route requests.

Its not needed though, unless you expect massive traffic.

Currently on api.iconify.design I'm getting over 30 million requests per month. Its handled by 7 small servers (distributed among different datacenters in different parts of world, then using latency routing to direct visitors to closest server for lowest possible latency, also hidden behind Cloudflare to provide SSL support), one process on each server. It handles that traffic without any issues and can handle much more.

ghost commented 4 years ago

As i know, node app run on single core.

You want to say it's ok to run only one instance (1 core) ?

I don't understand exactly how to manage multiple processes.

Thanks!

cyberalien commented 4 years ago

Yes, its ok to run only one instance. All data is in memory, so API handles requests in just few milliseconds. It is very fast.

To manage multiple processes you can use pm2. Its a really good easy to use tool.

If you do spawn multiple processes, use nginx to load balance them. If not, use nginx anyway to handle SSL stuff. There are various tutorials online for using nginx as load balancer or as proxy for node.js applications.