Crow icon indicating copy to clipboard operation
Crow copied to clipboard

HTTP/2 support

Open The-EDev opened this issue 5 years ago • 21 comments

in response to https://github.com/ipkn/crow/issues/47, https://github.com/ipkn/crow/issues/219, https://github.com/ipkn/crow/issues/292.

I'm not sure how to go about this, a good place to start implementing would be the comments of the issues themselves, and maybe we could also take a look at this to further understand how to implement the standard fully.

The-EDev avatar Oct 08 '20 12:10 The-EDev

This is starting to seem like a rabbit hole with no end.

Ignoring the 49% adoption of HTTP/2 after 5 years of its release (not even announcement), and the controversy surrounding it and SPDY (with things like server push, and slowing load-balancers due to HPACK).

The http_parser we currently have does not support HTTP/2, and neither does the NGINX parser we proposed switching to, instead NGINX have a separate module to handle everything HTTP/2, which could be useful. But the point that it's a large pain, with lots of code to rewrite, for a seemingly slightly faster protocol that still relies on HTTP/1.1 to establish a connection.

Don't get me wrong, I do think HTTP/2 has a place, things like server push (while making me think about what servers can send without clients asking) have their place, and I would be working on HTTP/2 support 100% If we had 5 or 6 part time people supporting all the other features and bugs. But as it stands, I'm just not sure HTTP/2 is so important it's worth spending one or more months getting initial support working and then even more time maintaining 2 protocols instead of 1.

This is an email to the IETF that partially shaped my answer, the rest of the answer was shaped by the spec itself (mainly how much needs to be rewritten or changed to accommodate this new protocol that isn't very new or all that much faster than 1.1).

The-EDev avatar Nov 01 '20 03:11 The-EDev

@The-EDev I personally don't think HTTP/2 is important to crow due to reasons I mentioned in #88 .

I would say it is much simpler and more benefitial to implement fastCGI instead

NobodyXu avatar Dec 28 '20 08:12 NobodyXu

Besides, IETF is soon going to publish their HTTP/3 (QUIC) which many might want to migrate to as it improve performance of web under 4G and allows google to have more control over the stack since QUIC is based on UDP.

NobodyXu avatar Dec 28 '20 08:12 NobodyXu

http/1.1 is enough for simple application writen in crow and for programmers to debug their own code writen in crow.

NobodyXu avatar Dec 28 '20 08:12 NobodyXu

If user really wants to integrate their reverse proxy server and content server, we can make crow qualified to become a nginx plugin.

In this way, we 'get' http/2.0 (and possibly http/3.0) support for free.

NobodyXu avatar Dec 28 '20 08:12 NobodyXu

Some new information I found out that makes HTTP/2 easier to set up (and even less useful):

HTTP/2 does not actually modify the structure of an HTTP message in any meaningful way, it only modifies the way a TCP connection is handled (multiplexing + server pushing) and adds a layer on top for sending data (using frames instead of just sending data directly through the TCP connection).

This means that the same HTTP parser can be used. but the res_push would need to be finalized and the http_connection object would need to be modified to accommodate the way HTTP/2 works

The-EDev avatar Apr 13 '21 13:04 The-EDev

Any updates on this or even HTTP/3 development?

patlecat avatar May 22 '23 08:05 patlecat

unfortunately not, several other features take precedence over HTTP/2, things like asynchronous request handlers

The-EDev avatar May 22 '23 10:05 The-EDev

@The-EDev It's just that in 2023 I can't justify to use a non-HTTPS/2 or /3 solution anymore.

patlecat avatar May 26 '23 12:05 patlecat

Well one way to get HTTP/2 support would be to connect Crow to Apache or Nginx as a reverse proxy, although since Crow's logic doesn't allow for things like duplexing the benefits would still be somewhat limited.

The-EDev avatar Jun 01 '23 06:06 The-EDev

@The-EDev Yes I have an idea how to get HTTP/2 without Crow ;) but seriously adopting HTTP/3 would be a smart move now methinks. It's coming.

patlecat avatar Jun 01 '23 13:06 patlecat

I'll gladly help out with all my knowledge about Crow if anyone's willing to take on the work required to adopt HTTP/2 or 3, either through a separate library or as an addition to Crow, but with my current time it's very difficult to justify such a massive change that the majority of people don't actually notice.

The-EDev avatar Jun 01 '23 15:06 The-EDev

@patlecat You might as well use a different framework, such as axum or other frameworks that uses hyper, a http library that supports https and working on supporting http3.

NobodyXu avatar Jun 01 '23 15:06 NobodyXu

@NobodyXu Yeah but why would I want to use Rust? There aren't many easy to use HTTP-libs around for C++ sadly.

patlecat avatar Jun 12 '23 13:06 patlecat

@NobodyXu Yeah but why would I want to use Rust?

Because:

There aren't many easy to use HTTP-libs around for C++ sadly.

Plus writing Rust is a much more pleasant experience than C++, you won't have SIGSEGV unless you use unsafe.

Sum-type is really useful for expressing errors and different situations.

NobodyXu avatar Jun 12 '23 13:06 NobodyXu

I'll gladly help out with all my knowledge about Crow if anyone's willing to take on the work required to adopt HTTP/2 or 3, either through a separate library or as an addition to Crow, but with my current time it's very difficult to justify such a massive change that the majority of people don't actually notice.

Adapting to HTTP/2 or /3 isn't a user visible feature. Most people will never even understand what the differences are. But for companies serving thousands of requests per seconds this is an existiential difference.

patlecat avatar Jun 19 '23 15:06 patlecat

@patlecat could you please elaborate on how HTTP/2 and HTTP/3 benefit larger scale applications?

The-EDev avatar Jun 19 '23 18:06 The-EDev

@The-EDev By the performance increase of bundling several requests and by the decreased time it needs to establish the initial handshakes. With a few dozen requests per second that may not make a big differences but with many thousands or more it adds up considerably and this would save time and money (not the least with HW). It's the reason why some companies install a proxy server only to process the HTTPS tasks that took too much time on the main app server. Roughly.

patlecat avatar Jun 20 '23 13:06 patlecat

@patlecat could you please elaborate on how HTTP/2 and HTTP/3 benefit larger scale applications?

As I know GraphQL's subscription feature require server push (tell me if I wrong) and we can implement our own subscription features.

ffreality avatar Apr 09 '24 14:04 ffreality