Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory consumption by Idle HTTPS/TLS Connections #4721

Closed
Tratcher opened this issue Sep 14, 2018 · 8 comments
Closed

Memory consumption by Idle HTTPS/TLS Connections #4721

Tratcher opened this issue Sep 14, 2018 · 8 comments
Assignees
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions enhancement This issue represents an ask for new feature or an enhancement to an existing one feature-kestrel investigate Perf severity-nice-to-have This label is used by an internal tool
Milestone

Comments

@Tratcher
Copy link
Member

[Reposting from an e-mail thread]

When I was doing IoT for example, we measured that an idle HTTPS/TLS connection can suck as much as 128 KB of memory. For Gateway scenarios, where connections can be mostly idle, but they need to be there this is very expensive. If I remember correctly the problem was SSL libraries requiring a couple of 32KB or 64KB buffers no matter what.

Ideally, you want 'idle' connections to truly cost 0 Bytes of memory or very close to it.

And this is relatively simple to test, create a HTTPS server with 100,000 TLS connections doing nothing, take note of the Commit Bytes, divide by 100,000.

Do you know in .NET Core what is the cost?

A lot of that overhead is cached request structures and pipe buffers designed to make active connections faster. We could consider discarding some of those cached objects if the connection is idle for a certain period of time. What if we only held it via a weak reference when the connection was idle?

@davidfowl
Copy link
Member

We should look at adding a benchmark here added to our performance infrastructure.

cc @sebastienros

@Drawaes
Copy link
Contributor

Drawaes commented Sep 14, 2018

Remember that there is overhead inside SChannel / OpenSsl per connection as well (that is in process as well so will increase commit bytes). Are you measuring this on windows or Linux currently? There are some settings for Openssl that can be used to alleviate some memory pressure by allowing buffers to be shared/reclaimed from idle connections that I have mentioned previously in other conversations

@Drawaes
Copy link
Contributor

Drawaes commented Sep 14, 2018

I am happy to help with this if you want someone to help out.

@muratg muratg changed the title Memory consumption by Idle Https/TLS Connections Memory consumption by Idle HTTPS/TLS Connections Sep 19, 2018
@muratg
Copy link
Contributor

muratg commented Nov 28, 2018

We'll revisit this after @jkotalik's pipe changes are in. We don't think there's anything to do in Kestrel after that. Any other optimization would have to come from CoreFX.

@aspnet-hello aspnet-hello transferred this issue from aspnet/KestrelHttpServer Dec 13, 2018
@aspnet-hello aspnet-hello added this to the 3.0.0 milestone Dec 13, 2018
@muratg
Copy link
Contributor

muratg commented Mar 7, 2019

@Tratcher did you try anything here?

@Tratcher
Copy link
Member Author

Tratcher commented Mar 7, 2019

No, this is not on my radar.

@analogrelay analogrelay modified the milestones: 3.0.0, 3.0.0-preview6 Mar 27, 2019
@analogrelay analogrelay modified the milestones: 3.0.0-preview6, Backlog Apr 30, 2019
@jkotalik jkotalik added affected-very-few This issue impacts very few customers enhancement This issue represents an ask for new feature or an enhancement to an existing one severity-nice-to-have This label is used by an internal tool labels Nov 13, 2020 — with ASP.NET Core Issue Ranking
@davidfowl davidfowl self-assigned this Mar 28, 2021
@davidfowl davidfowl modified the milestones: Backlog, 6.0.0 Mar 28, 2021
@davidfowl davidfowl removed the affected-very-few This issue impacts very few customers label Mar 28, 2021
@davidfowl
Copy link
Member

I've done a bunch of work here. I'll put it in preview4 because there's some pending work in the BCL (dotnet/runtime#49573)

@davidfowl davidfowl modified the milestones: 6.0.0, 6.0-preview4 Mar 31, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Apr 30, 2021
@amcasey amcasey added area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions and removed area-runtime labels Jun 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions enhancement This issue represents an ask for new feature or an enhancement to an existing one feature-kestrel investigate Perf severity-nice-to-have This label is used by an internal tool
Projects
None yet
Development

No branches or pull requests

8 participants