Repository navigation
Description
I did some simple tests today and found that envoy's performance seems to be getting worse and worse. Although I know features should always come at some cost. But those costs seem to be too much.
And although I know that performance is not the first goal of Envoy. But with continuous enhancement of Envoy, the performance seems to degrade too quickly. Here are some simple results of single envoy worker:
| Version | QPS |
|---|---|
| v1.12.4 | 26921.48 |
| v1.13.3 | 25182.18 |
| v1.14.7 | 23732.31 |
| v1.15.5 | 21010.66 |
| v1.16.5 | 19116.81 |
| v1.17.4 | 17804.78 |
| v1.18.4 | 16953.67 |
| v1.19.1 | 16046.59 |
| v1.20.0 | 15949.65 |
I think we should at least prevent it from further deterioration, and at the same time find ways to optimize it.
Here is my config yaml:
static_resources:
listeners:
- address:
socket_address:
address: 0.0.0.0
port_value: 9090
filter_chains:
- filters:
- name: envoy.http_connection_manager
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
codec_type: auto
stat_prefix: ingress_http
route_config:
name: local_route
virtual_hosts:
- name: host-one # prefix route
domains:
- "*"
routes:
- match:
prefix: "/"
route:
cluster: httpbin
http_filters:
- name: envoy.router
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
dynamic_stats: false
suppress_envoy_headers: true
clusters:
- name: httpbin
connect_timeout: 5s
type: strict_dns
lb_policy: round_robin
load_assignment:
cluster_name: httpbin
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: localhost
port_value: 8080
admin:
access_log_path: "/dev/null"
address:
socket_address:
address: 0.0.0.0
port_value: 20000
Back-end: multi-processes Nginx that will return simple short string.
Client command: wrk -c 200 -t 2 -d 180s http://localhost:9090/
Activity
wbpcode commentedon Nov 25, 2021
cc @mattklein123 @rojkov
zhxie commentedon Nov 25, 2021
Have you ever profiled Envoy with tools like perf, so that we can find some hotspots from the result?
wbpcode commentedon Nov 25, 2021
I will do it this weekend. 😄
rojkov commentedon Nov 25, 2021
This feels like a duplicate of #13412.
wbpcode commentedon Nov 25, 2021
Yep. Looks like the degrading never stops.
wbpcode commentedon Nov 25, 2021
Here are some flame graphs.
I only have two different binary files with code symbols. Considering that there has been a huge gap in performance between them, I think it is enough as a reference.v1.17.4:
https://drive.google.com/file/d/1aZuC54PmIXsQu7k88jBeU-HENOEiQXgT/view?usp=sharing
v1.12.2:
https://drive.google.com/file/d/1o6kV8T2J5nCs3m7lHaXSdXaudjzNJ9Sv/view?usp=sharing
v1.20.x
https://drive.google.com/file/d/1lU539aRFzOCrR16EFTjKwu0MtzV03_kr/view?usp=sharing
cc @mattklein123
wbpcode commentedon Nov 26, 2021
There are no obvious hotspots from the flame graph, just a very uniform slowdown. More encapsulation and abstraction gradually reduces the performance of Envoy.
jmarantz commentedon Nov 26, 2021
I'm not sure if I buy that incremental changes in encapsulation and abstraction are likely to cause that much slowdown. I glanced at one of the flame-graphs and it's hard to know what to improve there.
It might help to capture some perf-graphs from an instrumented binary that can provide more detail on what's going on. The purely sampled view we get from these flame-graphs might (for example, as a guess) hide some effects of changes in the way we make the networking system calls. E.g. we spend a lot of time in the 1.20 flamegraph in the kernel. Are we making larger numbers of calls for smaller chunks of data, for any reason?
It would be nice to get a controlled repro of this, using NIghthawk preferably, and then run envoy under
callgrindor compiled with various perf tools, so we can see call-counts for various functions. Using this we could compare how we are structuring our system calls to the earlier version of Envoy.wbpcode commentedon Nov 26, 2021
I will try to do more investigate.
mattklein123 commentedon Nov 26, 2021
Related to @jmarantz comment, over time we have generally moved to secure by default configuration. This almost universally is at odds with "horse race" benchmarks. So we will need to very carefully tease apart any differences. The work is useful but it's a lot more complicated than just looking at flame graphs. I also agree with @jmarantz that trying to run a reproducer under something like cachegrind will be a lot more informative.
jmarantz commentedon Nov 26, 2021
Just to point this out: Matt suggests cachegrind and I suggested callgrind: they are related and both very useful:
--tool=callgrindvs--tool=cachegrind)--compilation_mode=opt --cxxopt=-g --cxxopt=-ggdb3but those options might be dated as I haven't been able to do much direct technical work latelykcachegrind60 remaining items
botengyao commentedon Apr 2, 2025
Thanks @triplewy for noticing this config, agreed this should be limited for overload management, and this is also limited in our environment. I will update the doc to reflect it.
kyessenov commentedon Apr 15, 2025
What's the theory behind multi-accept causing performance degradation? Is it because a worker does more work per event and a lot of that work is wasted (due to slow upstreams)? What's the kernel queue size (128?)?
botengyao commentedon Apr 15, 2025
I think the multi-accept could cause issues under high load, not the general performance degradation concern per versions in this issue. From an internal load test and observation, Envoy can accept >1000 connections per event from kernel, and that will use more CPU and memory at that time to let Envoy be unstable during traffic spike, e.g., overload manager cannot kick in, leading to OOMs, and so on.
triplewy commentedon Apr 15, 2025
@kyessenov Essentially Envoy gets stuck performing SSL calculations when it accepts all downstream connections at the same time. This prevents upstream requests from completing in a certain amount of time because the event loop is filled with SSL calls. Our event loop duration during influxes of https connections could sometimes get to 10-30s.
In production without setting max downstream conns to accept, we saw behavior where an influx of downstream https connections would cause our fleet of proxies to essentially collapse where all success rate dropped to 0% for 5 minutes and then it restored since the clients left from their requests were being reset. But due to our client behavior, they would come back after another 10 minutes and we'd have this 100-0% success rate oscillation during peak times in some clusters.
kyessenov commentedon Apr 15, 2025
@triplewy OK, that makes sense. So this is really about flow control with respect to CPU, and we want reasonable fairness between upstream and downstream work.
johnlanni commentedon Jul 1, 2025
But this should not cause Envoy to crash, right? I understand it crashed due to an OOM. The reason for the OOM, I guess, is that after accepting a large backlog of connections in one event loop, the data sent over the connections was not processed in time, leading to the TCP read buffer occupying too much memory.
KBaichoo commentedon Jul 1, 2025
Might be due to what you have in your listener filter chain which gets allocated on connection acceptance. I would be surprised if the TCP read buffer should be that large given that the application had not yet even accepted the connection.
johnlanni commentedon Jul 1, 2025
Yes, resource allocation related to connections on the Envoy side can also lead to OOM. Additionally, my previous statement was not clear; I did not mean that the TCP read buffer for unaccepted connections is large. What I wanted to point out is that after accepting a large number of connections in an event loop, if the data from each connection cannot be read in time, it will cause the data sent by the client on the already accepted connections to accumulate. If each event loop only accepts one request, this problem would not occur, effectively throttling the data sent by the client(limited by the maximum size of the accept queue.).
triplewy commentedon Jul 1, 2025
@johnlanni But the tcp buffer memory is in the kernel right? That would not impact the application from OOMing. From my understanding the connections are already established from the kernel side. The application just accepts them and in this case, Envoy reads the TLS CHLO from the TCP buffer of each accepted connection and signs the SSL handshake. I think the creation of a bunch of listener filters at the same time causes the proxy to OOM.
What we think would be an interesting problem would be to see if making max_conns_to_accept_per_socket_event could be less than 1. For example 0.5. In what case should that number be lower than 1? What would you need to measure to find the optimal conns to accept for socket event (event loop).
johnlanni commentedon Jul 1, 2025
Oh, indeed, unless in scenarios like K8s containers, where it might be OOM killed by the kubelet.
kimiyasharifi commentedon Nov 28, 2025
@triplewy @kyessenov @botengyao We recently experienced a very similar failure pattern during a traffic spike, and I wanted to share additional data points that may help others. Even though we explicitly set:
max_connections_to_accept_per_socket_event: 1we still observed envoy OOMing under heavy load. Context from our setup:
Very high spike on a single authority
Two response flags showed strong spikes:
What we observed:
Our hypothesis so far:
It seems that under extreme spikes, the accept throttling alone is not sufficient to prevent memory growth from pending upstream requests + connection-level allocations.
We’re still analyzing memory profiles and would love any guidance on:
If useful, I can share additional metrics or narrower traces.
botengyao commentedon Dec 2, 2025
It seems this issue is originally on the general performance problem version by version, and the topic is diverged to overload management. And it is a really tricky system problem in general that some need to be tuned, @kimiyasharifi, some insights:
Do you config the overload manager and what is your config? Is the traffic mainly H/1 or H/2?
Consider enabling load shed points,
envoy.load_shed_points.tcp_listener_acceptforenvoy.load_shed_points.http_connection_manager_decode_headersdownstream connections and requests.Consider enabling load shed points
envoy.load_shed_points.connection_pool_new_connectionto prevent more connections for upstream when the system is under pressure.Enabling the cluster level maximum active retries sounds a reasonable config to enable if you see retry storm.
KBaichoo commentedon Dec 2, 2025
@kimiyasharifi do you mind raising either another issue or bringing this up in the community call: https://docs.google.com/document/d/1Yc4zkV-A_cC_R3C0u6D15WQAsRSxADs8p2l8UMMa4P4/edit?tab=t.0#heading=h.vgkvn1hr5uor to keep this thread on track with general performance?
The community call might be higher bandwidth for getting some help
kimiyasharifi commentedon Feb 7, 2026
Sorry for the delay. We haven’t enabled the overload manager in Contour, and most of our traffic is HTTP/2.
moozechen commentedon Jul 20, 2026
Really interesting data. We've been benchmarking Envoy as a gRPC-web proxy for streaming workloads and seeing similar patterns — the per-connection overhead dominates at low concurrency but Envoy scales linearly once past ~100 concurrent streams.
One observation that might help: we found that enabling HTTP/2 priority hints (via gRPC metadata on the client side) significantly improves tail latency under mixed workloads (large file transfers + small RPCs sharing the same connection). Without priority, a single large response can add 50-200ms to concurrent small RPCs. With priority, the max tail latency impact drops to <20ms.
Also curious if you've tested with gRPC bidirectional streaming specifically? We noticed a ~15% throughput hit vs unary/server-streaming under Envoy, which seems to be from the extra buffering in the H2 frame layer. Would love to see that added to the benchmark matrix.