Browser and Apache Web Server Architecture · Web Technology

Web Server Architecture

Watch lectures

Web Server Architecture

1. What is a Web Server?

A web server is hardware + software that stores web content (HTML, images, scripts) and serves it to clients over HTTP/HTTPS. It listens on port 80 (HTTP) / 443 (HTTPS), accepts requests, processes them (statically or via server-side code), and returns responses.

Examples: Apache HTTP Server, Nginx, Microsoft IIS, Apache Tomcat (servlet container), Node.js, LiteSpeed.

2. Client–Server Interaction

 CLIENT (Browser)                                WEB SERVER
 +-------------+   1. DNS lookup (name -> IP)    +----------------+
 |             | ------------------------------->| DNS Server      |
 |             |                                 +----------------+
 |             |   2. TCP connect (3-way)        +----------------+
 |             | <------------------------------ | Server:80      |
 |             |   3. HTTP GET /index.html       |  -listener     |
 |             | ------------------------------->|  -handler      |
 |             |   4. HTTP/1.1 200 OK + HTML     |  -logging      |
 |             | <-------------------------------|                |
 | 5. parse &  |   6. GET /style.css, /logo.jpg  |  (static files |
 |    render   | <------------------------------>|   or app code) |
 +-------------+                                 +----------------+

3. Core Components / Functions of a Web Server

Component Function
Listener (socket) Binds to TCP ports 80/443 and accepts connections (multiplexed or thread-per-connection)
Request parser Reads the HTTP request line, headers (Host, Cookie, Accept, Content-Length) and body; validates syntax
URL → resource mapper Maps URL to a file path, virtual host, or application handler (docroot, alias, URL rewriting)
Security / access control Authentication (Basic, Digest, form), authorisation (IP allow/deny, .htaccess), SSL/TLS termination
Static content handler Reads a file from the document root and sends it with correct MIME type
Dynamic content interface Hands requests to application code — CGI, FastCGI, Servlet container (Tomcat), PHP module, proxy to app server
Logging Access log (common/combined format) and error log for every request
Cache / performance features Keep-alive, caching headers, compression (gzip/deflate), load balancing

4. Architectures / Threading Models

Model Working Used by
Forking / process-per-connection A new process serves each connection Traditional Apache prefork (CGI era)
Thread-per-connection Lightweight threads within one process Apache worker, Tomcat default
Event-driven / asynchronous Single (or few) event loop(s) handle many connections Nginx, Node.js, Apache event MPM
Hybrid Process pool + event loops per process Modern Apache 2.4 event MPM
   prefork:   [master] -> child1, child2, child3 ... (1 connection/child)
   worker:    [parent] -> child{thread-pool serving many connections}
   event:     [parent] -> child{event-loop; keep-alive connections parked}

Scalability features: keep-alive (reuse TCP), pipelining, HTTP/2 multiplexing, gzip compression, ETag/Last-Modified caching, virtual hosting (many sites on one IP), reverse proxying.

5. Static vs Dynamic Serving

 Browser --> Web server --> static file (docroot/index.html)      [STATIC]
 Browser --> Web server --> app layer (JSP/Servlet/PHP) --> DB    [DYNAMIC]
                              |
                     application server (Tomcat/WebLogic)

6. Apache Tomcat in the Picture

Tomcat is a servlet/JSP container that implements the request-processing pipeline: connector (Coyote, HTTP/AJP) → engine → virtual host → context (web-app) → wrapper (servlet) → filters → servlet service() → response. (Detail in the Configuration of Apache Tomcat topic.)

7. Typical Request Handling Sequence (Apache)

  1. Client opens TCP connection; the listener accepts it.
  2. Request is parsed; virtual host chosen by the Host header.
  3. URL is mapped (alias, mod_rewrite, directory index DirectoryIndex).
  4. Access control & authentication (Require, .htaccess) are applied.
  5. MIME type decided; static file served, or handler invoked (CGI/PHP/proxy).
  6. Response headers (Content-Type, Content-Length, Set-Cookie, Cache-Control) + body sent.
  7. Connection kept alive or closed; entry written to access_log; errors to error_log.

8. Exam Points

  • Explain the architecture of a web server with a diagram (listener, parser, handler, dynamic interfaces, logging) — 10 marks (very frequent).
  • Compare process, thread and event-driven server models with examples — 5-7 marks.
  • List the functions/roles of a web server — 5 marks.
  • Explain how a dynamic request is processed end-to-end (browser → server → app → DB) — 7 marks.
Free AppAndroid App

Coursify Android App

Generate AI courses, take quick quizzes between classes, and master complex engineering concepts on the go.

← All Web Technology modules