My Profile Photo

Sheogorath's Blog

Nginx Connection Limits

Today I learned that nginx connection limits for HTTP/2 and HTTP/3 are not actually counting TCP connections, but concurrent requests, as described in the documentation. While for HTTP/1.0 and HTTP/1.1 browsers usually open up to 8 connections, in HTTP/2 a browser usually opens just 1 connection and uses streams to multiplex requests. The standard doesn’t define a simultaneous streams. Browsers like Firefox limit concurrent streams to 100, according to an answer on StackOverflow. Either way, this means that setting connection limits below 100 will potentially break websites.

I came across this issues while configuring rate-limits for Immich. Since I didn’t explicitly consult the documentation, which has a note in large letters hinting at the problem, I set the connection limits to 10, which resulted in various resources failing to load, despite request-per-minute and request-per-second budgets being not exceeded. The logs showed that the connection limit was the problem, which causes some confused, due to the way HTTP/2 works vs. how nginx redefined the meaning of connection limits.