Giter Site home page Giter Site logo

webserver1.0's Introduction

WebServer1.0

Introduction

一个基于C++17的Web服务器。支持GET、HEAD以及POST方法。支持HTTP长连接、短连接,以及管线化请求。日志使用spdlog。

Environment

  • OS: Ubuntu 20.04
  • Compiler: g++ 9.4.0
  • CMake: 3.16.3

Build

mkdir build
cd build
cmake ..
make

Usage

./WEBSERVER -p  port_number  -s  subreactor_number  -l  log_file_path(start with ./)
````-p 9899 -s 10 -l ./log/log.txt

Test

webbench-1.5

./webbench -c 1000  -t  30   http://192.168.31.128:18888/index.html

Technical points

  • 使用边沿触发的Epoll多路复用技术,并使用多Reactor多线程模型。
  • 使用线程池避免线程频繁创建销毁的开销
  • 基于时间轮算法的定时器以实现请求报文传输以及长连接的超时回调。
  • One loop per thread,主线程MainReactor负责accept并将连接socket分发给SubReactors;子线程中的SubReactors负责监听连接socket上的事件以及调用相应的回调函数。
  • 使用状态机和正则表达式解析HTTP请求,支持管线化。

webserver1.0's People

Contributors

forthdifferential avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.