Slide 1

Slide 1 text

Mario Blažek PHP Superpowers with @phpanarchist

Slide 2

Slide 2 text

About me • Mario Blažek • Backend Team Lead @4ofthem • Married with children • Believes in Open Source • Zagreb PHP Meetup organizer (ZgPHP) • Chief Fire O ffi cer

Slide 3

Slide 3 text

What kind of PHP setup are you using?

Slide 4

Slide 4 text

Existing setups • Apache + mod_php • Apache + php-fpm • Nginx + php-fpm • Standalone PHP servers (ReactPHP, Swoole, RoadRunner) • FrankenPHP

Slide 5

Slide 5 text

Nginx • Event-driven architecture, handles thousands of concurrent requests e ff i ciently • Serves static fi les directly without passing requests to PHP • Load balancing and reverse proxy capabilities • Handles concurrent connections better than traditional web servers

Slide 6

Slide 6 text

php-fpm (FastCGI Process Manager) • Handles dynamic PHP requests separately from the web server • Uses process pools (static, dynamic, ondemmand) to e ff i ciently manage multiple requests • Provides better security by isolating PHP execution from the web server • Allows tuning of worker processes, memory limits, and timeouts for performance optimization • Communicates with Nginx via FastCGI protocol

Slide 7

Slide 7 text

php-fpm tunning • https://tideways.com/pro fi ler/blog/an-introduction-to-php-fpm-tuning

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

Container philosophy • One process per container • Stateless and disposable containers

Slide 10

Slide 10 text

Problems with nginx+fpm • Process model challenges • Inter-process communication overhead • Complex scaling • Resource consumption • Deployment complexity

Slide 11

Slide 11 text

Franken to the game • PHP application server based on Caddy web server • One service! • Two modes: classic + worker • 103 Early Hints support • HTTP2 and HTTP3 native support

Slide 12

Slide 12 text

Franken to the game • Developed by Kévin Dunglas • Symfony Core member • API Platform • Mercure • Vulcain

Slide 13

Slide 13 text

Caddy web server • Modern and fast (event-driven, non- blocking architecture) • Caddy fi le - user friendly con fi guration • Automatic HTTPS • Works seamlessly as a reverse proxy, LB, cache and request forwarder • First-class support for PHP

Slide 14

Slide 14 text

Static binary

Slide 15

Slide 15 text

Docker

Slide 16

Slide 16 text

New SAPI

Slide 17

Slide 17 text

Caddy con fi guration Caddy fi le

Slide 18

Slide 18 text

Superpower - worker mode • Boot your application once • Keep it in memory • Process incoming requests without having to boot your application again • Relies on goroutines and channels • Symfony Runtime compatible • Some resemblance with RoadRunner

Slide 19

Slide 19 text

Worker mode

Slide 20

Slide 20 text

Symfony Runtime • Abstracts the application bootstrap logic into runtimes • Front controller remains generic • Basically application remains decoupled from the infrastructure • Di ff erent runtimes provided by community

Slide 21

Slide 21 text

Without Runtime

Slide 22

Slide 22 text

With Runtime

Slide 23

Slide 23 text

Symfony in worker mode

Slide 24

Slide 24 text

Early hints

Slide 25

Slide 25 text

Early hints

Slide 26

Slide 26 text

Mercure

Slide 27

Slide 27 text

Mercure

Slide 28

Slide 28 text

Benchmarks

Slide 29

Slide 29 text

Benchmarks • https://dev.to/dimdev/performance-benchmark-of-php-runtimes-2lmc • https://medium.com/beyn-technology/wars-of-symfony-runtimes-a- performance-odyssey-7b0120e8f9e1 • https://frankenphp.dev/docs/performance/ • https://github.com/dunglas/frankenphp-demo/tree/main/benchmark

Slide 30

Slide 30 text

Questions?

Slide 31

Slide 31 text

Thank you! https://bit.ly/phpfrankensuperpowers