Search code examples
phparchitectureserverreactphp

ReactPHP http server for each user, Is this a good idea?


ReactPHP http server for each user, Is this a good idea?

In my application:

  1. Each logged on user sends and receives data from server. In average one request per second.
  2. After server response, the server have some extra work to do, which is related to specific user.

I can simply build new ReactPHP http server for each user who logs, and release the server after the user log out.

Is this will work? Am i missing something ?


Solution

  • No, it's not a good idea. You need a separate port per user in that case to route the user to the right server. That'd quickly exhaust your ports.

    If you have blocking tasks within the event loop and want to use multiple processes because of that, just stick to traditional PHP with mod_php or php-fpm and start a new event loop for each process, do your thing and then exit.

    If you don't have any blocking operations and everything is non-blocking, you can just use a single server and it handles all the things.