1
Servers: Concurrency and Performance
Jeff Chase Duke University
HTTP Server
- HTTP Server
– Creates a socket (socket) – Binds to an address – Listens to setup accept backlog – Can call accept to block waiting for connections
– (Can call select to check for data on multiple socks)
- Handle request
– GET /index.html HTTP/1.0\n <optional body, multiple lines>\n \n
Inside your server
packet queues listen queue accept queue Server application (Apache, Tomcat/Java, etc)
Measures
- ffered load
response time throughput utilization
Example: Video On Demand
Client() { fd = connect(“server”); write (fd, “video.mpg”); while (!eof(fd)) { read (fd, buf); display (buf); } }
Server() { while (1) { cfd = accept(); read (cfd, name); fd = open (name); while (!eof(fd)) { read(fd, block); write (cfd, block); } close (cfd); close (fd); } [MIT/Morris]
How many clients can the server support? Suppose, say, 200 kb/s video on a 100 Mb/s network link?
Performance “analysis”
- Server capacity:
– Network (100 Mbit/s) – Disk (20 Mbyte/s)
- Obtained performance: one client stream
- Server is limited by software structure
- If a video is 200 Kbit/s, server should be able to
support more than one client.
[MIT/Morris]
500?
WebServer Flow
TCP socket space state: listening address: {*.6789, *.*} completed connection queue: sendbuf: recvbuf:
128.36.232.5 128.36.230.2
state: listening address: {*.25, *.*} completed connection queue: sendbuf: recvbuf: state: established address: {128.36.232.5:6789, 198.69.10.10.1500} sendbuf: recvbuf:
connSocket = accept() Create ServerSocket read request from connSocket read local file write file to connSocket close connSocket Discussion: what does step do and how long does it take?