Skip to content

midisec/Dalek

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

                                                   
                                                   
    ,---,                ,--,                 ,-.  
  .'  .' `\            ,--.'|             ,--/ /|  
,---.'     \           |  | :           ,--. :/ |  
|   |  .`\  |          :  : '           :  : ' /   
:   : |  '  | ,--.--.  |  ' |     ,---. |  '  /    
|   ' '  ;  :/       \ '  | |    /     \'  |  :    
'   | ;  .  .--.  .-. ||  | :   /    /  |  |   \   
|   | :  |  '\__\/: . .'  : |__.    ' / '  : |. \  
'   : | /  ; ," .--.; ||  | '.''   ;   /|  | ' \ \ 
|   | '` ,/ /  /  ,.  |;  :    '   |  / '  : |--'  
;   :  .'  ;  :   .'   |  ,   /|   :    ;  |,'     
|   ,.'    |  ,     .-./---`-'  \   \  /'--'       
'---'       `--`---'             `----'          

Dalek跑着我的小网站 :) pink

搭建

chmod 777 -c build.sh ./build.sh

用法

./Dalek start [-p port] [-n worker_num]

测试

测试机器处理器:i5-9300 ,系统 Ubuntu 20.0.4

webbench -c 10000 -t 4 http:https://localhost:1989/

结果:

Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.

Benchmarking: GET http:https://localhost:1989/
10000 clients, running 4 sec.

Speed=4841789 pages/min, 18630496 bytes/sec.
Requests: 322786 susceed, 0 failed.

Dalek架构

Master/Worker模型,端口复用,使用时间轮管理长连接 ,每个工作进程创建一个EventLoopHttpServerHttpServer负责接受连接,注册连接进入EventLoopTimerWheel

Dalek细节

master进程主要负责杀死worker进程, 当worker进程挂了,就会唤醒master进程,再fork()一个worker httppar.h实现了一个高性能的http解析器,可以在客户端40ms发送1byte的情况下正确的解析http请求包 ,reactor目录下则对事件进行了抽象,任何IO事件都封装成Channel,包括定时事件TimerWheel,服务器事件HttpServer,连接事件HttpConnection

代码统计

language files code comment blank total comment rate
C++ 26 3,337 305 950 4,592 8.37%
Markdown 4 36 0 10 46 0.00%
Makefile 3 10 0 2 12 0.00%
Log 1 5 0 1 6 0.00%
Shell Script 1 3 1 1 5 25.00%

代码树

Dalek
├─ CMakeLists.txt
├─ Dalek.cc
├─ README.md
├─ base
│  ├─ SyncLogger.h
│  ├─ copyable.h
│  ├─ noncopyable.h
│  └─ swap.h
├─ build
├─ build.sh
├─ http
│  ├─ Buffer.h
│  ├─ base.h
│  ├─ httpd.h
│  ├─ httppar.h
│  ├─ httpres.h
│  └─ mime.h
└─ reactor
   ├─ Channel.h
   ├─ EventLoop.h
   ├─ InetAddress.h
   ├─ Poller.h
   ├─ Socket.h
   ├─ TimerWheel.h
   └─ base.h

参考

nginx muduo

TODO

  • Json 配置服务器
  • 支持更多方法

About

A high performance httpd

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages