Giter VIP home page Giter VIP logo

httpserver's Introduction

HTTPServer

简介

学习Linux网络编程,实现Linux下C++文件服务器。

环境

  • 操作系统 linux, ubuntu 18.04
  • 编译器 g++ 7.4.0

功能

  • 利用Epoll边沿触发的IO多路复用技术与线程池实现多线程的Reactor并发模型
  • 使用正则和有限状态机解析HTTP请求报文,支持GET请求
  • 利用标准库容器封装char,实现自动增长的缓冲区

框架

项目细节

  • bulid

    make
  • run

    端口port

    ./server port
  • 演示

  • 文件根目录root/

  • listenfd和connfd使用LT + ET组合

  • 线程池内有8条线程

  • Reactor反应堆模型

压力测试

测试环境

  • CPU:Intel i5-8400(六核心六线程)
  • 内存:8G
  • linux, ubuntu 18.04, g++ 7.4.0

测试工具

Webbench是有名的网站压力测试工具。

  • 测试处在相同硬件上,不同服务的性能以及不同硬件上同一个服务的运行状况。
  • 展示服务器的两项内容:每分钟输出的页面数和每秒钟传输数据量。

测试规则

  • 测试样例

    ./webbench -c 10500 -t 5 http://192.168.1.107:9006/
  • 参数

  • -c 表示客户端数
  • -t 表示时间

测试结果

Webbench对服务器进行压力测试,经压力测试可以实现上万的并发连接.

  • 并发连接总数:10500
  • 访问服务器时间:5s
  • 每分钟输出页面数:449460 pages/min
  • 每秒钟传输数据量:6746377 bytes/sec
  • 所有访问均成功

TODO

  • 实现定时器,关闭超时的非活动连接
  • 实现日志系统,记录服务器运行状态

参考资料

httpserver's People

Contributors

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