Giter VIP home page Giter VIP logo

tinyws's Introduction

tinyWS

A C++ Tiny Web Server

版本

  • 多线程版本
  • 多进程版本
    • 版本1:父进程负责 listen 和 accept 连接,子进程负责连接的读写处理。
    • 版本2:所有进程监听同一个 listen sockfd,accept 到新的连接后自己处理连接的读写。所有进程通过竞争设置了PTHREAD_PROCESS_SHARED属性的mutex来获取处理 listen sockfd 的机会,保证了同一时刻只有一个进程监听 listen sockfd 的 IO 事件(只有读事件),解决了惊群问题

测试

版本 短连接QPS 长连接QPS
多线程 8377 31325
多进程1 7650 30828
多进程2 7638 30608

可以看出,处理请求数方面,长连接比短连接能很多,大概多了 4 倍。

tinyws's People

Watchers

James Cloos avatar  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.