Amitav Roy

Blog on web and travel

Beyond Boundaries: How FrankenPHP Redefines PHP Application Runtimes

Posted on 1 Jan 2024 by Amitav Roy

Beyond Boundaries: How FrankenPHP Redefines PHP Application Runtimes

What is FrankenPHP?

FrankenPHP is a contemporary PHP app server crafted in Go, boasting numerous advantages. Among its standout features, one that truly captures the spotlight is its remarkable ability to construct a standalone and self-contained binary. This particular feature holds immense significance, particularly in the realm of shipping PHP applications to production.

FrankenPHP is a modern PHP app server written in Go. Here are some points which really sets it apart from others in the race

  1. It’s about 3.5x faster than PHP FPM.
  2. Written in Go and C, it relies on Go’s iconic goroutines features
  3. It uses Caddy server under the hood. So, HTTPS support for local development is also available out of the box
  4. It has native support for HTTP/1.1, HTTP/2 and HTTP/3. Having a reduced round-trip time for HTTP/3, it’s a very performant option.

The game-changing perks

Now, let's talk about the good things that make FrankenPHP stand out in the crowd. We've touched on a few points earlier, but there are some features that got me particularly excited. These aren't just perks; they're the kind that can genuinely shake up your development and deployment game.

Single binary - Deployment Bliss

Ever dreamed of simplifying your deployment process? FrankenPHP makes it happen. The ability to whip up a single binary for our entire PHP application is a game-changer. No need for additional software – just a straightforward Ubuntu docker container is all you require to run your PHP apps. This not only streamlines deployment but also trims down the docker container's size on production. Less software onboard means fewer attack vectors, and trust me, that's a security win we all want.

Worker Script Mode - Powering Up Performance

Let's talk about performance, shall we? One of the cool things about Node applications is their ability to run entirely from memory, providing a performance boost for high-traffic scenarios. Guess what? FrankenPHP brings that magic to PHP using its worker mode. Boot up once, stay in memory, and enjoy a significant performance boost. It's the kind of wizardry that keeps your app nimble and ready for action.

103 Early hint support - Speeding Things Up

Ever heard of the 103 status code? I confess it wasn't on my radar until I dug into FrankenPHP. Now, I see how it can turbocharge a site's speed, especially in today's SEO landscape where page speed is king. FrankenPHP claims a whopping 30% reduction in loading time by harnessing early hint support. Curious? Dive into the MDN docs for the full scoop on how this feature works wonders.

Prometheus metrics and tracing - Keeping an Eye on Things

For those of us knee-deep in Prometheus for infrastructure monitoring, discovering that FrankenPHP supports it is like finding treasure. Running an application is sweet, but on production, logging is a critical piece of the puzzle. With built-in support for Prometheus metrics and tracing, FrankenPHP just earned itself a star.

So, these are the features that caught my eye. As of January 2nd, I've got one application running on production with FrankenPHP, and I'm eager to share more insights as the journey unfolds. There's even a real-time feature I've spotted in the docs, waiting to be explored. Exciting times ahead!

What are your thoughts on FrankenPHP? Are you running any applications with it in production? Let's chat on Twitter or LinkedIn—I'm always up for a good tech talk!