Skip to main content

Virtual hosting and HTTP connections

Short answer

Virtual hosting serves multiple domains on one server using IP, port, or the Host header (name-based). HTTP connections may be non-persistent (separate TCP per object, ~2 RTT) or persistent (keep-alive, pipelining reduces total delay to ~1 RTT).

What is virtual hosting? Explain the HTTP connections with respect to web access.

Virtual hosting

Virtual hosting is hosting more than one web site (domain name) on a single web server machine, so that each site appears to have its own server. It reduces cost and IP address use. The methods are IP-based, port-based and name-based (the server picks the site from the HTTP Host: header). Example in Apache: two <VirtualHost *:80> blocks with ServerName www.a.com and ServerName www.b.com.

HTTP connections

A web page has a base HTML file plus many objects (images, CSS, scripts). How TCP connections are used for them matters for delay.

1. Non-persistent connection (HTTP/1.0 default)

  • A separate TCP connection is made for each object and closed after the response.
  • Each object costs 2 RTT (one for TCP handshake, one for request/response) plus transmission time.
  • Browsers can open several parallel connections to reduce delay, but this loads the server and network.

2. Persistent connection (HTTP/1.1 default)

  • The server leaves the TCP connection open after replying (Connection: keep-alive) and closes it after a timeout or on Connection: close.
  • Several objects use the same connection, saving handshakes and slow-start.
    • Without pipelining: the client sends a new request only after receiving the previous response; about 1 RTT per object.
    • With pipelining: the client sends requests back-to-back without waiting; as little as about 1 RTT for all objects.
 Non-persistent             Persistent
 SYN/SYN-ACK  (RTT)         SYN/SYN-ACK  (RTT)
 GET obj1     (RTT)         GET obj1 / obj2 / obj3
 close                      ... same connection ...
 SYN/SYN-ACK  (RTT)         close after timeout
 GET obj2     (RTT)
PointNon-persistentPersistent
Connections for n objectsn1 (or few)
Delay per object~2 RTT~1 RTT or less
Server resourcesMore (many sockets)Less

HTTP/2 goes further by multiplexing many requests on one connection.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Internet and Intranet chapter 4 questions →