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
The http-proxy example seem to add 5s to every PUT requests. It seem to be due to some unexpected keep-alive timeout.
Below is a minimal (although not short) example in order to reproduce the issue.
Reproducing the issue
We'll send a PUT request using curl to the rust http-proxy server, and this server will proxy the request to a node backend.
node backend: a simple upload server
The upload server is a simple nodeJS server:
when you PUT /something.txt, it writes the body of the request in ./uploads/something.txt
when you GET /something.txt, it serves the file ./uploads/something.txt
mkdir uploads
npm install
# This server listens on port 3000
node server.js
Second terminal: the proxy server
# actix is listening on port 4444, and forwards things to# our node server which listens on port 3000
cargo run 127.0.0.1 4444 127.0.0.1 3000
Third terminal: uploading/downloading files
Depending on if you perform a GET or PUT request, execution time is very different.
$ time curl -XPUT -H 'Content-Type: application/octet-stream' --data-binary @computer.svg 127.0.0.1:4444/computer.svg
real 0m5.008s
user 0m0.000s
sys 0m0.004s
$ time curl -XGET http://127.0.0.1:4444/computer.svg
…file content
# execution time for the GET request
real 0m0.011s
user 0m0.004s
The 5s is consistent, only on the PUT request. My sample file computer.svg weights 5882 bytes so size is out of the equation.
I did the same thing with a python flask server (whose code is here), it yields the same results.
On a more complex example with logging, it seems the extra 5s come from a Keep-alive timeut:
…
[2020-05-28T08:46:46Z TRACE actix_codec::framed] attempting to decode a frame
[2020-05-28T08:46:46Z TRACE actix_codec::framed] frame decoded from buffer
[2020-05-28T08:46:46Z INFO actix_web::middleware::logger] 127.0.0.1:35050 "PUT /victory HTTP/1.1" 100 0 "-" "curl/7.52.1" 0.030986
[2020-05-28T08:46:51Z TRACE actix_http::h1::dispatcher] Keep-alive timeout, close connection
[2020-05-28T08:46:51Z TRACE mio::poll] deregistering handle with poller
[2020-05-28T08:46:51Z TRACE mio::poll] registering with poller
…
With some help to identify the root cause, I can totally make the fix, but I'm a bit lost in the codebase here.
The text was updated successfully, but these errors were encountered:
The
http-proxy
example seem to add 5s to every PUT requests. It seem to be due to some unexpected keep-alive timeout.Below is a minimal (although not short) example in order to reproduce the issue.
Reproducing the issue
We'll send a PUT request using curl to the rust http-proxy server, and this server will proxy the request to a node backend.
node backend: a simple upload server
The upload server is a simple nodeJS server:
PUT /something.txt
, it writes the body of the request in./uploads/something.txt
GET /something.txt
, it serves the file./uploads/something.txt
package.json
server.js
Running the test
You'll need 3 terminals (or tmux, etc…).
First terminal: the upload server
mkdir uploads npm install # This server listens on port 3000 node server.js
Second terminal: the proxy server
Third terminal: uploading/downloading files
Depending on if you perform a GET or PUT request, execution time is very different.
The 5s is consistent, only on the PUT request. My sample file
computer.svg
weights 5882 bytes so size is out of the equation.I did the same thing with a python flask server (whose code is here), it yields the same results.
On a more complex example with logging, it seems the extra 5s come from a
Keep-alive
timeut:With some help to identify the root cause, I can totally make the fix, but I'm a bit lost in the codebase here.
The text was updated successfully, but these errors were encountered: