php-pm

VilniusPHP: PHP Naughty Session

I'll be talking about...

  • php-pm in 5 minutes

Marius BalĨytis

php-process manager

  • uses ReactPHP
  • asynchronous PHP
  • up to 15x faster than using php-fpm

Example PHP code


echo "Hello!";

Example PHP-PM-like code


while (true) {
    listenViaSocketForRequest(function($r) {
        sendResponse($r, "Hello!");
    });
}

Why's that faster?


$service = initHeavyService();  // not executed for every request!

while (true) {
    listenViaSocketForRequest(function($r) {
        sendResponse($r, $service->generateResponse());
    });
}

Wrappers

  • Symfony
  • Laravel
  • Zend
  • CakePHP
  • Wordpress

cd my-project
docker run -v `pwd`:/var/www -p 8080:80 \
        phppm/nginx --static-directory=web/

Why's that naughty?

  • shared memory between requests!

class Cache
{
    private $cache = []; // shared between (some) requests!

    // ...
}

Even more naughty?

github.com/php-pm/php-pm

Questions?