12.35

    see origin tiny server in section 11.6 on book

    the key is close(connfd) in both parent and child process to ensure close fd
    and reuse it or it’ll failed: Accept error: too many open files

    1. !INCLUDE "./code/12.35.c.diff"

    run server

    1. (cd chapter12/code; make && ./12.35)

    open another terminal and benchmark it

    1. wrk -d4 http://localhost:5000

    output

    1. Running 4s test @ http://localhost:5000
    2. 2 threads and 10 connections
    3. Thread Stats Avg Stdev Max +/- Stdev
    4. Latency 62.20ms 87.89ms 348.01ms 82.24%
    5. Req/Sec 397.69 184.95 767.00 58.33%
    6. 2585 requests in 4.00s, 578.09KB read
    7. Requests/sec: 645.64
    8. Transfer/sec: 144.39KB