The C10K problem

来源:互联网 发布:成都 程序员版 编辑:程序博客网 时间:2024/05/23 01:57

原文链接:http://www.kegel.com/c10k.html

It's time for web servers to handle ten thousand clients simultaneously,don't you think? After all, the web is a big place now.

And computers are big, too. You can buy a 1000MHz machinewith 2 gigabytes of RAM and an 1000Mbit/sec Ethernet card for $1200 or so. Let's see - at 20000 clients, that's50KHz, 100Kbytes, and 50Kbits/sec per client. It shouldn't take any more horsepower than that to take four kilobytes from the disk and send them to the network once a second for eachof twenty thousand clients.(That works out to $0.08 per client, by the way. Those$100/client licensing fees some operating systems charge are starting to look a little heavy!) So hardware is no longer the bottleneck.

In 1999 one of the busiest ftp sites, cdrom.com, actually handled 10000 clients simultaneouslythrough a Gigabit Ethernet pipe.As of 2001, that same speed is nowbeing offered by several ISPs,who expect it to become increasingly popular with large business customers.

And the thin client model of computing appears to be coming back instyle -- this time with the server out on the Internet, servingthousands of clients.

With that in mind, here are a few notes on how to configure operating systems and write code to support thousands of clients. The discussioncenters around Unix-like operating systems, as that's my personal areaof interest, but Windows is also covered a bit.

Contents

  • The C10K problem
  • Related Sites
  • Book to Read First
  • I/O frameworks
  • I/O Strategies
    1. Serve many clients with each thread, and use nonblocking I/O andlevel-triggered readiness notification
      • The traditional select()
      • The traditional poll()
      • /dev/poll (Solaris 2.7+)
      • kqueue (FreeBSD, NetBSD)
    2. Serve many clients with each thread, and use nonblocking I/O and readinesschange notification
      • epoll (Linux 2.6+)
      • Polyakov's kevent (Linux 2.6+)
      • Drepper's New Network Interface (proposal for Linux 2.6+)
      • Realtime Signals (Linux 2.4+)
      • Signal-per-fd
      • kqueue (FreeBSD, NetBSD)
    3. Serve many clients with each thread, and use asynchronous I/O and completion notification
    4. Serve one client with each server thread
      • LinuxThreads (Linux 2.0+)
      • NGPT (Linux 2.4+)
      • NPTL (Linux 2.6, Red Hat 9)
      • FreeBSD threading support
      • NetBSD threading support
      • Solaris threading support
      • Java threading support in JDK 1.3.x and earlier
      • Note: 1:1 threading vs. M:N threading
    5. Build the server code into the kernel
  • Comments
  • Limits on open filehandles
  • Limits on threads
  • Java issues [Updated 27 May 2001]
  • Other tips
    • Zero-Copy
    • The sendfile() system call can implement zero-copy networking.
    • Avoid small frames by using writev (or TCP_CORK)
    • Some programs can benefit from using non-Posix threads.
    • Caching your own data can sometimes be a win.
  • Other limits
  • Kernel Issues
  • Measuring Server Performance
  • Examples
    • Interesting select()-based servers
    • Interesting /dev/poll-based servers
    • Interesting epoll-based servers
    • Interesting kqueue()-based servers
    • Interesting realtime signal-based servers
    • Interesting thread-based servers
    • Interesting in-kernel servers
  • Other interesting links
原创粉丝点击