jeremycw / httpserver.h

Single header library for writing non-blocking HTTP servers in C
MIT License
1.78k stars 143 forks source link

Benchmark hardware question #37

Closed travisbrady closed 4 years ago

travisbrady commented 4 years ago

I have a brief question about the kind of hardware you ran the benchmark in the readme on. I tried the same on my local 2016 era Macbook pro and my avg req/sec are dramatically different.

Am I compiling correctly? Or is this just my laptop being terrible?

Results (mean of 8200 req/sec):

$ ab -k -c 200 -n 100000 http://127.0.0.1:8080/
This is ApacheBench, Version 2.3 <$Revision: 1807734 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)
Completed 10000 requests
Completed 20000 requests
Completed 30000 requests
Completed 40000 requests
Completed 50000 requests
Completed 60000 requests
Completed 70000 requests
Completed 80000 requests
Completed 90000 requests
Completed 100000 requests
Finished 100000 requests

Server Software:
Server Hostname:        127.0.0.1
Server Port:            8080

Document Path:          /
Document Length:        13 bytes

Concurrency Level:      200
Time taken for tests:   12.165 seconds
Complete requests:      100000
Failed requests:        0
Keep-Alive requests:    100000
Total transferred:      13400000 bytes
HTML transferred:       1300000 bytes
Requests per second:    8220.54 [#/sec] (mean)
Time per request:       24.329 [ms] (mean)
Time per request:       0.122 [ms] (mean, across all concurrent requests)
Transfer rate:          1075.73 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   1.8      0      42
Processing:     1   24   2.0     24      56
Waiting:        1   24   2.0     23      56
Total:          1   24   3.0     24      83

Percentage of the requests served within a certain time (ms)
  50%     24
  66%     24
  75%     24
  80%     25
  90%     27
  95%     29
  98%     30
  99%     31
 100%     83 (longest request)
jeremycw commented 4 years ago

That's strange. My hardware is:

  Model Name:   MacBook Pro
  Model Identifier: MacBookPro11,5
  Processor Name:   Intel Core i7
  Processor Speed:  2.5 GHz
  Number of Processors: 1
  Total Number of Cores:    4
  L2 Cache (per Core):  256 KB
  L3 Cache: 6 MB
  Memory:   16 GB

The numbers in the readme were done on an Ubuntu VM but I still get ~85,000 RPS on macOS High Sierra 10.13.6

Compiled with: clang -O3 -std=c99 -Wall -Wextra -Werror test/main.c -o http-server

travisbrady commented 4 years ago

Hmmm...this must just be some peculiarity with my laptop. Thanks for checking on yours