Giter Site home page Giter Site logo

mywebserver's Introduction

MyWebServer

Introduction

linux下高并发c++http服务器,经过webbench压力测试,可以达到30000多的QPS

Envoirment

  • OS: Ubuntu 16.04
  • C++版本:14
  • Mysql:ver 14.14 Distrib 5.7.33, for Linux

Technical points

  • 利用io复用技术Epoll以及线程池实现多进程多线程的Reactor并发模型;
  • 利用正则与状态机解析HTTP请求报文,实现处理静态资源的请求;
  • 利用标准库容器,实现自动增长的缓冲区;
  • 基于最小堆实现定时器,实现心跳机制,清除超时非活动连接
  • 利用RAII机制实现数据库连接池,减少数据库连接建立与关闭的开销

Business functions

  • 登录和注册
  • 播放视频
  • 查看图片
  • 文件上传 (只能上传小文件)

Model

网络模型

Test

测试环境 : ubuntu16.04 内存62g cpu核数40

测试项目 测试方案 tps pages/min tps pages/s 分析
LT+LT 单进程 开40线程 最多cpu利用率到28 1349566 22492.76667 由于cpu利用率只能达到280%,故多余线程调度加锁成为瓶颈
LT+LT 单进程 开28线程 1422504 23708.4 cpu利用率为280%
LT+LT 多进程多线程 二进程 开28线程 1720170 28669.5 cpu利用率为280%
LT+LT 多进程多线程 三进程 开28线程 1889946 31499.1 cpu三个线程cpu利用率为240%
LT+LT 多进程多线程 四进程 开28线程 2000502 33341.7 cpu利用率为200%
LT+LT 多进程多线程 五进程 开28线程 1869168 31152.8 cpu利用率为200%
LT+ET 单进程 开28线程 1434516 23908.6 cpu利用率为280%
LT+ET 多进程多线程 二进程 开28线程 1750000 29166.66667 cpu利用率为280%
LT+ET 多进程多线程 三进程 开28线程 1970000 32833.33333 cpu三个线程cpu利用率为240%
LT+ET 多进程多线程 四进程 开28线程 2056290 34271.5 cpu利用率为240%
LT+ET 多进程多线程 五进程 开28线程 1850000 30833.33333 cpu利用率为200%
ET+LT 单进程 开28线程 1419120 23652 cpu利用率为280%
ET+LT 多进程多线程 二进程 开28线程 会发生强烈竞争,最终只有一个进程在运行

TODO

  • 静态文件预先加载进入内存,加快访问
  • 快速路由
  • 大文件的上传

Reference

  • Linux高性能服务器编程 游双著
  • Linux多线程服务端编程---使用muduo C++网络库 陈硕著
  • TinyWebServer

mywebserver's People

Contributors

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