React PHP & Symfony @ SymfonyCat 2016

React PHP & Symfony @ SymfonyCat 2016

My Reactd PHP & Symfony talk at Symfony Catalunya 2016. Please rate the talk at https://legacy.joind.in/talk/view/18618 thanks! :D

8f2089782f2711659072020ad7227aff?s=128

Albert Casademont

July 22, 2016
Tweet

Transcript

  1. React PHP & Symfony by @acasademont Symfony Catalunya 2016

  2. about me Albert Casademont software engineer @ ulabox.com @acasademont finishing

    my MBA () really obsessed with performance!!
  3. performance

  4. None
  5. the life of a PHP request 1. parsing 2. AST

    (Abstract Syntax Tree) 3. bytecode 4. execution
  6. None
  7. opcache to the rescue

  8. the life of a PHP request 1. parsing 2. AST

    (Abstract Syntax Tree) 3. bytecode 4.execution
  9. set up opcache NOW!! (please )

  10. the life of a PHP request 1. parsing 2. AST

    (Abstract Syntax Tree) 3. bytecode 4.execution
  11. None
  12. NOT BAD!!

  13. set up PHP7 NOW!! (please )

  14. None
  15. 40ms not fast enough!

  16. WTF!

  17. the life of a PHP request 1. parsing 2. AST

    (Abstract Syntax Tree) 3. bytecode 4.execution
  18. PHP execution time • initialization!!! memory allocation => composer, DI…

    • useful execution
  19. aren’t we wasting A LOT of resources?

  20. YES so…what else?

  21. None
  22. React PHP •reactor pattern, event loop •NodeJS style! •CLI PHP

    process •acts as an http server •===> globals persist! <====
  23. PHP-PM •acts as a process manager on top of React-php

    •also written in plain PHP •Much like PHP-FPM, but no fcgi
  24. show time!

  25. so…is it fast/er?

  26. 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
  27. 0 10 20 30 40 median request time (ms) React

    FPM 0 20 40 60 80 100 requests per second React FPM
  28. ~35-40% faster

  29. None
  30. important caveats •globals globals globals! •debugging becomes weird •Careful with

    Doctrine! •memory leaks •not production ready, still buggy
  31. the future •still work to do! •a whole new async

    world! •future default PHP app server? •it’s written in PHP => explore!!
  32. resources! •github.com/reactphp •github.com/php-pm

  33. questions?

  34. gràcies ;) we are hiring!