Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Phalcon PHP

5d6f567f9109789fd9f702959768e35d?s=47 Phalcon PHP
December 07, 2011

Phalcon PHP

PHP Framework written as C extension

5d6f567f9109789fd9f702959768e35d?s=128

Phalcon PHP

December 07, 2011
Tweet

Transcript

  1. Phalcon PHP Framework delivered as C extension

  2. Why? •  Use  of  frameworks  has  become  mandatory   in

     professional  development  with  PHP   •  They  offer  a  philosophy  and  organized   structures  to  easily  maintain  projects  wri?ng   less  code  and  making  work  more  fun  
  3. How PHP works? 1.  PHP  have  dynamic  and  weak  typing

      discipline   2.  PHP  is  interpreted  (not  compiled)   3.  Every  ?me  a  script  is  loaded,  should  be   interpreted  by  PHP   4.  If  a  bytecode  cache  (like  APC)  isn’t  used,   syntax  checking  is  performed  every  ?me  
  4. How traditional php frameworks works? 1.  Many  files  with  classes

     and  func?ons  are  read  at   every  request  made.  Disk  reading  is  expensive  in   terms  of  performance   2.  Modern  frameworks  use  lazy  loading  technique   (autoload)  for  load  and  execute  only  code  needed   3.  Con?nuous  loading/interpre?ng  could  be  expensive   and  impact  your  applica?on  performance   4.  When  you  use  a  framework  most  of  the  code   remain  the  same  across  development.  Why  load  and   interpret  it  every  ?me?
  5. How a PHP C extension works? 1.  C extensions are

    loaded together with PHP one time, on the web server dispatch process 2.  Classes and functions provided by the extension are ready to use for any application 3.  The code isn’t interpreted because it is compiled to a specific platform and processor
  6. How Phalcon works? 1.  Components  are  loosely  coupled.  You  may

     use  the   components  you  want  without  depending  on  a  full   stack   2.  Low-­‐level  op?miza?ons  provide  the  lowest   overhead  for  MVC-­‐based  applica?ons   3.  Interact  with  databases  with  maximum  performance   by  using  a  C-­‐language  ORM  for  PHP   4.  Phalcon  is  directly  engaged  with  PHP,  so  it  can   directly  access  internal  structures  op?mizing   execu?on  as  well
  7. Traditional Frameworks Phalcon Interpretation of hundreds or thousands of PHP

    lines on each request Yes No Load dozens of files in each request Yes No Checking the existence of functions, methods, classes, constants at each request Yes No Low-level optimizations gaining microseconds for each request No Yes Compare how Phalcon is faster than other frameworks
  8. Framework Benchmark

  9. None
  10. <h1>Hello!</h1>  

  11. •  Operative System: Mac OS X Snow Leopard 10.6.8 • 

    Web Server: Apache httpd 2.2.21 •  PHP: 5.3.8 + APC 3.1.9 (Without Xdebug) •  CPU: 3.06 Ghz Intel Core 2 Duo •  Main Memory: 4GB 1067 MHz DDR3 •  Hard Disk: 500GB SCSI/SAS HDD Test Environment
  12. ab  –n  1000  –c  5  http://localhost/bench/phalcon  

  13. Framework/Requests per Second 0   500   1000   1500

      2000   2500   114,49   234,53   552,28   662,61   947,56   2489,26   #  Requests/sg  
  14. Framework Total Requests/Average Time 0   1   2  

    3   4   5   6   7   8   9   8,735   4,264   1,811   1,509   1,055   0,422   Time  per  Request/sg  
  15. Number of Interpreted Files per Request 0   20  

    40   60   80   100   120   115   66   46   36   23   4   Number  of  Files  
  16. Allocated Memory per Request 0   0,5   1  

    1,5   2   2,5   3   3,5   3,5   3   1,75   1,25   1,1   0,75   Memory  (MB)  
  17. Give it a try! hep://phalconphp.com