Workerman is a high-performance PHP socket server framework, Workerman based on PHP multi-process and Libevent event polling library, PHP developers as long as the implementation of one or two interfaces, you can open their own network applications, such as RPC services, chat room servers, Game server and so on.
Workerman's goal is to make it easier for PHP developers to develop socket-based, high-performance application services without having to understand PHP sockets and PHP multi-process details. Workerman itself is a PHP multi-process Server framework, with PHP process management and socket communication modules, so do not rely on PHP-FPM, Nginx or Apache and other such containers can be run independently.
Characteristics
Using PHP Development
Support for PHP multi-process
Support TCP/UDP
Support for various application layer protocols on the interface
Supports Libevent event polling library, supports high concurrency
Support Service Smooth Restart
Support PHP file update detection and automatic loading
Support for long PHP connections
Support to run child processes with the specified user
Supports Telnet remote control
Performance
Based on Workerman already have a lot of network applications, such as multi-person online tadpoles games, Php-json-rpc, php-thrift-rpc, php-websocket chat room, PHP statistical monitoring system and so on.
Example code:
Count = 4;//Returns Hello $data to client after receiving data from client $ws_worker->onmessage = function ($connection, $data) { //Send Hello $ to client Data $connection->send (' Hello '. $data);};/ /Run Worker::runall ();
Performance Stress Testing
Test environment:
System: Ubuntu 12.04 LTS 64-bit memory: 8gcpu:intel®core i3-3220 CPU @ 3.30ghzx4
Business logic:
Hello World
Results:
Short link (Close the link after each request completes, next request to establish a new link): Condition: Test script Open 500 threads, each line subroutines connect Workerman 10W times, each link sends 1 request result: Throughput: 3w/s, cpu:60%, memory consumption: 4*8m = 32M
Long link (do not close the link after each request, the next request to continue to reuse this link): Condition: Pressure test script Open 1000 threads, each line subroutines Workerman 1 times, each link sends 10W request result: Throughput: 13w/s, cpu:68%, memory consumption: 4*8m = 32M
No flow jitter, no memory leaks, very powerful performance
Workerman Start Interface:
Workerman Status Viewing interface: