Slide 1

Slide 1 text

React PHP & Symfony by @acasademont Symfony Catalunya 2016

Slide 2

Slide 2 text

about me Albert Casademont software engineer @ ulabox.com @acasademont finishing my MBA () really obsessed with performance!!

Slide 3

Slide 3 text

performance

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

the life of a PHP request 1. parsing 2. AST (Abstract Syntax Tree) 3. bytecode 4. execution

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

opcache to the rescue

Slide 8

Slide 8 text

the life of a PHP request 1. parsing 2. AST (Abstract Syntax Tree) 3. bytecode 4.execution

Slide 9

Slide 9 text

set up opcache NOW!! (please )

Slide 10

Slide 10 text

the life of a PHP request 1. parsing 2. AST (Abstract Syntax Tree) 3. bytecode 4.execution

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

NOT BAD!!

Slide 13

Slide 13 text

set up PHP7 NOW!! (please )

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

40ms not fast enough!

Slide 16

Slide 16 text

WTF!

Slide 17

Slide 17 text

the life of a PHP request 1. parsing 2. AST (Abstract Syntax Tree) 3. bytecode 4.execution

Slide 18

Slide 18 text

PHP execution time • initialization!!! memory allocation => composer, DI… • useful execution

Slide 19

Slide 19 text

aren’t we wasting A LOT of resources?

Slide 20

Slide 20 text

YES so…what else?

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

React PHP •reactor pattern, event loop •NodeJS style! •CLI PHP process •acts as an http server •===> globals persist! <====

Slide 23

Slide 23 text

PHP-PM •acts as a process manager on top of React-php •also written in plain PHP •Much like PHP-FPM, but no fcgi

Slide 24

Slide 24 text

show time!

Slide 25

Slide 25 text

so…is it fast/er?

Slide 26

Slide 26 text

test environment •1 VB, single core, 1GB RAM •ulabox.com website •Full Symfony 2.8.8, prod env •PHP-FPM: opcache, 5 workers •PHP-PM: no-opcache, 5 workers

Slide 27

Slide 27 text

0 10 20 30 40 median request time (ms) React FPM 0 20 40 60 80 100 requests per second React FPM

Slide 28

Slide 28 text

~35-40% faster

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

important caveats •globals globals globals! •debugging becomes weird •Careful with Doctrine! •memory leaks •not production ready, still buggy

Slide 31

Slide 31 text

the future •still work to do! •a whole new async world! •future default PHP app server? •it’s written in PHP => explore!!

Slide 32

Slide 32 text

resources! •github.com/reactphp •github.com/php-pm

Slide 33

Slide 33 text

questions?

Slide 34

Slide 34 text

gràcies ;) we are hiring!