1.Swoole: Redefining PHP
The PHP language's high-performance network communication Framework provides the PHP language for asynchronous multi-threaded servers, asynchronous TCP/UDP network clients, asynchronous MySQL, database connection pooling, Asynctask, Message Queuing, millisecond timers, asynchronous file read and write, asynchronous DNS queries.
Swoole can be widely used in the Internet, mobile communications, enterprise software, online games, Internet of things, car networking, smart home and other fields. The use of Php+swoole as a network communication framework can greatly improve the efficiency of enterprise IT research and development teams and focus on the development of innovative products.
2.workerman
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, Mobile 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.
3.mpass–php to do socket service solution
- Author: laruence ()
- This address: http://www.laruence.com/2010/10/29/1774.html
- Reprint please indicate the source
PHP is rarely useful for service, but if your existing business logic is implemented in PHP, but now you need to provide a set of socket services based on existing business logic?
Of course, the solution is many, but the simplest way, or directly using PHP to do the socket service.
There are many problems to be solved, and the main problems to be solved are as follows:
- 1. As a back-office service , it needs to be run in the background , so the slightest memory leak is unacceptable .
- 2. As a back-office service , malformed data causes the process to exit abnormally and is unacceptable .
- 3. As a backstage service , we should be able to do graceful restart.
- 4. As a back-office service , the use of resources must be within an acceptable range .
Recently, I implemented a simple framework for providing a socket service based on the PHP pcntl extension. Named Mpass (multi-processes Socket Server).
The main structure is as follows:
Mpass
My previous article on PHP CLI mode in the multi-process application described how to avoid the memory leak when PHP does the service, so based on this, plus PHP5 after the Stream_socket_* series API, completed the framework.
As for the graceful restart, through the Pcntl_signal function, at the time of receiving the restart/shutdown signal, the cleanup action is done to ensure that the logic that is being executed is not faulted because of the reboot/shutdown.
Have similar needs of friends, can learn from.
Project Address & : Mpass
PHP Socket Server Framework Set