FrankenPHP and Caddy: Double performance, claims Caddy creator but only some apps benefit

FrankenPHP and Caddy: Double performance, claims Caddy creator but only some apps benefit

FrankenPHP, a PHP App server written in Go and built on the Caddy web server, has the potential to double performance and halve the developer and devops work for PHP applications, said Caddy creator Matt Holt; while Caddy itself has just been updated to version 2.8, now with experimental HTTP/3 support to backends.

The author of FrankenPHP is Kevin Dunglas, a core contributor to both PHP and Go, and a maintainer for Symfony, a popular PHP web framework.

Dunglas combined his knowledge of these various fields to create FrankenPHP, previewed at SymfonyCon in November 2022 and reaching its 1.0 release in December 2023. FrankenPHP is designed for container deployment and contains Caddy, which is also written in Go, so that a single service powers PHP applications. FrankenPHP is open source under the MIT license, with code on GitHub.

Packaging the PHP runtime plus the web server together like this greatly improves performance. One benchmark presented by Dunglas showed web requests for a hello world Symfony app taking on average 2.53ms to complete, versus 9.45ms for PHP-FPM (FastCGI Process Manager), commonly used to optimize performance on conventional web servers.

FrankenPHP running API Platform in a Docker container

Other features of FrankenPHP include automatic HTTPS certificate generation (thanks to Caddy’s support for Let’s Encrypt or ZeroSSL), native support for PHP extensions – including OPCache and XDebug – and a worker mode that keep an app in memory, for faster response. Structured logging, Prometheus metrics and tracing, and graceful reload (update an application on the fly) are also supported. 

Pre-built containers are available for commonly used PHP applications, including WordPress, Symfony, Drupal, Joomla, Laravel, and API Platform, this last also created by Dunglas. 

Holt is an enthusiast. “This has the potential to change the World Wide Web (I use that term very deliberately, given that PHP powers the vast majority of the Internet globally … It is not uncommon to nearly double your site’s performance and halve your work as a developer/devops person,” he said on Hacker News.

Unfortunately it is not that simple. A large part of the reason for PHP’s widespread use is because of WordPress, and Dunglas said that “unlike Laravel and Symfony, WordPress doesn’t support the worker mode of FrankenPHP (yet?), so there are not many benefits in terms of performance (except the ability to preload assets using 103 Early Hints, which can reduce the latency of a page load by 30%).”

Still, performance is no worse, and there remains a simplified DevOps story for FrankenPHP users – though PHP is generally not difficult to deploy by more conventional means. 

On the Caddy side, version 2.8 is “one of the biggest Caddy updates yet,” according to the team, with hundreds of improvements. There is experimental support for the fast HTTP/3 protocol to proxy backends, updated automatic certificate renewal including ARI (ACME Renewal Information) support, and performance improvements including that more media types are now compressed by default.

Caddy is highly regarded by some of its users. “It is such a good reverse proxy and a paradigm-shifter for its auto-certificates and HTTP/3 support,” said one.

PHP is often perceived as dated compared to modern web development with Node.js, or typed languages such as C# and Java. Developers though appreciate PHP’s incremental improvement over the years, perhaps easier to absorb than the constant shifts in the JavaScript world between client and server components and the proliferation of frameworks. PHP also works well for serving an API that can be called from JavaScript.