everpeace / kube-throttler

throttling your pods in kubernetes cluster.
Apache License 2.0
32 stars 6 forks source link

Can kube-throttler solve thundering herd problem (aka stampede problem) #57

Closed buckleyGI closed 1 year ago

buckleyGI commented 1 year ago

I came across kube-throttler when looking for a solution to our pressing problem (still not solved) when we bring back a great number of pods after a blackout period.

Let me try to explain our situation. At night we scale all deployments to 0 replicas (and store the original value in an annotation) to reduce costs. In the morning the replicas are restored to their original values. This is where the problem starts as they overburden the node where the CPU plateaus to 100%. The warmup probes start to fail and, if they make it, the liveness probes will start restaring the pods. Too many pods are trying to get up at the same time... After about 2 hours the system finally stabilizes. If we startup the pods manually, say 5 per minute, the system comes up in less then 10 minutes (!). In other domains this is called the thundering herd problem or stampede problem and we haven't found a fix yet for Kubernetes.

Is this where kube-throttler can help us? I understand that kube-throttler takes into account the CPU utilization but its goal is to be more efficient and not throttle pod creation per se right. Will we be abusing kube-throttler for our use case or is it a good fit you think?

If not it is time for me to learn Go and the Scheduling Framework as it can't be too hard to install a throttle for pod creation on a node where x pods can be created in a sliding window of x minutes. Am I on the right track? Thank you.

everpeace commented 1 year ago

@buckleyGI Thank you for opening up the issue!

If we startup the pods manually, say 5 per minute, the system comes up in less then 10 minutes (!).

Thanks for the detailed description of your issue. Probably, I roughly understood your situation. It seems that you want to limit the number of pods that are starting up (i.e. pods before the liveness/startup probe succeeds) in the cluster.

Is this where kube-throttler can help us? I understand that kube-throttler takes into account the CPU utilization but its goal is to be more efficient and not throttle pod creation per se right.

Precisely, kube-throttler does NOT take into account the CPU utilization but just considers the resource requests of Pods.

Will we be abusing kube-throttler for our use case or is it a good fit you think?

I think it is not the sweet use-case. But, kube-throttler can limit the number of pods that are starting-up in the cluster.

Here is my idea:


If not it is time for me to learn Go and the Scheduling Framework as it can't be too hard to install a throttle for pod creation on a node where x pods can be created in a sliding window of x minutes. Am I on the right track? Thank you.

I also have an alternative idea. Perhaps, "Pod Scheduling Readiness" (just released in v1.26) will help.

You would also need two components:

Note: In this case, a controller decides the order of pods starting up. Usually, kube-scheduler decides the order of pods be scheduled. I think this is not actually pros/cons. But you can decide which way suits your use case.

everpeace commented 1 year ago

I edited its title to align the issue contents 🙇‍♂️

everpeace commented 1 year ago

I'm closing this due to inactive for long time