Skip to content
This repository was archived by the owner on Dec 18, 2018. It is now read-only.

Limit size of memory buffer when reading request #304

Closed
Tratcher opened this issue Oct 29, 2015 · 5 comments
Closed

Limit size of memory buffer when reading request #304

Tratcher opened this issue Oct 29, 2015 · 5 comments
Assignees
Milestone

Comments

@Tratcher
Copy link
Member

As @halter73 explained it to me, kestrel will constantly read the incoming request body off the socket and buffer it in memory until the application retrieves it. This could consume significant amounts of memory if the app isn't draining it fast enough.

Should Kestrel implement IHttpBufferingFeature.DisableRequestBuffering to stop preemptively buffering the request body and only read it on-demand? This would also let you put back-pressure on the client if they are sending data too quickly. This is also something that may make sense to enable/disable at startup.

@benaadams
Copy link
Contributor

Or a max buffered property?

@halter73 halter73 added this to the 1.0.0-rc2 milestone Nov 13, 2015
@muratg muratg assigned cesarblum and unassigned troydai Dec 15, 2015
@muratg
Copy link
Contributor

muratg commented Dec 15, 2015

@CesarBS Feel free to ping @troydai as he has some context on this one.

@lodejard
Copy link
Contributor

Having a max read-ahead would be a good idea. Disabling request buffering would be a different thing- that would be to stop the server or middleware from remembering the body, to disable "seek" rewinding

@DamianEdwards
Copy link
Member

post RC2

@muratg muratg removed the 1 - Ready label Jan 22, 2016
@muratg muratg modified the milestones: Backlog, 1.0.0-rc2 Jan 22, 2016
@halter73 halter73 modified the milestones: 1.0.0-rc2, Backlog Mar 1, 2016
@mikeharder mikeharder changed the title Implement IHttpBufferingFeature.DisableRequestBuffering Limit size of memory buffer when reading request Mar 11, 2016
@mikeharder mikeharder modified the milestones: 1.0.0-rc2, 1.0.0 Mar 29, 2016
@muratg muratg modified the milestones: 1.0.1, 1.0.0 May 18, 2016
@muratg muratg modified the milestones: 1.0.0, 1.0.1 May 31, 2016
mikeharder added a commit that referenced this issue Jun 14, 2016
- Added property `KestrelServerOptions.MaxRequestBufferSize`
 - Default is 1,048,576 bytes (1MB)
 - If value is null, the size of the request buffer is unlimited.
- Fixed bug in `IConnectionControl.Resume()` where `_socket.ReadStart()` can throw if the socket is already disconnected.
- Made `UvStreamHandle.ReadStop()` idempotent, to match `uv_read_stop()`.
@muratg
Copy link
Contributor

muratg commented Jun 14, 2016

Thanks @mikeharder!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

9 participants