-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Why does the performance of reqwest fluctuate so much? #1116
Comments
I do not know the reason. You're certain it's not the server, or your network? Do you see the same if using the async client? |
I connect to the target server through a LAN. I use nodejs without this problem. I haven't used an async client. |
In my low-concurrency scenario, is there any difference in performance between asynchronous and synchronous clients? |
Looking at what you posted, there shouldn't be much difference. The blocking client works by having a background thread run an async client, so I thought maybe the extra thread could be competing, but I see you have multiple cores so likely not an issue. You could turn on logs for |
Ok i try it, thanks. |
It looks like the problem is here. why? [2020-12-17T07:35:59.499410Z TRACE hyper::proto::h1::conn] flushed({role=client}): State { reading: Init, writing: KeepAlive, keep_alive: Busy }
[2020-12-17T07:35:59.523475Z TRACE hyper::proto::h1::conn] Conn::read_head [2020-12-17T07:35:59.499290Z TRACE hyper::proto::h1::decode] Chunk size is 0
[2020-12-17T07:35:59.499293Z TRACE hyper::proto::h1::decode] end of chunked
[2020-12-17T07:35:59.499297Z DEBUG hyper::proto::h1::conn] incoming body completed
[2020-12-17T07:35:59.499301Z TRACE hyper::proto::h1::conn] maybe_notify; read_from_io blocked
[2020-12-17T07:35:59.499307Z TRACE want] signal: Want
[2020-12-17T07:35:59.499310Z TRACE want] signal found waiting giver, notifying
[2020-12-17T07:35:59.499315Z TRACE hyper::proto::h1::conn] flushed({role=client}): State { reading: Init, writing: Init, keep_alive: Idle }
[2020-12-17T07:35:59.499319Z TRACE want] signal: Want
[2020-12-17T07:35:59.499311Z TRACE reqwest::blocking::wait] wait at most 30s
[2020-12-17T07:35:59.499329Z TRACE reqwest::blocking::wait] (ThreadId(1)) park timeout 29.999999715s
[2020-12-17T07:35:59.499321Z TRACE hyper::proto::h1::conn] flushed({role=client}): State { reading: Init, writing: Init, keep_alive: Idle }
[2020-12-17T07:35:59.499346Z TRACE want] poll_want: taker wants!
[2020-12-17T07:35:59.499351Z TRACE hyper::client::pool] put; add idle connection for ("http", 796285560210.coloc.huobi.com)
[2020-12-17T07:35:59.499354Z DEBUG hyper::client::pool] pooling idle connection for ("http", 796285560210.coloc.huobi.com)
[2020-12-17T07:35:59.499358Z TRACE want] signal: Want
[2020-12-17T07:35:59.499361Z TRACE hyper::proto::h1::conn] flushed({role=client}): State { reading: Init, writing: Init, keep_alive: Idle }
[2020-12-17T07:35:59.499370Z TRACE hyper::client::pool] take? ("http", 796285560210.coloc.huobi.com): expiration = Some(90s)
[2020-12-17T07:35:59.499375Z DEBUG hyper::client::pool] reuse idle connection for ("http", 796285560210.coloc.huobi.com)
[2020-12-17T07:35:59.499380Z TRACE hyper::proto::h1::role] encode_headers
[2020-12-17T07:35:59.499383Z TRACE hyper::proto::h1::role] -> encode_headers
[2020-12-17T07:35:59.499385Z TRACE hyper::proto::h1::role] Client::encode method=POST, body=Some(Known(171))
[2020-12-17T07:35:59.499391Z TRACE hyper::proto::h1::role] <- encode_headers
[2020-12-17T07:35:59.499394Z TRACE hyper::proto::h1::role] -- encode_headers
[2020-12-17T07:35:59.499396Z TRACE hyper::proto::h1::encode] sized write, len = 171
[2020-12-17T07:35:59.499405Z DEBUG hyper::proto::h1::io] flushed 529 bytes
[2020-12-17T07:35:59.499410Z TRACE hyper::proto::h1::conn] flushed({role=client}): State { reading: Init, writing: KeepAlive, keep_alive: Busy }
[2020-12-17T07:35:59.523475Z TRACE hyper::proto::h1::conn] Conn::read_head
[2020-12-17T07:35:59.523487Z DEBUG hyper::proto::h1::io] read 517 bytes
[2020-12-17T07:35:59.523492Z TRACE hyper::proto::h1::role] parse_headers
[2020-12-17T07:35:59.523495Z TRACE hyper::proto::h1::role] -> parse_headers
[2020-12-17T07:35:59.523500Z TRACE hyper::proto::h1::role] Response.parse([Header; 100], [u8; 517])
[2020-12-17T07:35:59.523506Z TRACE hyper::proto::h1::role] Response.parse Complete(456)
[2020-12-17T07:35:59.523516Z TRACE hyper::proto::h1::role] <- parse_headers
[2020-12-17T07:35:59.523520Z TRACE hyper::proto::h1::role] -- parse_headers
[2020-12-17T07:35:59.523522Z DEBUG hyper::proto::h1::io] parsed 12 headers
[2020-12-17T07:35:59.523524Z DEBUG hyper::proto::h1::conn] incoming body is chunked encoding
[2020-12-17T07:35:59.523529Z TRACE hyper::proto::h1::decode] decode; state=Chunked(Size, 0)
[2020-12-17T07:35:59.523534Z TRACE hyper::proto::h1::decode] Read chunk hex size
[2020-12-17T07:35:59.523540Z TRACE hyper::proto::h1::decode] Read chunk hex size
[2020-12-17T07:35:59.523544Z TRACE hyper::proto::h1::decode] Read chunk hex size
[2020-12-17T07:35:59.523549Z TRACE hyper::proto::h1::decode] Chunk size is 55
[2020-12-17T07:35:59.523554Z DEBUG hyper::proto::h1::decode] incoming chunked header: 0x37 (55 bytes)
[2020-12-17T07:35:59.523559Z TRACE hyper::proto::h1::decode] Chunked read, remaining=55
[2020-12-17T07:35:59.523565Z TRACE hyper::proto::h1::conn] flushed({role=client}): State { reading: Body(Chunked(BodyCr, 0)), writing: KeepAlive, keep_alive: Busy }
[2020-12-17T07:35:59.523573Z DEBUG reqwest::async_impl::client] response '200 OK' for http://796285560210.coloc.huobi.com/v1/order/orders/place?AccessKeyId=xxxxxxxxxxxxxxxxxxx&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2020-12-17T07%3A35%3A59&Signature=jX3RC%2Byuh8X5a%2BDhRRHh0k3spO7UeLlbB%2FXiXbaI9rA%3D
[2020-12-17T07:35:59.523587Z TRACE hyper::proto::h1::conn] flushed({role=client}): State { reading: Body(Chunked(BodyCr, 0)), writing: KeepAlive, keep_alive: Busy }
[2020-12-17T07:35:59.523591Z TRACE reqwest::blocking::wait] wait at most 30s
[2020-12-17T07:35:59.523612Z TRACE hyper::proto::h1::decode] decode; state=Chunked(BodyCr, 0)
[2020-12-17T07:35:59.523617Z TRACE hyper::proto::h1::decode] Read chunk hex size
[2020-12-17T07:35:59.523617Z TRACE reqwest::blocking::wait] (ThreadId(1)) park timeout 29.999980621s
[2020-12-17T07:35:59.523621Z DEBUG hyper::proto::h1::io] read 20 bytes
[2020-12-17T07:35:59.523635Z TRACE hyper::proto::h1::decode] Read chunk hex size
[2020-12-17T07:35:59.523640Z TRACE hyper::proto::h1::decode] Chunk size is 10
[2020-12-17T07:35:59.523645Z DEBUG hyper::proto::h1::decode] incoming chunked header: 0xA (10 bytes)
[2020-12-17T07:35:59.523650Z TRACE hyper::proto::h1::decode] Chunked read, remaining=10
[2020-12-17T07:35:59.523658Z TRACE hyper::proto::h1::conn] flushed({role=client}): State { reading: Body(Chunked(BodyCr, 0)), writing: KeepAlive, keep_alive: Busy }
[2020-12-17T07:35:59.523663Z TRACE hyper::proto::h1::decode] decode; state=Chunked(BodyCr, 0)
[2020-12-17T07:35:59.523667Z TRACE hyper::proto::h1::decode] Read chunk hex size
[2020-12-17T07:35:59.523671Z TRACE hyper::proto::h1::decode] Read chunk hex size
create_order Elapsed time: 24.381ms |
Cool, that helps zoom us in a bit, thanks! So, there's a delay between flushing the request and reading the response. The next thing to determine is: did the server take that long to respond, or did we miss a wakeup somehow? I think if you turn on the logs for |
How to turn on the logs for mio and tokio, I use this method does not work. RUST_LOG=trace cargo run --release --bin test_huobi_spot_order |
I wild guess: HTTP pipelining and naggle's algorithm + delayed ACKs? |
I also have similar issue with nodejs I am able to send ~2K requests however using reqwest after about 100 requests remaining start reporting timeouts @seanmonstar I am using async client |
Why does the performance of reqwest fluctuate so much? There is no such problem when using nodejs to make the same request.
rust version: 1.50.0 nightly
os: ubuntu server 20.04.1
intel 16 cores 3.6Ghz, and 32G mem.
Command:
cargo run --release
[profile.release]
lto = true
codegen-units = 1
[dependencies.reqwest]
version = "0.10.9"
default-features = false
features = ["blocking", "gzip", "json", "rustls-tls-native-roots"]
rust code:
Result:
The text was updated successfully, but these errors were encountered: