Web Server Architectures
Web Server Architectures
Web Server Architectures
Design Goals
Performance & Quality of Service (Systems)
Good responsiveness; low latency Good concurrency High throughput Graceful degradation Low memory consumption
Send Data
One process sequentially handles all client connections Simple requires no synchronization Does not scale (one client at a time)
Optimizations?
Caching
Pathname translation Some dynamic content File operations
Multi-Process Architecture
Process 1
Accept Connection Parse HTTP Request
Read File or generate content
Send Data
Process N
Accept Connection Parse HTTP Request
Read File or generate content
Send Data
Utilizes multiple processors Easy to debug Can pre-fork a pool of processes Inter Process Communication is difficult and expensive High memory cost, context switches
Multi-Threaded Architecture
Accept Connection Parse HTTP Request
Read File or generate content
Send Data
Utilizes multiple threads, good performance Easy to change threading policies Need to synchronize, to avoid data races Resources utilization (kernel and user-level): Blocking I/O can cause deadlocks
Send Data
Event Dispatcher
Use a selector to check for ready file descriptors Uses a finite state machine to determine how to move to the next processing stage No context switching, no synchronization, single address space Modern OS do not provide adequate support for asynchronous disk operations
Send Data
Event Dispatcher
Helper 1
Helper N
Similar to Single Process Event-Driven but with helpers for blocking I/O (e.g., disk requests)
Performance Comparison
MP MT SPED AMPED
+
(only one proc.)
- (whole
server proc. blocks)
- (one disk
request at a time)
Hybrid Approach
SEDA: Staged Event-Driven Architecture
SEDA: An Architecture for Well-Conditioned, Scalable Internet Services, Matt Welsh, David Culler, and Eric Brewer. In Proceedings of the Eighteenth Symposium on Operating Systems Principles (SOSP-18), Banff, Canada, October, 2001.
Uses thread pools and events Events organized into stages Each stage has a thread pool Load conditioning; graceful degradation