hjr3 / weldr

A HTTP 1.1 proxy written in Rust using tokio.
Apache License 2.0
217 stars 20 forks source link

Replace all HTTP parsing logic with hyper #53

Closed hjr3 closed 7 years ago

hjr3 commented 7 years ago

There will still need to be some gateway specific HTTP logic. The linking of the frontend to the backend is very basic at the moment.

Using hyper also fixed some issues:

Fixes #11 Fixes #12

To do:

hjr3 commented 7 years ago

I am almost done with converting the tests. The hyper client body response is itself a future (stream), which means I have to do some work to collect it all and present it back as a normal String so tests can sanely assert against it. I also want @yanns to take a look at my new test harness. I don't love it, but I am not sure I can do better.

The good news is that I have fixed a number of outstanding issues as part of this conversion. This could bring us much closer to a 0.1 release.

yanns commented 7 years ago

The tests look good! When I tested the Server-Send-Events, it works. But it is much slower than the implementation without hyper. I guess that hyper makes a response for each event instead of letting them grouped.

hjr3 commented 7 years ago

@yanns thanks for the review. I was able to get the tests back into almost the exact same form. With regards to performance, I have a few thoughts:

  1. Sean said he is aware of some hyper performance issues and is working on fixing those. I specifically talked about the perf challenges when trying to optimize the amount of allocations between the frontend and backend.
  2. We had an incomplete version of the HTTP standard. I think we would have seen some performance decreases even if we stayed with our own internal HTTP library.
  3. Swapping in hyper was quite easy. Most of the work was updating the integration tests to use the tokio version of hyper. I think we would have done this regardless. If we get to a point where hyper is blocking us on perf issues, we can swap back in the internal HTTP library and work on getting it to conform with the HTTP standard.

I created https://github.com/hjr3/alacrity/issues/54 so we can add some benchmarks and keep better track of this too.