Actix-web: h2 support in the awc is causing serious performance issues

Created on 3 Mar 2020  路  5Comments  路  Source: actix/actix-web

If you were to add the following alpn protocol configuration to this awc example, you would essentially have the same configuration as what is used by default within the awc when openssl feature flag is used:

let mut builder = SslConnector::builder(SslMethod::tls()).unwrap();
builder.set_alpn_protos(b"\x02h2\x08http/1.1").unwrap();

Running the example with the protocol declaration results in a major performance problem for https requests. The source of this issue is the use of h2. If you remove h2 from set_alpn_protos, the issue is resolved.

I don't know whether h2 works correctly for http-server but it clearly has issues with the awc. It would be useful to know whether the http-server handles h2 better.

C-bug P-awc P-http help-wanted

Most helpful comment

Looks like Dunnock fixed the issue. Great job, Dunnock! We're fortunate that the tokio community figured this problem out.

All 5 comments

Attached is a flamegraph for awc example
flamegraph-awc.svg.zip

@actix/contributors Please note this issue. This is a test of whether awc can be maintained going forward. This also may be affecting the http server as well.

@fafhrd91 fyi

It seems reqwest had a similar issue and provide some details in the issue https://github.com/hyperium/hyper/issues/1813, especially from seanmonstar:

And curiously, with hyper's new default HTTP2 window, ~875MB/s. My only guess as to why that's faster than maxing the window is that it pushes back pressure to the executor instead of the h2::Connection prioritizer juggling chunks.

Suggest we try to increase defaults as they did, will look into it
https://github.com/hyperium/hyper/blob/master/src/proto/h2/client.rs#L24-L28

BTW, actix-http::h2::Service is using default H2 parameters too, not sure if they are bad (default window size 64k sounds right for REST API, but bad for blobs)
https://github.com/actix/actix-web/blob/master/actix-http/src/h2/service.rs#L311

Looks like Dunnock fixed the issue. Great job, Dunnock! We're fortunate that the tokio community figured this problem out.

Was this page helpful?
0 / 5 - 0 ratings