Skip to content

foxhunter/hetao

 
 

Repository files navigation

hetao是一款国人原创研发的开源的C语言实现的支持高并发、超高性能Web服务器,使用高性能HTTP解析器fasterhttp作为其解析核心。
hetao在开启Keep-Alive和gzip压缩时(现代浏览器默认开启)性能比nginx约快3倍。

hetao功能:
* 支持主流操作系统Linux(基于epoll)、WINDOWS(基于IOCP)
* 支持HTTP/1.0、HTTP/1.1
* 支持通讯超时控制
* 支持多侦听端口
* 支持多虚拟主机(基于域名)
* 支持自定义错误页面
* 支持自定义缺省index文件
* 支持自适应Keep-Alive
* 支持自适应gzip、deflate压缩
* 支持HTTPS
* 支持反向代理负载均衡(目前支持轮询、最少连接数算法),支持HTTP与HTTPS互转
* 支持改写URI
* 支持重定向域名
* 支持优雅重启/重载配置,重启期间完全不中断对外服务
* 支持工作进程绑定CPU
* 支持进程崩溃后自动重启

hetao安全机制:
* HTTP请求报文合法性校验
* 活跃超时控制(防止僵尸连接)和累积超时控制(防止慢速攻击)
* 每个IP连接数限制
* 全局最大连接数限制
* 最大单个文件缓存大小

选择hetao的理由: 
* hetao在Linux上的综合性能约比Nginx还要快三倍,尤其适合中小型静态文件
* hetao是众多开源Web服务器中在WINDOWS版本唯一全部采用IOCP模型。Apache的WINDOWS版本是传统的Leader-Follow多进程模型,Nginx则是多线程select模型(玩具?)
* hetao配置文件采用JSON标准格式,简洁易写,而且支持行注释和块注释。Apache配置格式比较复杂,Nginx配置格式多变怪异且不支持块注释
* hetao设计精炼,代码结构简洁易读,代码量小,易于改造
* hetao是中国国产原创,作者可随时联系交流,中文资料较多
* Linux版提供指定目录直接创建Web站点,WINDOWS版提供了右键目录直接创建Web站点,便于测试页面

源码托管:
http://git.oschina.net/calvinwilliams/hetao
https://github.com/calvinwilliams/hetao

项目文档:
doc/hetao-CN.pdf

作者邮箱:
[email protected]

------------------------------------------------------------

压测结论:
在开启Keep-Alive和gzip压缩、中型文件(约3.3KB)的场景下,hetao比nginx足足快了近3倍 ^_^

$ ab2 -kc 1000 -n 50000 -H "Accept-Encoding: gzip" http://192.168.6.111:9527/press.html
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 192.168.6.111 (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:        hetao/0.2.0
Server Hostname:        192.168.6.111
Server Port:            9527

Document Path:          /press.html
Document Length:        281 bytes

Concurrency Level:      1000
Time taken for tests:   6.923 seconds
Complete requests:      100000
Failed requests:        0
Write errors:           0
Keep-Alive requests:    100000
Total transferred:      41709990 bytes
HTML transferred:       28242186 bytes
Requests per second:    14445.19 [#/sec] (mean)
Time per request:       69.227 [ms] (mean)
Time per request:       0.069 [ms] (mean, across all concurrent requests)
Transfer rate:          5883.87 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0   13 198.9      0    3080
Processing:     1   31 102.2     15    3456
Waiting:        0   31 102.2     15    3456
Total:          1   44 242.5     15    3479

Percentage of the requests served within a certain time (ms)
  50%     15
  66%     31
  75%     36
  80%     43
  90%     64
  95%     85
  98%    108
  99%    126
 100%   3479 (longest request)

$ ab2 -kc 1000 -n 50000 -H "Accept-Encoding: gzip" http://192.168.6.111:9528/press.html
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 192.168.6.111 (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:        nginx/1.9.13
Server Hostname:        192.168.6.111
Server Port:            9528

Document Path:          /press.html
Document Length:        293 bytes

Concurrency Level:      1000
Time taken for tests:   23.928 seconds
Complete requests:      100000
Failed requests:        0
Write errors:           0
Keep-Alive requests:    99004
Total transferred:      54195020 bytes
HTML transferred:       29300000 bytes
Requests per second:    4179.19 [#/sec] (mean)
Time per request:       239.281 [ms] (mean)
Time per request:       0.239 [ms] (mean, across all concurrent requests)
Transfer rate:          2211.83 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0   23 268.2      0    3167
Processing:     1  127 904.6     75   20671
Waiting:        0  127 904.6     75   20670
Total:          1  150 1058.7     75   23814

Percentage of the requests served within a certain time (ms)
  50%     75
  66%     86
  75%     87
  80%     87
  90%     92
  95%     96
  98%     96
  99%   2365
 100%  23814 (longest request)

$ ab2 -kc 1000 -n 50000 -H "Accept-Encoding: gzip" http://192.168.6.111:9529/press.html
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 192.168.6.111 (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:        Apache/2.2.14
Server Hostname:        192.168.6.111
Server Port:            9529

Document Path:          /press.html
Document Length:        281 bytes

Concurrency Level:      1000
Time taken for tests:   39.800 seconds
Complete requests:      100000
Failed requests:        0
Write errors:           0
Keep-Alive requests:    99119
Total transferred:      65363814 bytes
HTML transferred:       28101124 bytes
Requests per second:    2512.58 [#/sec] (mean)
Time per request:       397.998 [ms] (mean)
Time per request:       0.398 [ms] (mean, across all concurrent requests)
Transfer rate:          1603.83 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1  48.4      0    3001
Processing:     1   97 774.0      2   25875
Waiting:        0   97 773.8      2   25875
Total:          1   98 780.3      2   25897

Percentage of the requests served within a certain time (ms)
  50%      2
  66%      3
  75%      3
  80%      4
  90%      6
  95%     82
  98%   1398
  99%   2352
 100%  25897 (longest request)

$ ab2 -kc 1000 -n 50000 -H "Accept-Encoding: gzip" http://192.168.6.111:9530/press.html
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 192.168.6.111 (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:        Tengine/2.1.2
Server Hostname:        192.168.6.111
Server Port:            9530

Document Path:          /press.html
Document Length:        293 bytes

Concurrency Level:      1000
Time taken for tests:   25.203 seconds
Complete requests:      100000
Failed requests:        0
Write errors:           0
Keep-Alive requests:    99027
Total transferred:      51895135 bytes
HTML transferred:       29300000 bytes
Requests per second:    3967.81 [#/sec] (mean)
Time per request:       252.028 [ms] (mean)
Time per request:       0.252 [ms] (mean, across all concurrent requests)
Transfer rate:          2010.84 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0   16 233.6      0   21003
Processing:     1   91 485.5     33   21267
Waiting:        1   91 485.5     33   21267
Total:          1  107 637.0     33   24392

Percentage of the requests served within a certain time (ms)
  50%     33
  66%    101
  75%    112
  80%    112
  90%    132
  95%    182
  98%    213
  99%    337
 100%  24392 (longest request)

...see doc/* for detail

About

Very-high performance Web Server

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 84.6%
  • C++ 11.4%
  • HTML 3.4%
  • Other 0.6%