1

How can i control the distribute of requests inside a pod? For example: I have one pod with one container that runs NodeJs Hello world with 10sec sleep. At first without scaling, i just want to hold other requests until the container finish processing a request.

Im trying to implement a simple Function as a service with Kubernetes.

  • Presumably requests will already block if your service is busy / can't handle them. Are you saying that you need a bigger queue or something? – Oliver Charlesworth Jan 30 '18 at 08:57
  • no, im saying that the service is not busy and can handle other requests...but i still want 1 request per container (like lambda) –  Jan 30 '18 at 09:00
  • Ah right, sounds like you're talking about explicit throttling. I don't know whether K8S has built-in support for that, but I wonder whether you could also achieve that the source-code level in your service? (e.g. by only having a single request-handler thread.) – Oliver Charlesworth Jan 30 '18 at 09:05
  • what if i use Coarse Parallel Processing Using a Work Queue? every request will be a job. –  Jan 30 '18 at 10:35

1 Answers1

0

Since Kubernetes support ingress controller, you may configure nginx like this below:

limit_req_zone $binary_remote_addr zone=mylimit:10m rate=10r/s;

server {
location /login/ {
    limit_req zone=mylimit;


    proxy_pass http://my_upstream;
}
}

But if you want to limit rate by using kubernetes resource quota, the github issue: https://github.com/kubernetes/kubernetes/issues/2856 may be useful

Configuring Basic Rate Limiting

k8s Ingress

Wu Wenter
  • 171
  • 5