dart-lang / shelf

Web server middleware for Dart
https://pub.dev/packages/shelf
BSD 3-Clause "New" or "Revised" License
919 stars 124 forks source link

Dart's http server is slowly #451

Open donywan opened 3 days ago

donywan commented 3 days ago

https://web-frameworks-benchmark.netlify.app/result

Why?

ykmnkmi commented 2 days ago

In JS, the base part of the HTTP server is implemented in native code, it's just Zig, Rust, C++ with JS bindings. In Dart case, it's all written in Dart and native socket bindings. Dart is reading all the bytes, parsing them, and putting them into the streams.

donywan commented 2 days ago

Is there any possibility of improvement?In this way, dart can also be used as a backend.

In JS, the base part of the HTTP server is implemented in native code, it's just Zig, Rust, C++ with JS bindings. In Dart case, it's all written in Dart and native socket bindings. Dart is reading all the bytes, parsing them, and putting them into the streams.

ykmnkmi commented 2 days ago

Dart is used as a backend. A 2ms vs 5ms diff is not that much. If you want to improve the standard HttpServer, take a look at http_io to experiment.

donywan commented 1 day ago

I tested it with the standard HttpServer and the throughput was indeed too low.