
Amazon CloudFront Now Supports HTTP/2 Connections to the Origin, So I Tried It Out
This page has been translated by machine translation. View original
Introduction
On November 23, 2026, an update was announced that adds HTTP/2 support for Amazon CloudFront connections to origins.
With HTTP/2, CloudFront can send multiple requests to the origin in parallel over a single connection. As a result, it is expected to reduce the number of connections to the origin and the cost of TLS negotiation.
This article presents the results of specifying the origin setting OriginHttpVersion and checking the HTTP version the origin receives and the number of connections in the ALB logs.
Test Environment
- Region: Tokyo (ap-northeast-1)
- Origin: ALB (2 AZs)
- Listener: HTTPS 443, ELBSecurityPolicy-TLS13-1-2-2021-06
- ALB response: fixed response (200, body ok)
- Origin domain: Route 53 alias record
- Logs: ALB access logs and connection logs delivered to CloudWatch Logs (JSON) and searched with Logs Insights
- AWS CLI: 2.42.1
Configuration
CloudFront uses HTTP/2 to the origin only when the connection to the origin is HTTPS and the minimum origin SSL protocol is TLSv1.2 or later.
OriginHttpVersion is specified in the origin's CustomOriginConfig. I saved the following content, which specifies https-only and TLSv1.2 to satisfy the conditions above, as dist-http2.json.
{
"CallerReference": "h2o-verify-http2-20261124",
"Comment": "OriginHttpVersion http2",
"Enabled": true,
"Origins": {"Quantity": 1, "Items": [{
"Id": "alb-origin",
"DomainName": "origin.example.com",
"CustomOriginConfig": {
"HTTPPort": 80, "HTTPSPort": 443,
"OriginProtocolPolicy": "https-only",
"OriginSslProtocols": {"Quantity": 1, "Items": ["TLSv1.2"]},
"OriginReadTimeout": 30, "OriginKeepaliveTimeout": 5,
"OriginHttpVersion": "http2"
}}]},
"DefaultCacheBehavior": {
"TargetOriginId": "alb-origin",
"ViewerProtocolPolicy": "https-only",
"CachePolicyId": "4135ea2d-6df8-44a3-9df3-4b5a84be39ad",
"OriginRequestPolicyId": "b689b0a8-53d0-40ab-baf2-68738e2966ac",
"AllowedMethods": {"Quantity": 2, "Items": ["GET","HEAD"]},
"Compress": false
}
}
I created a distribution from this file with the following command.
aws cloudfront create-distribution --distribution-config file://dist-http2.json
For the http1.1 side used for comparison, I created a distribution with OriginHttpVersion set to http1.1.
Test Method
The HTTP version the origin received is determined from the type and the end of request_line in the ALB access logs. The type is h2 for HTTP/2 over TLS.
For each test, I changed the beginning of the request path. Paths starting with g1 are for checking the version, and paths starting with g2 are for checking the number of connections. Because the path remains in request_line of the ALB access logs, the following Logs Insights query can narrow down to only the g1 requests.
fields @timestamp, type, request_line, elb_status_code
| filter request_line like /g1-/
| sort @timestamp asc
The number of connections is compared by the number of conn_trace_id values (an ID for each connection) in the ALB logs.
- Number of new connections: The number of connections the ALB received in each send. It is the number of conn_trace_id values in the connection logs.
- Number of connections used for requests: The number of unique conn_trace_id values in the access logs.
Test Results
HTTP version received by the origin
I sent one request to each distribution and compared the ALB access logs.
| OriginHttpVersion | type | request_line | elb_status_code |
|---|---|---|---|
| http2 | h2 | GET https://origin.example.com:443/g1-http2/001 HTTP/2.0 | 200 |
| http1.1 | https | GET https://origin.example.com:443/g1-http11/001 HTTP/1.1 | 200 |
Number of connections to the origin
I sent 200 requests simultaneously, varying the path, to distributions with caching disabled. No edge location was specified. I ran each setting three times, swapping which setting was sent first in each round.
| Round | OriginHttpVersion | New connections | Connections used for requests | type |
|---|---|---|---|---|
| 1 | http2 | 38 | 38 | h2 |
| 1 | http1.1 | 197 | 66 | https |
| 2 | http2 | 106 | 106 | h2 |
| 2 | http1.1 | 198 | 63 | https |
| 3 | http2 | 156 | 156 | h2 |
| 3 | http1.1 | 168 | 112 | https |
The number of new connections was smaller with the http2 setting in all three rounds. The number of connections used for requests was larger with the http2 setting in the second and third rounds. With the http2 setting, the two values matched, while with the http1.1 setting the number of new connections was larger.
Send script and aggregation queries
The simultaneous sending of 200 requests was run with send-requests.sh <domain> <path prefix> 200 200. For the domain, specify the CloudFront domain name (d111111abcdef8.cloudfront.net). The path prefix was changed for each setting and round: in the first round, names starting with g2-http11 and g2-http2; in the second round, names starting with g2r2-; and in the third round, names starting with g2r3-.
#!/usr/bin/env bash
# Usage: send-requests.sh <domain> <path prefix> <count> <parallelism>
# Set each request's path to <path prefix>/<sequence number> (for matching in logs)
set -euo pipefail
DOMAIN=$1; TAG=$2; N=$3; PAR=$4
cfg=$(mktemp)
for i in $(seq 1 "$N"); do
printf 'url = "https://%s/%s/%03d"\n' "$DOMAIN" "$TAG" "$i" >> "$cfg"
done
curl -sS -Z --parallel-max "$PAR" -K "$cfg" -o /dev/null \
-w '%{http_code} %{http_version} %{url_effective} x-amz-cf-id-n/a\n' --http2
rm -f "$cfg"
This is the query for the connection logs (number of new connections). Specify the search period as 19 seconds from the start of each send, and sum n.
stats count(*) as n by bin(1s)
This is the query for the access logs (number of connections used for requests). It aggregates by path prefix.
filter request_line like /g2/
| parse request_line "https://origin.example.com:443/*/" as seg
| stats count(*) as requests, count_distinct(conn_trace_id) as connections by seg, type
| sort seg
Summary
I confirmed that specifying http2 for CloudFront's origin setting OriginHttpVersion makes HTTPS communication from CloudFront to the origin (ALB) use HTTP/2.
The number of concurrent connections to the origin and the TLS load have sometimes become bottlenecks, but using HTTP/2, which is supported in this update, may help mitigate them. If you use an on-premises load balancer that supports HTTP/2 as the origin of CloudFront, please try the http2 setting.
Note that when you can expect autoscaling based on the number of concurrent connections, as with an ALB, HTTP/1.1 may sometimes perform better. If you introduce the http2 setting, we recommend evaluating it beforehand in a test environment or similar.
