-
-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use multiple cores by the API #224
Comments
I'm not seeing the core usage on this screenshot, but generally speaking there's no benefit to using worker_threads for I/O operations, and that's 90% (if not more) of what this API service is doing. I would say you should consider spawning new threads for CPU intensive work, like hashing, encryption or parsing and leave I/O operations with the main Event Loop. |
|
Not possible, we use host networking, meaning only 1 container can run at any moment on a VM. Also it would probably increase pub-sub traffic and make syncing of probes more difficult. So ideally we want to only move specific operations to other threads and not run the whole API per thread. |
we don't have intensive sync work to move from main thread. So when 2 VMs will not be enough we should choose between adding new VMs or running per thread. |
|
The key thing here is to set up socket.io communication. Currently the only way to implement it is by using As redis is our current bottleneck I am not sure we need to proceed with the solution described above. At least until #269 is implemented. I've posted a question about combining |
Linked issue: |
The fetchSocket() calls are cached now, aren't they? The effect should not be that significant. |
That is true, it is cached. And I don't think effect will be that big. But anyway our servers are usually loaded on ~15% even under perf tests, while redis barely deals with the load. So we shouldn't make the narrow place more narrow to tune the API servers. |
So what we can see on the image is that currently our bottleneck is the perf of the node process itself. (Redis CPU is ~3%, while API CPU is ~100%). From the flamegraph we are observing that that there are some sync operation done mostly by npm packages, those are:
We can't get rid of most of that operations, but we should benefit from doing them in parallel and applying a cluster to the API seems to make sense now. Other possible optimizations:
P.S. Socket.io load generated by mtr (5 RPS * 4 seconds * 500 probes): |
Can you explain the |
Not 15 writes per second, just 15 writes per probe per measurement. So it is 150000 writes overal, and since such measurements usually take ~20 seconds to end it is 150000/20 = 7500 writes per second. |
Oh ok so the first part "5 req * 4 seconds" means 5 rps for 4 seconds = 20 measurements overall, right? |
Yeah, that is the case when CPU gets to 100% after a few mtr requests. |
Currently we have a 4 cores CPU.
Node effectively uses only one of them.
We should consider options to load idle cores: cluster, worker_threads, etc.
The text was updated successfully, but these errors were encountered: