Skip to content

http2 seems to be slow #1365

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

Open
KMantas opened this issue Jul 28, 2020 · 3 comments
Open

http2 seems to be slow #1365

KMantas opened this issue Jul 28, 2020 · 3 comments
Labels
package:http2 type-enhancement A request for a change that isn't a bug

Comments

@KMantas
Copy link

KMantas commented Jul 28, 2020

Hi

I have tested speed of http2 library and it is much slower comparing to http. I tested with client and server being on my local. Server is written in Go and client in Dart. To downloaded 100mb file with HttpClient it takes 4s and http2 takes 15s.
I faced this issue with GRPC. We are downloading files with GRPC streams and speed depending on how far the server is, can be 8 times slower comparing to http download. I was trying to isolate the issue and it seems http2 package seems to be the main problem.
I have Dart VM version: 2.8.4
and tested with
http2: ^1.0.0
http: ^0.12.2

I used the code from "minimal example" to download file with http2. Is there a way to improve speed?

@FrantisekGazo
Copy link

Any update on this?

@thamarakshan-pilla
Copy link

Any update on this yet??

@Neronse
Copy link

Neronse commented Aug 4, 2022

Seems like problem is not in http2 package.
I noticed that sending photo is slow too.
Sending bytes to outgoing stream is fast enough, but when we start listen incoming stream, first header frame received only after 10s+. Looks like problem may be in raw socket.
I have found this issue for dart socket dart-lang/sdk#48210, may be where the same problem.

I also want to note that the problem is serious for http 2 in dart. All native solutions are faster.

UPD:
My problem wasnt in http2 package, or socket.
I am using Dio and write http2 adapter. And all open source adapters implemented like this https://github.com/flutterchina/dio/blob/master/plugins/http2_adapter/lib/src/http2_adapter.dart#L75
They are sending data messages with 1 byte inside.
When i refactored this code, speed of sending becomes `normal.

 final bytes = BytesBuilder(copy: false);
      final completer = Completer<Uint8List>.sync();
      requestStream.listen(
        bytes.add,
        onError: completer.completeError,
        onDone: () => completer.complete(bytes.takeBytes()),
        cancelOnError: true,
      );
      final collectedBytes = await completer.future;
      stream.sendData(collectedBytes);

@mosuem mosuem added the type-enhancement A request for a change that isn't a bug label Jun 12, 2024
@mosuem mosuem transferred this issue from dart-archive/http2 Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package:http2 type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

5 participants