Y
Y
yiicoder2015-07-19 17:13:09
PHP
yiicoder, 2015-07-19 17:13:09

Does anyone use ReactPHP in Production?

There was a problem - reception and processing of a large array of data.
Now implemented through a bunch of nginx+phpfpm+rabbitmq. The amount of incoming data is quite large (~ 40,000 req/min). Consists of two parts - the first - accepts, does the simplest data validation and sends to rabbitmq. The second part is a background script that parses the queue and processes it as it should.
Plugging occurs at stage 1. "Sometimes" phpfpm stalls a little, due to the high frequency of requests, all the workers get busy - some data is lost.
There is an idea to rewrite the first part in node.js, but I don’t want to produce various technologies, and in light of the release of Php7, ReactPHP seems to be a very promising direction.
We tested it (ReactPHP in conjunction with nginx as a balancer), made small load tests and it "seems to" withstand x10-15 times of requests.
Does anyone have experience successfully implementing ReactPHP into a project? Are there known pitfalls?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
S
Sergey, 2015-07-19
@yiicoder

I use it, the flight is normal (about half a year already)

I
index0h, 2015-07-19
@index0h

php is a stateless language. Daemons can certainly be written in php, but this is not its intended use.
Step 1 ReactPHP won't save. Increase the number of nginx/fpm workers.
PHP7 will become truly production ready only in 2 years, if not more. The point here is both in the errors of php itself, and in the dependencies that you use, they must fully support 7-ku. For example $this->$some[$thing] changes the execution logic in 7-ke, the consequences are not predictable.
Therefore, if I were you, I would write this part on the node, after increasing the number of libuv processes. And in case of shortage - raised a lot of processes with balancing through nginx.

X
xmoonlight, 2015-07-19
@xmoonlight

13407242629490.jpgWhy just take it and not write a native network daemon in C?

N
Nazar Mokrinsky, 2015-07-19
@nazarpc

Why not look at HHVM? There is no need to rewrite the code, after a certain number of requests, HHVM compiles critical sections into machine code and thus speeds up even more (initially, requests will most likely be processed more slowly).
By the way, you can run ReactPHP with HHVM.
Also, ReactPHP still doesn't support multipart requests, if you do, send a pull request

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question