Is there a limit on the length of URLs when using Amazon ELBs? If so, is there a way to increase it?

Solution 1:

I tested this with a simple bash script against a domain I have running behind an ELB:

S='a';
URL='http://example.com/?foo=';
while true;
do
  echo $URL$S | wc -c;
  curl -I "$URL$S";
  S=$S$S;
done

This worked fine for a while:

2081
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Date: Tue, 05 Feb 2013 15:01:44 GMT
Server: Apache/2.2.22 (Ubuntu)
Vary: Accept-Encoding
Connection: keep-alive

4129
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Date: Tue, 05 Feb 2013 15:01:46 GMT
Server: Apache/2.2.22 (Ubuntu)
Vary: Accept-Encoding
Connection: keep-alive

But failed once it crossed the 8192 length barrier:

8225
HTTP/1.1 414 Request-URI Too Large
Content-length: 337
Content-Type: text/html; charset=iso-8859-1
Date: Tue, 05 Feb 2013 15:01:47 GMT
Server: Apache/2.2.22 (Ubuntu)
Vary: Accept-Encoding
Connection: keep-alive

16417
HTTP/1.1 414 Request-URI Too Large
Content-length: 337
Content-Type: text/html; charset=iso-8859-1
Date: Tue, 05 Feb 2013 15:01:47 GMT
Server: Apache/2.2.22 (Ubuntu)
Vary: Accept-Encoding
Connection: keep-alive

The failing requests were logged in a different file by Apache because the GET string comes before the Host: header and hence Apache didn't ever determine which vhost to use.

Nonetheless, it was still Apache responding, and not the ELB, even up to over 128KB in a single GET string. The full 128KB request was logged in the default Apache log file. After 256KB, curl failed to process the request.

It doesn't look like there's any URL length limit in Amazon ELBs.

Solution 2:

We received the following answer from AWS Support (formatting mine):

Kindly note that there is a limit for the URI length for all load balancers and as you are getting the 414 error, your GET request must be exceeding the below limit.

Application Load Balancer (ALB)

For the ALB, there is a difference in the HTTP Header Limits for HTTP/1.x headers and HTTP/2 headers. Please see the documentation on HTTP Header Limits.

HTTP/1.x headers for Application Load Balancers have the following size limits:

  • Request line: 16K
  • Single header: 16K
  • Whole header: 64K

HTTP/2 headers for Application Load Balancers have the following size limits:

  • Request line: 8K
  • Single header: 8K
  • Whole header: 64K

Classic Load Balancer (CLB)

The only limit that the CLB imposes is the length of the HTTP verb (GET, POST, etc), and this has to be 127 Bytes or less, any verb larger than this will cause the CLB to return an HTTP error 405 "METHOD_NOT_ALLOWED".

Network load balancer (NLB)

As NLB functions at the fourth layer of the Open Systems Interconnection (OSI) model, there is no limit for HTTP header. It attempts to open a TCP connection to the selected target on the port specified in the listener configuration.

Tags:

Url

Amazon Elb