Consider the number of activators when throttling the requests
In what area(s)?
/area networking
Describe the feature
As per discussion in https://github.com/knative/serving/pull/3139.
Once we want to scale out the number of activators we need to make sure each activator is aware of the number of its own of replicas to prevent overflowing the user pods. For example instead of sending Number of pods * ContainerConcurrency requests we send Number of pods * ContainerConcurrency / Activator Replicas.
This should be a prereq for https://github.com/knative/serving/issues/1625
@vvraskin Any chance you can look at this in 0.7?
@mattmoor Unfortunately not, I changed the company recently and will not have enough cycles in the next weeks... :(
/assign
I tried to reproduce this issue in the following format.
sample app: test/test_images/helloworld/helloworld.yaml
traffic: hey -z 5s -c 500 -host "route-example.default.example.com" http://external_ip
When the app is scaled to 0 instance and the burst of traffic is sent.
- In the default case of 1 activator instance, 5 pods are up and running to handle traffic.
Status code distribution:
[200] 478 responses
[502] 22 responses
- In case of 4 replicas, 5 pods are up and running to handle traffic.
Status code distribution:
[200] 490 responses
[502] 10 responses
I believe the behavior remains the same because each replica of activator receives part of the traffic and it passes the information to PA which makes the decision about autoscaling pods. In the end irrespective of activator replicas the number of scaled pods are the same so I do not think there is anything to be done in this issue.
Please correct me if I am wrong or misunderstanding this issue altogether.
cc @mattmoor
@shashwathi The issue here is about the throttling behavior of the activator.
As an example, if you have a Revision with containerConcurrency = 10 and 0 pods, the activator will block all requests from hitting those pods. As soon as 1 pod becomes available, the activator allows exactly 10 requests to pass along. When the next pod comes up it allows 20 requests and so on. It makes sure to not overload the revision.
If we have multiple activators however, they would overload the revision because each of them would let 10 (20) requests through as they are not connected by any means.
In order to reproduce this you'll need to add containerConcurrency to the revision template. helloworld.yaml doesn't have that. You should see a vast number of 503s in multiple activators vs. only one of them.
@markusthoemmes : Thank you for your comment.
I updated the helloworld application to containerConcurrency: 10 and ran the following experiment.
traffic burst command: hey -z 10s -c 500 -host "route-example.default.example.com" http://external_ip
Experiment with activator replicas 1, concurrency = 10
Run1: Result: 46 pods
Status code distribution:
[200] 489 responses
[502] 1 responses
Run2: Total pods: 30
Status code distribution:
[200] 500 responses
Experiment 2 with activator replicas 4, concurrency = 10
Run 1: Total pods : 40
Status code distribution:
[200] 500 responses
Run 2: Total pods: 35
Status code distribution:
[200] 500 responses
We ran the same experiment with helloworld application handler sleeping for 6s and got similar results as above. We did this to ensure the number of open connections from activator to pod remained at 10 thus forcing overload if there is no other pods to accept the traffic.
If we have multiple activators however, they would overload the revision because each of them would let 10 (20) requests through as they are not connected by any means.
It appears that the revision is scaled up instantly and handled the traffic in a similar fashion irrespective of activator replicas. Is there more concrete way of reproducing this problem? or is this an edge case scenario?
cc @andrew-su
@shashwathi @andrew-su
helloworld application handler sleeping for 6s
Can you confirm you did this with the readinessCheck in the helloworld application? Otherwise, the KPA will think the revision is ready, and deactivate the activator.
Can you confirm you did this with the readinessCheck in the helloworld application? Otherwise, the KPA will think the revision is ready, and deactivate the activator.
We removed the readiness check for this experiment. If we have handler that doesn't respond for 6s then readinesscheck will fail forever and never mark deployment as ready.
If we have handler that doesn't respond for 6s then readinesscheck will fail forever and never mark deployment as ready.
Isn't that what you want to guarantee that the requests go to the activator? Otherwise, subsequent requests will go directly to the revision instead of the activator.
@tanzeeb : Thank you for that pointer. Totally missed that while testing. We updated the experiment to include health endpoint with no delay and / endpoint with 10 sec delay. Below is the readiness probe we used for Helloworld application experiment.
path: /health
initialDelaySeconds: 40
periodSeconds: 10
We noticed that 1 instance of activator results in only 200 responses whereas 4 instances of activator results is 5-10% of traffic in 5xx responses.
We have submitted a PR to fix this.