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

Phalcon PHP

Phalcon PHP
December 07, 2011

Phalcon PHP

PHP Framework written as C extension

Phalcon PHP

December 07, 2011
Tweet

More Decks by Phalcon PHP

Other Decks in Technology

Transcript

  1. 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  
  2. 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  
  3. 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?
  4. 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
  5. 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
  6. 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
  7. •  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
  8. Framework/Requests per Second 0   500   1000   1500

      2000   2500   114,49   234,53   552,28   662,61   947,56   2489,26   #  Requests/sg  
  9. 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  
  10. Number of Interpreted Files per Request 0   20  

    40   60   80   100   120   115   66   46   36   23   4   Number  of  Files  
  11. 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)