5 ms·
One thing that I’ve been unable to wrap my head around is how to effectively calculate the right CPU share values for single threaded web-servers. I’ve got a p
by jackcodes 7y ago
One thing that I’ve been unable to wrap my head around is how to effectively calculate the right CPU share values for single threaded web-servers.
I’ve got a project using this setup, but it’s fairly common one l- e.g. Express with node clustering, Puma on Rails etc. On Kubernetes you obviously just forgo the clustering ability and let k8s handle the concurrency and routing for you.
So in this instance, I’m struggling to see why I wouldn’t request a value of 1vCPU for each process. My thinking is that my program is already single threaded, and asking the kubernetes CPU scheduler to spread resource between multiple single threaded processes is pure overhead. At that point I should allow each process to run to its full capacity. Is that correct?
This I feel gets a lot more complex now that my chosen language, DB drivers, and web framework is just starting to support multithreading. That’s a can of worms I can’t begin to figure out how to allocate for - 2vCPU’s each? Does anyone know?
- chmod775 7y agoJavaScript, the language, is single threaded, but node and V8 are not. Depending on how much (and how heavy) async work you're doing it might be reasonable to let a node process use multiple cores.
- jackcodes 7y agoGood point - although it’s worth clarifying that I’m on Crystal for this, meaning I’m definitely single threaded in this instance. Would that be as simple as a case of 1vCPU per pod?
- YawningAngel 7y agoAt $job we default to 1vCPU per pod with the option to ask for more if that makes sense (e.g. you use a lot of shared heap and can meaningfully multithread).
- jackcodes 7y agoThanks, this was almost exactly the brief validation I was looking for.