Welcome! Log In Create A New Profile

Advanced

Re: [PATCH] HTTP/2: make http2 server support http1

Valentin V. Bartenev
March 04, 2018 08:02AM
On Sunday, 4 March 2018 05:53:36 MSK Haitao Lv wrote:
> Hi, wbr,
>
> Thanks for your review. I don't know why I can't receive your email.
> Let me reply directly.
>
> > It doesn't look like a useful feature.
> > Could you please explain the use cases?
>
> The current implementation support both http/1 and http/2 over the
> same TLS listen port by the ALPN Extension.
>
> Nginx also support listening http/2 over plain tcp port, which is
> perfect for development and inner production environment.
>
> However, the current implementation cannot support http/1.1 and http/2
> simultaneously. We have no choice but listen on two different ports.
> As a result, one same service has two ports and different clients
> should choose their suitable port.
>
> Besides, the http/2 is efficient, but http/1 is simple. So I see no
> chance that the http/2 will replace http/1 totally in the production
> inner environment. Will call the inner API by both http/1 and http/2.
>
> So I think support http/1 and http/2 on the plain tcp port will simplify
> both the production and development environment.
>

HTTP/2 was designed to save connection time between a client and a web
server, which can be costly with significant RTT and full TLS handshake.

Also it helps to overcome concurrency limitation in browsers, that usually
limited to 6 connection per host.

All these problems usually don't exist in inner environments.

HTTP/2 isn't efficient. In fact, it has more overhead and may require
more TCP packets to transfer the same amount of data. Moreover, more TCP
connections are usually faster than one, just because they have bigger start
window in total and less suffer from packet loss.

Please, don't be fooled by aggressive marketing around HTTP/2. Most of
such articles are written by people who barely understand how network works.
HTTP/2 is neither a better version nor the "next" version of HTTP protocol
(the name is misleading). It's an another protocol designed to solve some
specific cases, while introducing many other problems.

I don't recommend to use HTTP/2 in cases other than TLS connections between
browsers and web servers in public network. Also even for this purpose,
there are cases when HTTP/2 isn't recommended, e.g. unreliable networks
with packet loss (as mobile networks).

You can easily find on YouTube a talk by Hooman Beheshti called
"HTTP/2: what no one is telling you" with some interesting research.

nginx support HTTP/2 over plain TCP for a number of reasons:

1. for easy testing and debugging the protocol implementation in nginx;

2. that required almost no additional code to implement;

3. there's a use case when TLS termination is done by simple TCP proxy
and then the traffic routed to HTTP/1 or HTTP/2 nginx ports according
to ALPN.


>
> > What if the received data is bigger than h2mcf->recv_buffer?
>
> Yes, it is a problem. However, it can be fixed easily.
>
> As we know, the http/2 preface is PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n.
> We could modify the ngx_http_parse_request_line and when we got A PRI
> method, we need to get a single * uri. If we got things other than *,
> we just return a invalid request response. By this, we will never got
> a PRI to_much_long_uri HTTP/2.0 request line, and the buffer will not
> be exhausted. So the ngx_http_alloc_large_header_buffer will not be called
> during the handshake. After the ngx_http_parse_request_line, we will
> ensure we got a PRI request, and the buffer size is client_header_buffer_size.
>

As far as I can see, your reasoning is based on assumption that
client_header_buffer_size is always smaller than http2_recv_buffer_size.

That simply isn't true as both can be easily configured by users.

wbr, Valentin V. Bartenev

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[PATCH] HTTP/2: make http2 server support http1

Haitao Lv 509 March 02, 2018 02:54AM

Re: [PATCH] HTTP/2: make http2 server support http1

Valentin V. Bartenev 208 March 02, 2018 12:32PM

Re: [PATCH] HTTP/2: make http2 server support http1

Haitao Lv 183 March 03, 2018 10:02PM

Re: [PATCH] HTTP/2: make http2 server support http1

Haitao Lv 106 March 04, 2018 12:52AM

Re: [PATCH] HTTP/2: make http2 server support http1

Haitao Lv 92 March 04, 2018 10:12PM

Re: [PATCH] HTTP/2: make http2 server support http1

ru@nginx.com 177 March 05, 2018 04:04AM

Re: [PATCH] HTTP/2: make http2 server support http1

Haitao Lv 105 March 05, 2018 09:38AM

Re: [PATCH] HTTP/2: make http2 server support http1

Valentin V. Bartenev 119 March 05, 2018 10:08AM

Re: [PATCH] HTTP/2: make http2 server support http1

Haitao Lv 155 March 05, 2018 10:54AM

Re: [PATCH] HTTP/2: make http2 server support http1

Maxim Dounin 247 March 05, 2018 02:16PM

Re: [PATCH] HTTP/2: make http2 server support http1

Haitao Lv 139 March 05, 2018 09:22PM

Re: [PATCH] HTTP/2: make http2 server support http1

Haitao Lv 94 March 07, 2018 07:30PM

Re: [PATCH] HTTP/2: make http2 server support http1

Haitao Lv 69 March 07, 2018 07:44PM

Re: [PATCH] HTTP/2: make http2 server support http1

吕海涛 192 March 12, 2018 12:46PM

Re: [PATCH] HTTP/2: make http2 server support http1

Valentin V. Bartenev 120 March 12, 2018 01:12PM

Re: [PATCH] HTTP/2: make http2 server support http1

Haitao Lv 118 March 18, 2018 01:00PM

Re: [PATCH] HTTP/2: make http2 server support http1

Valentin V. Bartenev 84 March 20, 2018 12:04PM

Re: [PATCH] HTTP/2: make http2 server support http1

Haitao Lv 84 March 20, 2018 11:38PM

Re: [PATCH] HTTP/2: make http2 server support http1

Haitao Lv 82 April 01, 2018 08:36PM

Re: [PATCH] HTTP/2: make http2 server support http1

吕海涛 100 June 13, 2018 07:42PM

Re: [PATCH] HTTP/2: make http2 server support http1

Valentin V. Bartenev 175 March 04, 2018 08:02AM

Re: [PATCH] HTTP/2: make http2 server support http1

Haitao Lv 227 March 04, 2018 10:06PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 71
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready