how to write a good web server

Server module

  • 1.select based server
    Advantage: easy to implement
    disadvantage: limit to fd, max is 1024 on most linux
  • 2./dev/poll based server
    Advantage:
    disadvantage: same to select
  • 3.epoll based server
    Advantage: fastly, not need to check each fd.
    disadvantage: do more coding
  • 4.thread based server
    Advantage: cheap to create, easy to share memory
    disadvantage: instability, crash thread make entry process down because all
    threads share the same addres space.  
    
  • 5.process based server
    Advantage: stable, crash process do not effect others.
    disadvantage: create and kill processs overhead the web server.
  • 6.hybrid process thread server
    Advantage:
    disadvantage:
  • 7.process-pool and thread-pool based server
    process pool, reference
    dynamic-pool-of-processes
    Preforking: Process Pools
    3
    Advantage:
    disadvantage:
  • 8.event based server
    Advantage:
    disadvantage:

Biggest performance-killers

  • 1.Data copies
  • 2.Context switches
  • 3.Memory allocation
  • 4.Lock contention

Reference