Coder Social home page Coder Social logo

webserver's Introduction

WebServer

用C++实现的高性能WEB服务器,经过webbenchh压力测试可以实现上万的QPS

项目地址:https://github.com/Aged-cat/WebServer

功能

  • 利用IO复用技术Epoll与线程池实现多线程的Reactor高并发模型;
  • 利用正则与状态机解析HTTP请求报文,实现处理静态资源的请求;
  • 利用标准库容器封装char,实现自动增长的缓冲区;
  • 基于堆结构实现的定时器,关闭超时的非活动连接;
  • 改进了线程池的实现,QPS提升了45%+;

项目详解

WebServer项目——buffer详解

WebServer项目——epoller详解

WebServer项目——timer详解

WebServer项目——threadpool详解

WebServer项目——HTTPconnection详解

WebServer项目——HTTPrequest详解

WebServer项目——HTTPresponse详解

WebServer项目——webserver详解

环境要求

  • Linux
  • C++11

项目启动

mkdir bin
make
./bin/myserver

压力测试

./webbench-1.5/webbench -c 100 -t 10 http://ip:port/
./webbench-1.5/webbench -c 1000 -t 10 http://ip:port/
./webbench-1.5/webbench -c 5000 -t 10 http://ip:port/
./webbench-1.5/webbench -c 10000 -t 10 http://ip:port/
  • 测试环境: Ubuntu:20 cpu:i7-4790 内存:16G

性能表现

markparticle的C++服务器做一个比较(表格中的为QPS的值):

10 100 1000 10000
old 8929 9126 9209 155
new 11478 13578 13375 106

性能提升了45%

致谢

@markparticle

webserver's People

Contributors

agedcat 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.