Does changing the protocol of the aws alb taraget group to http2 improve the speed? And how to set it up?

0

I know that changing from http1 to http2 improves the speed.

So I allowed alb and cloudfront to be http2. In the developer tools of the Chrome browser, I confirmed that the protocol was h2 and http2 was applied.

However, after searching for stalled, there was an opinion that changing the protocol of the aws elb target group to http2 would improve stalled and improve speed. So I changed the protocol to http2 with the same settings as http1, but a 502 error occurred. (When connecting to a random port (eg: 8080 port) with the load balancer dns address) There was no error in the http1.1 setting.

The question is, if h2 is displayed when checking the protocol in the browser, is it applied to http2 or should the target group protocol be set to http2 internally? If I need to set it up, how can I avoid getting a 502 error?

1回答
0
承認された回答

When you enable ALB target group protocol as HTTP/2 you need to make sure that target support protocol version HTTP/2 as well. For example if you are using nginx you can update server section as :

server {
        listen       80 http2 ;
        listen       [::]:80 ;

If server is not configured to support protocol version, Target will send 400 bad request to ALB as ALB was making HTTP/2 request. Tested this on my env and packet capture on target show below response towards ALB.

PRI * HTTP/2.0
HTTP/1.1 400 Bad Request
Server: nginx/1.20.0
Date: Thu, 23 Feb 2023 05:06:42 GMT
Content-Type: text/html
Content-Length: 157
Connection: close

<html>
<head><title>400 Bad Request</title></head>
<body>
<center><h1>400 Bad Request</h1></center>
<hr><center>nginx/1.20.0</center>
</body>
</html>

Request packet from ALB to Target: Enter image description here

As the ALB get this 400 Bad request from target it can generate 502 back to the client.

If you have already configured your Target for HTTP2, then you can check other possible reasons for 502 here.

As far as performance , you can get the benefit of compressed header when you have end to end HTTP2, which can save some data transfer cost.

profile pictureAWS
navaz
回答済み 1年前
profile picture
エキスパート
レビュー済み 1ヶ月前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ