-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Need a way to change the CHUNK_SIZE value at runtime. #8
Comments
I brought this up in the old discussion forums too.
Alternatively, if you changed |
You could also expose the chunk_size option in http_listener_config class. Our goal is to stay uniform across all the platforms that we support. So ideally we would prefer solutions that can be implemented across the board. The discussion thread on codeplex also has some details https://casablanca.codeplex.com/discussions/646631 Thanks |
I'll see if we can allocate some time for me to do this change in the current (or next) milestone. It's definitely something worth investing time in. |
hey wongpsw Please note, to contribute to the project, you will need to sign our contributor license agreement (CLA). Once you've signed you can email it directly to me at kavyako at Microsoft dot com or askcasablanca at Microsoft dot com. Thanks |
I believe the correct fix to this issue is actually to add the HTTP_SEND_RESPONSE_FLAG_BUFFER_DATA flag to the HttpSendResponse and HttpSendResponseEntityBody calls in http_server_httpsys.cpp. Adding this flag increased the throughput from 15 mbit/s to 300 mbit/s for my test transfer with a 40 ms ping to the server. This flag makes http.sys automatically size the send buffer based on the ideal send backlog (ISB). To quote the MSDN documentation for SIO_IDEAL_SEND_BACKLOG_CHANGE: "When sending data over a TCP connection using Windows sockets, it is important to keep a sufficient amount of data outstanding (sent but not acknowledged yet) in TCP in order to achieve the highest throughput. The ideal value for the amount of data outstanding to achieve the best throughput for the TCP connection is called the ideal send backlog (ISB) size. The ISB value is a function of the bandwidth-delay product of the TCP connection and the receiver's advertised receive window (and partly the amount of congestion in the network)." Or in other words, manually adjusting the chunk size will never completely work as you can't predict the ideal size. Luckily we can opt-in to the kernel managing this for us by adding the HTTP_SEND_RESPONSE_FLAG_BUFFER_DATA flag. |
Or am I using cpprest in the wrong way?
Our application normally transfers data (using HTTP GET) of several hundred megabytes, the default 64 Kb chunk size seems too small for optimal download rate. Changing the value to 5 Mb can reduce download time of 2 Gb data from 2minutes to 28 seconds.
The demo code, which just allocates the requested data in-memory and send them:
And using curl for testing:
Using 64Kb chunk size:
Using 5Mb chunck size:
The text was updated successfully, but these errors were encountered: