Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do We have any php application servers (not web servers)?

Tags:

php

nginx

apache

For Java we have different Application servers like WebSphere and Web logic, My Doubt is do we have any PHP Application servers?

Till now We are using Apache and Nginx web servers for PHP Web applications. How Application servers are useful to PHP?

Thanks Ramu

like image 646
DaraRamu Avatar asked Oct 17 '25 13:10

DaraRamu


1 Answers

With PHP-PM, RoadRunner, Swoole the label "app server" is arguable, but they all solve the most problematic part: the wasteful "process app reinit & cleanup on every request". And, in addition to removing the entire HTTP server → aux. process mgmt. → PHP script loading/processing detour from the pipeline (by having an integrated, in-process HTTP server + process management facilities), they also add varying levels/amounts of extra services to help building robust long-lived server-side apps in PHP.


Swoole is technically implemented as a PHP extension, but does much more than the usual ones. It launches worker processes on its own, and it's used like a framework: you'll write your event loop and pass control to Swoole. Your app will be hooked up to handle HTTP requests (or websocket events etc.), using their nonblocking async I/O (networking, filesystem, process mgmt.), plus various other handy services incl. coroutines, IPC, locking etc.). All the async., performance-critical I/O is dealt with in C, via a straightforward PHP API, including:

  • HTTP server and client
  • TCP/UDP server and client
  • Websocket server
  • Redis server
  • MySQL client
  • Filesystem I/O, IPC, process mgmt. etc.

https://scottaubrey.info/blog/2018-10-22-first-look-at-swoole/

It's basically Node.js for PHP

→ Unofficial extra docs (in addition to the official ones)


RoadRunner is a process manager server (written in Go). From their feature list:

  • PSR-7 HTTP server (file uploads, error handling, static files, hot reload, middlewares, event listeners)
  • HTTPS and HTTP/2 support (including HTTP/2 Push, H2C)
  • Fully customizable server, FastCGI support
  • Load balancer, process manager and task pipeline
  • Works over TCP, UNIX sockets and standard pipes
  • Automatic worker replacement and safe PHP process destruction
  • Worker lifecycle management (controller)
  • Very fast (~250k rpc calls per second on Ryzen 1700X using 16 threads)
  • Integrations with Symfony, Laravel, Slim, CakePHP, Zend Expressive
  • Automatic reloading on file changes
  • Works on Windows (Unix sockets (AF_UNIX) supported on Windows 10)

PHP-PM is another advanced PHP process manager (like RoadRunner), but also comes with an app (meta)framework, built on top of ReactPHP (another event-driven, async. I/O lib, similar to Swoole, but implemented in PHP, so inherently slower). This package covers most of the ground of the app-server chores (https://laravel-news.com/php-pm). Some of their listed features:

  • Integrated load balancer.
  • Hot-Code reload (when PHP files change).
  • Static file serving for easy development procedures.
  • Support for HttpKernel (Symfony/Laravel), Drupal (experimental), Zend (experimental).

Bonus: here's a nice, detailed performance test of various architecture alternatives (excluding Swoole) for long-lived sever-side PHP processes. For Swoole (compared to other frameworks, not other PHP process piping setups!), see this nice framework performance chart; it's pretty scary fast.

like image 65
Sz. Avatar answered Oct 19 '25 05:10

Sz.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!