aio-libs / aio-libs/aiohttp

Add keepalive_requests and keepalive_time parameters for connection

Open
#10,722 18 comments 0 reactions 0 assignees View on GitHub
client enhancement
Dominant language
Python
Stars
16.5k
Forks
2.4k
Avg merge
17h 22m
Merged PRs (30d)
212

Description

### Is your feature request related to a problem?

In the k8s environment, when the pod (behind ClusterIP Service) is scaled up, the new pod has almost no requests.

### Describe the solution you'd like

When the k8s pod is scaled up, the connection number between the new and old pods remains relatively balanced

### Describe alternatives you've considered

For example, nginx sets an upper limit on the number of requests and a time limit for each connection. If the limit is exceeded, the connection is disconnected, so that new pods of the service will also have the opportunity to receive new requests.
[keepalive_requests](https://nginx.org/en/docs/http/ngx_http_upstream_module.html#keepalive_requests)
[keepalive_time](https://nginx.org/en/docs/http/ngx_http_upstream_module.html#keepalive_time)

### Related component

Client

### Additional context

When I was stress testing the backend service, after the k8s pod was scaled up, the CPU usage of the new and old pods differed greatly because the new pods had much fewer connections than the old pods.

![Image](https://github.com/user-attachments/assets/0960721a-fe8d-47bb-88a7-a26cddc173d6)

### Code of Conduct

- [x] I agree to follow the aio-libs Code of Conduct

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.