Closed vorandrew closed 2 months ago
@vorandrew sure, will do! just to clarify, it won't matter how many CPU cores i give to node, right? for example, if i give it 4 CPUs, it will still use 1 because it's single-threaded? so again, it wouldn't be fair to compare, i guess. would it make more sense to create 2 replicas of each app and give each 1 CPU instead so we still get 2 CPU per application?
Node can use multiple cores for specific workloads (not about clustered stuffs).
@agravelot yes i saw it in documentation
Network I/O operations on node.js runs on the main thread.
Yes, node.js spawns four threads in addition to the main thread but none of them are used for network I/O such as database operations
@vorandrew sure, will do! just to clarify, it won't matter how many CPU cores i give to node, right? for example, if i give it 4 CPUs, it will still use 1 because it's single-threaded? so again, it wouldn't be fair to compare, i guess. would it make more sense to create 2 replicas of each app and give each 1 CPU instead so we still get 2 CPU per application?
It's not CPU cores you are giving... it's CPU limits. Go concurrency is limited by number of physical cores on machine or GOMAXPROCS
Here is good read https://www.ardanlabs.com/blog/2024/02/kubernetes-cpu-limits-go.html
PS: We are having this conversation in the wrong pull request thread
Let's compare apples to apples. NodeJS stdlib implementation vs Golang stdlib