antonputra / tutorials

DevOps Tutorials
https://youtube.com/antonputra
MIT License
3.2k stars 2.5k forks source link

ref: node app using stdlib #287

Closed vorandrew closed 2 months ago

vorandrew commented 2 months ago

Let's compare apples to apples. NodeJS stdlib implementation vs Golang stdlib

antonputra commented 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?

agravelot commented 2 months ago

Node can use multiple cores for specific workloads (not about clustered stuffs).

https://www.youtube.com/watch?v=zphcsoSJMvM

antonputra commented 2 months ago

@agravelot yes i saw it in documentation

vorandrew commented 2 months ago

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 commented 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?

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

288