You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 1, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Jun 1, 2026. It is now read-only.
Need a way to change the CHUNK_SIZE value at runtime. #8
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:
[root@localhost ~]# curl -o NUL 10.50.10.51:8080/bytes?mb=2000
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 2000M 100 2000M 0 0 15.7M 0 0:02:06 0:02:06 --:--:-- 14.8M
Using 5Mb chunck size:
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 2000M 100 2000M 0 0 69.2M 0 0:00:28 0:00:28 --:--:-- 77.1M
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.
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: