Coder Social home page Coder Social logo

dbalabka / aerys-benchmark Goto Github PK

View Code? Open in Web Editor NEW
11.0 11.0 4.0 128 KB

Amphp HTTP server (aka Ayres) PHP non-blocking HTTP server benchmark

PHP 34.22% JavaScript 1.88% Shell 38.78% Dockerfile 25.12%
aerys amphp async benchmark http-benchmarking nodejs php php7 reactphp

aerys-benchmark's Introduction

aerys-benchmark's People

Contributors

dbalabka avatar kelunik avatar staabm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

aerys-benchmark's Issues

Review how HTTP parsing is affecting performance

There is an assumption that HTTP parsing in Amphp might affect overall server performance.

The assumption is based on experimental results. The variant of pure TCP Amphp server without HTTP parsing performs closer to Swoole and faster than Nodejs.

HTTP parsing implemented with PHP PECL Regexp can be replaced with bind C or Rust library via FFI or Wasmer extension.

Possible fast parsing libraries are:

  1. https://github.com/seanmonstar/httparse/
  2. https://github.com/h2o/picohttpparser

Libraries benchmark: https://github.com/rust-bakery/parser_benchmarks/blob/master/http/README.md

Comments on your conclusions

As was mentioned otherwhere, enabling opcache (via -dopcache.enable_cli=1 -dopcache.optimization_level=0xffffffff) and using PHP 7.1 may improve performance a bit more.

Also, note that the node http module is even simpler than ours; as in, it has no concept of flexible middlewares etc. It ultimately just has to handle even less logic and thus may be faster. A tiny bit of logic, but not totally insignificant as it has to create a bunch of generators for the middleware machinery.
There are also other options to tune for the benchmark, like "deflateEnable" => false: Aerys always buffers by default for up to Options->deflateMinimumLength to check whether it's worth to use gzip compression]. NodeJS does no such thing.

In general, the nodejs server is more lightweight than Aerys; Aerys is packed with a bit more functionality which will be handy in more complex โ€ฆ in real world scenarios.

I have no idea why the standard deviation, especially as it is very low for node... I'd be interested in that too.

P.s.: $resp->addHeader('Content-Length', strlen($data)); is redundant; Aerys will set it for you (chunked encoding if you stream and normal content-length if end() is used without prior stream() call)

Need to warm-up server before benchmark

For example NodeJS JIT have huge performance hit. During first 30 seconds NodeJS usually response with high deviation due to JIT compilation.
To avoid this issue we have to warm-up server during few seconds before benchmark and use --always-opt.

Add other benchmarks

Currently it only benchmarks a plain GET /, would be interesting to see POST requests with multipart and JSON as well as larger responses with gzip / deflate.

Unfair comparison

Your current benchmark uses NodeJS and React with one process, while Aerys spawns as many workers as you have CPU cores available.

Add other servers implementations to benchmark

Swoole is an event-driven, asynchronous & concurrent networking communication engine with higher performance written only in C for PHP. Swoole includes components for different purposes: TCP/UDP Server and Client, Task Worker, Database Connection Pooling, Millisecond Timer, Event, Async IO, Async Http/WebSocket Client, Async Redis Client, Async MySQL Client, and Async DNS Requiring. With these components, Swoole allows you to build many features, which are widely used in the applications about Internet, mobile communication, enterprise software, cloud computing, online game, IoT, IoV, and smart home, etc. For IT development group, it can improve the efficiency, which makes them focus on the innovational products.

http://www.swoole.com/

Workerman An asynchronous event driven PHP framework for easily building fast, scalable network applications. Supports HTTP, Websocket, SSL and other custom protocols. Supports libevent, HHVM, ReactPHP.

https://github.com/walkor/Workerman

Express.js Fast, unopinionated, minimalist web framework for node.

https://github.com/expressjs/express

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.