← Back to Frontend, page 1

frontend-0002 · Medium mid

Browsers limit parallel connections per host. What are the exceptions to that limit, and how do HTTP/2 and HTTP/3 change the picture?

Under HTTP/1.1 a browser opens only a handful of connections to each host, often six, and each connection carries one request at a time. HTTP/2 and HTTP/3 multiplex many requests on one connection, so the per-host limit matters much less, and tricks such as domain sharding become harmful.

Full answer

Under HTTP/1.1, one connection handles one request and response at a time. To load a page with many files, a browser opens several connections to the same host. Chrome uses six per host. Other browsers use similar numbers, and the values can change, so treat six as a typical figure and not a rule.

The limit is the reason for several old tricks, and they are also the answer to the exception part of the question.

  • A different host name has its own limit. Splitting assets over img1.example.com and img2.example.com (domain sharding) gave more parallel downloads under HTTP/1.1. Each new host costs a DNS lookup, a TCP connection and a TLS handshake.
  • Long-lived requests use up the limit. Server-Sent Events or a long poll over HTTP/1.1 holds a connection open, and several tabs share the same limit.
  • Prefetch and preconnect can open extra connections ahead of need.

HTTP/2 changes the model. One connection carries many streams in parallel. The browser sends all requests at once, and the server interleaves the responses. The old limit is almost irrelevant for a single host. A browser can still use more than one connection, for example when requests use different credential settings or the hosts cannot be coalesced.

HTTP/3 keeps this model and replaces TCP with QUIC over UDP. A lost packet delays only the stream it belongs to, and does not stop all streams on the connection as it does in TCP.

Consequences for today:

  • Do not shard domains when serving over HTTP/2 or HTTP/3. One host with one connection is faster.
  • Bundling still helps compression and reduces request overhead, but giant bundles are no longer required for parallelism.
  • Priorities matter more than counts. Use fetchpriority and preload for the files the first paint needs.

The snippet starts an HTTP/2 server without TLS, sends 20 requests from one client and counts the connections. Browsers speak HTTP/2 only over TLS, so this Node demo shows the multiplexing idea, not browser behaviour.

javascript
import http2 from 'node:http2';

const sessions = new Set();
const server = http2.createServer((req, res) => res.end('ok ' + req.url));
server.on('session', (s) => sessions.add(s));
await new Promise((resolve) => server.listen(0, resolve));

const client = http2.connect(`http://localhost:${server.address().port}`);
const get = (path) => new Promise((resolve) => {
  const req = client.request({ ':path': path });
  let body = '';
  req.setEncoding('utf8');
  req.on('data', (c) => (body += c));
  req.on('end', () => resolve(body));
  req.end();
});

const bodies = await Promise.all(Array.from({ length: 20 }, (_, i) => get('/file' + i)));
console.log('responses:', bodies.length, 'connections:', sessions.size);
client.close();
server.close();

Run with Node 24.22.1. The output matched the text in the answer in two runs. Run with Node and the output was identical in two runs. The server uses HTTP/2 without TLS (h2c) only to keep the demo small. Browsers use HTTP/2 over TLS, and browser connection limits were not measured here.

Key points

  • HTTP/1.1 allows one request at a time per connection, so browsers open about six per host.
  • Each extra host gets its own limit but costs DNS, TCP and TLS setup.
  • HTTP/2 multiplexes many streams on one connection.
  • HTTP/3 uses QUIC, so one lost packet does not block every stream.
  • Domain sharding is a harmful habit under HTTP/2 and HTTP/3.

Common mistakes

  • Saying HTTP/2 has no limits at all. Servers set a maximum number of concurrent streams.
  • Keeping domain sharding after moving to HTTP/2.
  • Claiming the number six is fixed in a standard.
  • Forgetting that SSE or long polling over HTTP/1.1 can use the whole limit.

Follow-ups

  • What is head-of-line blocking, and does HTTP/2 fully remove it?
  • Why can a CDN on another host name still be a good idea?
  • How do you confirm in DevTools which protocol a request used?

Tips

  • Start with why the limit exists, then list the exceptions, then the protocols.
  • Say that the number is browser specific and can change.