Skip to content

chendotjs/lotos

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

94 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lotos WebServer

Build Status

Lotos is a tiny but high-performance HTTP WebServer following the Reactor model, using non-blocking IO and IO multiplexing(epoll ET) to handle concurrency. Lotos is written in pure c and well tested. Several HTTP headers (Connection, Content-Length, etc.) is supported and more will be added in the future.

-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
C                               19            367            275           2428
C/C++ Header                    12            120            131            514
make                             2             17              0             42
CMake                            1              7              0             18
-------------------------------------------------------------------------------
SUM:                            34            511            406           3002
-------------------------------------------------------------------------------

Documents

0x01 0x02 0x03 0x04 0x05 0x06
项目目的 并发模型 设计实现 测试调试 性能测试 调试记录

Environment

  • gcc >= 5.4 or clang >= 3.5 (gcc4.9 is not supported)
  • Linux only, kernel version >= 3.9

Usage

Build

$ git clone https://github.com/chendotjs/lotos.git
$ cd lotos/src/
$ make && make test

Run

Usage: lotos -r html_root_dir [-p port] [-t timeout] [-w worker_num] [-d (debug mode)]

$ ./lotos -r ../www -t 60 -w 4 -p 8888

then you can visit http://localhost:8888/.

Feature

  • EPOLL Edge Trigger mode, more efficient.
  • Nonblocking IO.
  • Multiprocessing, port reuse.
  • TCP connections managed by min-heap data structure.
  • HTTP persistent connection support. Close TCP connection when connection expires.
  • Parse HTTP requests using FSM.
  • Handle errors and exceptions.
  • Memory pool is optional.

Test

Unit tests are based on minctest. It is simple, lightweight, and flexible.

Moreover, I contributed some codes to it.

Benchmark

Please refer to BENCHMARK.md.

Reference

nginx

node.js http parser

Tkeed