Coder Social home page Coder Social logo

httpserver's Introduction

myHttpServer

简介

这是一个由C++语言编写的Web服务器,目前支持GET方法请求静态资源。支持解析POST方法。支持HTTP长连接。实现了简易CGI功能。

开发环境

  • 操作系统: Ubuntu 20.04
  • 编译器: g++ 9.3.0
  • 版本控制: git
  • 自动化构建: cmake

核心技术

  • 基于epoll的IO复用机制实现Reactor模式,采用边缘触发(ET)模式,和非阻塞模式
  • 针对长连接,epoll使用EPOLLONESHOT保证一个长连接在任意时刻都只被一个线程处理
  • 线程模型将划分为主线程和工作线程,主线程接收客户端连接(accept),然后将连接放入任务队列后用条件变量通知休眠的工作线程。工作线程负责和客户端进行数据的交互
  • 利用线程池管理所有的工作线程,避免其不必要构造和析构
  • 基于链表+哈希表实现定时器功能,定时剔除不活跃连接。定时器的插入、更新和删除时间复杂度都为O(1)
  • RAII技术管理程序中的互斥锁、条件变量等资源
  • 统一信号源。利用匿名管道接受所有的进程信号,然后由主线程中的epoll统一处理
  • 异步日志功能。通过在内存中构建循环缓冲区,利用专用后端线程执行文件写入从而将文件IO从前端线程中分离。

httpserver's People

Contributors

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