Giter VIP home page Giter VIP logo

hellepoll's Introduction

Hellepoll is a simple asynchronous web-server written in C++.

It is available under the standard Simplified BSD License; see the LICENSE file for details.

Speed

You only write this kind of code if you are concerned about speed :)

benchmarkTornado (Python)node.jsdeft (Java)Hellepoll
ab -c252K9K13K18K/s
ab -k -c257K?30K60K/s+

(At 40K/sec on my laptop I am running out of memory bandwidth, and my CPU is not maxed out yet. Numbers ought to be higher on normal server-like hardware.)

Where to start?

Look at helloworld.cpp. Its mostly about parsing commandline arguments, but in there is a simple class that prints "Hello world" on every request. Can't start simplier than that!

Status

It is very much alpha code, mostly for those wanting to build their own inner guts and just want code to glance at.

It would be nice to imagine it growing into a proper 'tornado for C++' but that's a long way off.

Helloworld is an example simple HTTP server that is included, and used in speed benchmarking.

Architecture

It is built around an asynchronous IO loop, which is the scheduler class; currently this is epoll, but in prinicple it could be kqueue or equivilent. It can use edge-triggering, and if used it will check that you sate the stream in your slice.

You would have one instance of the scheduler class for each thread. Ideally, your server is single threaded so you don't have to worry about locking and such, just run a separate process instance for each core that you have.

In the IO loop are any number of tasks - half a million is not so scary.

Protocol handlers - such as HTTP - use state machines to track their progress.

Todo

  • HTTP server should have a handler factory instead, based on the address and the registration of regexes or stems or something
  • For non-chunked keep-alive replies, all writes should be buffered so the content-length can be computed by the framework
  • Profile and improve speed of inner loop
  • Integrate async file IO too
  • Profile and improve speed e.g. play with writev()
  • scheduler.add_callback() and general helpers for writing async programs
  • A templating system for HTML
  • Errors reported to task handlers
  • More built-in handlers e.g. async memcached, redis, even SQL somehow

hellepoll's People

Contributors

williame avatar

Stargazers

 avatar  avatar

Watchers

 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.