GithubHelp home page GithubHelp logo

webserver's Introduction

A C++ Lightweight Web Server

license Build Status

简介

这是一个轻量级的 Web 服务器,目前支持 GET、HEAD 方法处理静态资源。并发模型选择: 线程池+Reactor+非阻塞方式运行。

测试页面:


Part Ⅰ Part Ⅱ
整体设计 性能测试分析

开发部署环境

  • 操作系统: Ubuntu 5.4.0-6 Ubuntu16.04.9
  • 编译器: g++ version 5.4.0 20160609
  • 版本控制: git
  • 编辑器: Vim
  • 压测工具:WebBench

Usage

cmake . && make 

./webserver [-p port] [-t thread_numbers]  [-r website_root_path] [-d daemon_run]

核心功能及技术

  • 状态机解析 HTTP 请求,目前支持 HTTP GET、HEAD 方法
  • 使用 priority 队列实现的最小堆结构管理定时器,使用标记删除
  • 使用 epoll + 非阻塞IO + 边缘触发(ET) 实现高并发处理请求,使用 Reactor 编程模型
  • epoll 使用 EPOLLONESHOT 保证一个 socket 连接在任意时刻都只被一个线程处理
  • 使用多线程充分利用多核 CPU,并使用线程池避免线程频繁创建销毁的开销
  • 为减少内存泄漏的可能,使用智能指针等 RAII 机制

开发计划

  • 添加异步日志系统,记录服务器运行状态
  • 自动化构建: cmake
  • 集成开发工具: CLion

参考

webserver's People

Contributors

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