@pbischoff said in Scaling/vCPU core usage of Directus in Cloudron:
But this is a problem for almost every node.js app of the cloudron App Store, isn't it? Do they all use only one vCPU core?
Apps like NodeBB (this forum) support so called cluster mode - https://nodejs.org/api/cluster.html . Essentially, this creates worker threads to spread load across CPU. This is part of nodejs.
But to keep in mind, nodejs by itself can handle quite a bit of parallelism with just one CPU. Most of the work done by the main process is just http request processing. This is usually I/O bound and not CPU bound. Nodejs being asynchronous can handle requests in parallel in just one process quite easily. We are talking about 1000s of requests a second.
Many other nodejs apps like Cloudron code itself, peertube, offload the processing of static assets to a side installation of nginx. So, when downloading images/css files etc, it doesn't even hit nodejs. When node code has to do heavy work, it usually just puts it in a queue and the queue handler is a separate process (which can thus be restarted and killed easily). The queue handler will use another cpu core.
For directus, I am not an expert on the app. But, you want to maybe use some worker thread or queue or something like that to make use of more CPUs.