SlideShare a Scribd company logo
Improving PHP Application performance  with APC Presented by James McLean
Improving PHP Application Performance with APC Who is this clown? PHP Introduction APC Introduction Testing Environment Opcodes? APC Installation APC Configuration APC Shared Memory APC Vanilla Install Performance APC & Stat APC & Caching Variables Conclusion
Who is this clown? PHP User since early Version 3. PHP Developer since early 2000 Zend Certified Engineer, PHP5 Web Developer at Iugo Pty Ltd, Adelaide. irc://irc.freenode.org/#phpc Channel Operator Personal Blog:  http://blog.phpguy.org
PHP Introduction PHP: Hypertext Preprocessor PHP/FI, Created in 1995 by Rasmus Lerdorf General Purpose Language Ideally suited to Web Development Can be used on the command line and for shell scripting, even for GUI apps!
APC Introduction APC: Alternative PHP Cache. Free, Open Source Opcode Cache. Benefit from simply installing the module, no code changes required. Ability to cache variables with code changes.
Testing Environment All tests were performed with the following: Intel Core 2 Quad Q9450 @ 3.2Ghz 8GB DDR2 800Mhz RAM APC 3.0.19, PHP 5.2.6 & PHP 5.2.6 From Gentoo Portage Custom OO PHP5 Framework PDO Used for all Database Access ab2 -k -c 50 -t 300 http://devwww.vortexdvd.com/
Opcodes? Opcodes are, simply, compiled PHP code. Discarded after the page has been executed. PHP Page Compilation: - Scanning / Lexing.  Plain Text Code turned into Tokens - Parsing.  Tokens are collected into Expressions. - Compilation.  Expressions are translated into Opcodes for Execution. - Execution.  Opcode stacks are processed, one at a time.  APC caches the Opcodes for later execution!
APC Installation Quick and Easy to install! PECL -  http://pecl.php.net -  #   pecl install apc . GNU/Linux Package Managers. - Gentoo Portage:  dev-php5/pecl-apc . - Debian/Ubuntu:  # pecl install apc Windows:  http://pecl4win.php.net Ensure the module is loaded into php.ini. -  extension=apc.so
APC Configuration In a basic APC installation, two major configuration options affect the performance of your applications apc.shm_size – Shared Memory Size. apc.stat – Stat files.
APC Shared Memory apc.shm_size controls how much memory will be set aside for APC to use. Memory is cheap!  Increasing the memory available to APC will not always improve performance signifigantly.
APC Vanilla Install Performance As mentioned before, you can get a performance gain, simply from installing the module. No APC Enabled: APC Enabled, Vanilla Settings: Requests per second:  71.27 [#/sec] (mean) Time per request:  701.510 [ms] (mean) Time per request:  14.030 [ms] (mean, across all concurrent requests) Transfer rate:  898.79 [Kbytes/sec] received Requests per second:  93.55  [#/sec] (mean) Time per request:  534.454  [ms] (mean) Time per request:  10.689  [ms] (mean, across all concurrent requests) Transfer rate:  1181.05  [Kbytes/sec] received Whoa!
APC & Stat No.. Not that stat...
APC & Stat By Default, PHP checks the modification time of the script and all includes at Execution. You can disable stat checking, for extra performance! Web Server restarts required when files change.
APC & Stat Stat Testing: $ ab2 -k -c 50 -t 300 http://devwww.vortexdvd.com/ apc.stat = on apc.stat = off Requests per second:  129.46 [#/sec] (mean) Time per request:  386.208 [ms] (mean) Time per request:  7.724 [ms] (mean, across all concurrent requests) Transfer rate:  1634.77 [Kbytes/sec] received Requests per second:  278.58  [#/sec] (mean) Time per request:  179.481  [ms] (mean) Time per request:  3.590  [ms] (mean, across all concurrent requests) Transfer rate:  3516.54  [Kbytes/sec] received EPIC WIN!!
APC & Stat Turning off File Stat yields an excellent performance benefit! Best if your site files don't change very often. Requires a web-server restart when the files are changed.
APC & Variable Caching APC allows you to cache variables for speed. Large variables and variables that dont change often, ideally suited to variable caching. Caching Database Query Result Sets can result in extra performance, and save your database!
APC & Variable Caching Custom code to enable or disable use of the Query Cache. Query Cache Disabled Query Cache Enabled Requests per second:  124.55  [#/sec] (mean) Time per request:  401.436  [ms] (mean) Time per request:  8.029  [ms] (mean, across all concurrent requests) Transfer rate:  1572.57  [Kbytes/sec] received Requests per second:  91.97 [#/sec] (mean) Time per request:  543.680 [ms] (mean) Time per request:  10.874 [ms] (mean, across all concurrent requests) Transfer rate:  1160.01 [Kbytes/sec] received WIN!
Conclusion APC is a great way to get some 'free speed' out of your applications. - Benefit from installing the module, vanilla config! - Minor config changes for a huge benefit with Stat APC doesn't suit everyone and all situations. - Does not suit distributed servers or load balanced. Overall, APC is worth a look next time you need to improve your PHP application performance.
References http://www.php.net/apc http://www.debian-administration.org/articles/574 http://blog.phpguy.org/2007/09/20/apc-and-web-application-performance/ http://blog.phpguy.org/2007/09/21/apc-and-web-application-performance-take-2/ http://blog.libssh2.org/index.php?/archives/92-Understanding-Opcodes.html
Ad

Recommended

PHP Performance with APC + Memcached
PHP Performance with APC + Memcached
Ford AntiTrust
 
Apc presentation
Apc presentation
guestef8544
 
/* pOrt80BKK */ - PHP Day - PHP Performance with APC + Memcached for Windows
/* pOrt80BKK */ - PHP Day - PHP Performance with APC + Memcached for Windows
Ford AntiTrust
 
Caching with Memcached and APC
Caching with Memcached and APC
Ben Ramsey
 
Oscon 2010 - ATS
Oscon 2010 - ATS
Leif Hedstrom
 
High Concurrency Architecture and Laravel Performance Tuning
High Concurrency Architecture and Laravel Performance Tuning
Albert Chen
 
Northeast PHP - High Performance PHP
Northeast PHP - High Performance PHP
Jonathan Klein
 
Memcached B box presentation
Memcached B box presentation
Nagesh Chinkeri
 
Performance scalability brandonlyon
Performance scalability brandonlyon
Digitaria
 
Roy foubister (hosting high traffic sites on a tight budget)
Roy foubister (hosting high traffic sites on a tight budget)
WordCamp Cape Town
 
Accelerate your ColdFusion Applications using Caching
Accelerate your ColdFusion Applications using Caching
ColdFusionConference
 
Memcached Study
Memcached Study
nam kwangjin
 
Moxi - Memcached Proxy
Moxi - Memcached Proxy
NorthScale
 
Integrated Cache on Netscaler
Integrated Cache on Netscaler
Mark Hillick
 
Memcached Presentation
Memcached Presentation
Asif Ali
 
Os Harkins
Os Harkins
oscon2007
 
Fastest Servlets in the West
Fastest Servlets in the West
Stuart (Pid) Williams
 
Zendcon scaling magento
Zendcon scaling magento
Mathew Beane
 
HTTP caching with Varnish
HTTP caching with Varnish
David de Boer
 
Going crazy with Varnish and Symfony
Going crazy with Varnish and Symfony
David de Boer
 
Give Your Site a Boost with Memcache
Give Your Site a Boost with Memcache
Ben Ramsey
 
Using memcache to improve php performance
Using memcache to improve php performance
Sudar Muthu
 
Performance Tuning - MuraCon 2012
Performance Tuning - MuraCon 2012
eballisty
 
Memcached
Memcached
Shrawan Kumar Nirala
 
Dutch php conference_2010_opm
Dutch php conference_2010_opm
isnull
 
Memcached Code Camp 2009
Memcached Code Camp 2009
NorthScale
 
J Ruby Whirlwind Tour
J Ruby Whirlwind Tour
oscon2007
 
Zend_Cache: how to improve the performance of PHP applications
Zend_Cache: how to improve the performance of PHP applications
Enrico Zimuel
 
Getting Social: What You Need To Do Now To Engage with a new Social World.
Getting Social: What You Need To Do Now To Engage with a new Social World.
Eric T. Tung
 
Phing - A PHP Build Tool (An Introduction)
Phing - A PHP Build Tool (An Introduction)
Michiel Rook
 

More Related Content

What's hot (20)

Performance scalability brandonlyon
Performance scalability brandonlyon
Digitaria
 
Roy foubister (hosting high traffic sites on a tight budget)
Roy foubister (hosting high traffic sites on a tight budget)
WordCamp Cape Town
 
Accelerate your ColdFusion Applications using Caching
Accelerate your ColdFusion Applications using Caching
ColdFusionConference
 
Memcached Study
Memcached Study
nam kwangjin
 
Moxi - Memcached Proxy
Moxi - Memcached Proxy
NorthScale
 
Integrated Cache on Netscaler
Integrated Cache on Netscaler
Mark Hillick
 
Memcached Presentation
Memcached Presentation
Asif Ali
 
Os Harkins
Os Harkins
oscon2007
 
Fastest Servlets in the West
Fastest Servlets in the West
Stuart (Pid) Williams
 
Zendcon scaling magento
Zendcon scaling magento
Mathew Beane
 
HTTP caching with Varnish
HTTP caching with Varnish
David de Boer
 
Going crazy with Varnish and Symfony
Going crazy with Varnish and Symfony
David de Boer
 
Give Your Site a Boost with Memcache
Give Your Site a Boost with Memcache
Ben Ramsey
 
Using memcache to improve php performance
Using memcache to improve php performance
Sudar Muthu
 
Performance Tuning - MuraCon 2012
Performance Tuning - MuraCon 2012
eballisty
 
Memcached
Memcached
Shrawan Kumar Nirala
 
Dutch php conference_2010_opm
Dutch php conference_2010_opm
isnull
 
Memcached Code Camp 2009
Memcached Code Camp 2009
NorthScale
 
J Ruby Whirlwind Tour
J Ruby Whirlwind Tour
oscon2007
 
Zend_Cache: how to improve the performance of PHP applications
Zend_Cache: how to improve the performance of PHP applications
Enrico Zimuel
 
Performance scalability brandonlyon
Performance scalability brandonlyon
Digitaria
 
Roy foubister (hosting high traffic sites on a tight budget)
Roy foubister (hosting high traffic sites on a tight budget)
WordCamp Cape Town
 
Accelerate your ColdFusion Applications using Caching
Accelerate your ColdFusion Applications using Caching
ColdFusionConference
 
Moxi - Memcached Proxy
Moxi - Memcached Proxy
NorthScale
 
Integrated Cache on Netscaler
Integrated Cache on Netscaler
Mark Hillick
 
Memcached Presentation
Memcached Presentation
Asif Ali
 
Zendcon scaling magento
Zendcon scaling magento
Mathew Beane
 
HTTP caching with Varnish
HTTP caching with Varnish
David de Boer
 
Going crazy with Varnish and Symfony
Going crazy with Varnish and Symfony
David de Boer
 
Give Your Site a Boost with Memcache
Give Your Site a Boost with Memcache
Ben Ramsey
 
Using memcache to improve php performance
Using memcache to improve php performance
Sudar Muthu
 
Performance Tuning - MuraCon 2012
Performance Tuning - MuraCon 2012
eballisty
 
Dutch php conference_2010_opm
Dutch php conference_2010_opm
isnull
 
Memcached Code Camp 2009
Memcached Code Camp 2009
NorthScale
 
J Ruby Whirlwind Tour
J Ruby Whirlwind Tour
oscon2007
 
Zend_Cache: how to improve the performance of PHP applications
Zend_Cache: how to improve the performance of PHP applications
Enrico Zimuel
 

Viewers also liked (20)

Getting Social: What You Need To Do Now To Engage with a new Social World.
Getting Social: What You Need To Do Now To Engage with a new Social World.
Eric T. Tung
 
Phing - A PHP Build Tool (An Introduction)
Phing - A PHP Build Tool (An Introduction)
Michiel Rook
 
如何使用 Xhprof 分析網站效能 (真實案例2)
如何使用 Xhprof 分析網站效能 (真實案例2)
Cyril Wang
 
如何使用 Xhprof 分析網站效能 (真實案例)
如何使用 Xhprof 分析網站效能 (真實案例)
Cyril Wang
 
Desktop Apps in a Javascript World - Electron
Desktop Apps in a Javascript World - Electron
Marc MacLeod
 
Edge Conf Rendering Performance Panel
Edge Conf Rendering Performance Panel
Jonathan Klein
 
EscConf - Deep Dive Frontend Optimization
EscConf - Deep Dive Frontend Optimization
Jonathan Klein
 
JSDay 2013 - Practical Responsive Web Design
JSDay 2013 - Practical Responsive Web Design
Jonathan Klein
 
Riding rails for 10 years
Riding rails for 10 years
jduff
 
UXFest - RUM Distillation 101
UXFest - RUM Distillation 101
Jonathan Klein
 
DIY Synthetic: Private WebPagetest Magic
DIY Synthetic: Private WebPagetest Magic
Jonathan Klein
 
PHP On Steroids
PHP On Steroids
Jonathan Oxer
 
BTV PHP - Building Fast Websites
BTV PHP - Building Fast Websites
Jonathan Klein
 
PHPDay 2013 - High Performance PHP
PHPDay 2013 - High Performance PHP
Jonathan Klein
 
Scaling PHP to 40 Million Uniques
Scaling PHP to 40 Million Uniques
Jonathan Klein
 
Integrating React.js with PHP projects
Integrating React.js with PHP projects
Ignacio Martín
 
PHP UK 2017 - Don't Lose Sleep - Secure Your REST
PHP UK 2017 - Don't Lose Sleep - Secure Your REST
Adam Englander
 
How Slow Load Times Hurt Your Bottom Line (And 17 Things You Can Do to Fix It)
How Slow Load Times Hurt Your Bottom Line (And 17 Things You Can Do to Fix It)
Tammy Everts
 
How Shopify Scales Rails
How Shopify Scales Rails
jduff
 
Black widow project
Black widow project
vermigle
 
Getting Social: What You Need To Do Now To Engage with a new Social World.
Getting Social: What You Need To Do Now To Engage with a new Social World.
Eric T. Tung
 
Phing - A PHP Build Tool (An Introduction)
Phing - A PHP Build Tool (An Introduction)
Michiel Rook
 
如何使用 Xhprof 分析網站效能 (真實案例2)
如何使用 Xhprof 分析網站效能 (真實案例2)
Cyril Wang
 
如何使用 Xhprof 分析網站效能 (真實案例)
如何使用 Xhprof 分析網站效能 (真實案例)
Cyril Wang
 
Desktop Apps in a Javascript World - Electron
Desktop Apps in a Javascript World - Electron
Marc MacLeod
 
Edge Conf Rendering Performance Panel
Edge Conf Rendering Performance Panel
Jonathan Klein
 
EscConf - Deep Dive Frontend Optimization
EscConf - Deep Dive Frontend Optimization
Jonathan Klein
 
JSDay 2013 - Practical Responsive Web Design
JSDay 2013 - Practical Responsive Web Design
Jonathan Klein
 
Riding rails for 10 years
Riding rails for 10 years
jduff
 
UXFest - RUM Distillation 101
UXFest - RUM Distillation 101
Jonathan Klein
 
DIY Synthetic: Private WebPagetest Magic
DIY Synthetic: Private WebPagetest Magic
Jonathan Klein
 
BTV PHP - Building Fast Websites
BTV PHP - Building Fast Websites
Jonathan Klein
 
PHPDay 2013 - High Performance PHP
PHPDay 2013 - High Performance PHP
Jonathan Klein
 
Scaling PHP to 40 Million Uniques
Scaling PHP to 40 Million Uniques
Jonathan Klein
 
Integrating React.js with PHP projects
Integrating React.js with PHP projects
Ignacio Martín
 
PHP UK 2017 - Don't Lose Sleep - Secure Your REST
PHP UK 2017 - Don't Lose Sleep - Secure Your REST
Adam Englander
 
How Slow Load Times Hurt Your Bottom Line (And 17 Things You Can Do to Fix It)
How Slow Load Times Hurt Your Bottom Line (And 17 Things You Can Do to Fix It)
Tammy Everts
 
How Shopify Scales Rails
How Shopify Scales Rails
jduff
 
Black widow project
Black widow project
vermigle
 
Ad

Similar to Improving PHP Application Performance with APC (20)

Introduction to APC
Introduction to APC
Chin Yong Tang
 
Os Gopal
Os Gopal
oscon2007
 
php & performance
php & performance
simon8410
 
PHP & Performance
PHP & Performance
毅 吕
 
Caching strategy and apc
Caching strategy and apc
Võ Duy Tuấn
 
Heavy Web Optimization: Backend
Heavy Web Optimization: Backend
Võ Duy Tuấn
 
Caching
Caching
Aaron Scherer
 
Zend Server: A Guided Tour
Zend Server: A Guided Tour
Shahar Evron
 
Scalability In PHP
Scalability In PHP
Ian Selby
 
Dutch php conference_apc_mem2010
Dutch php conference_apc_mem2010
isnull
 
Apc Memcached Confoo 2011
Apc Memcached Confoo 2011
Bachkoutou Toutou
 
Performance and Scalability
Performance and Scalability
Mediacurrent
 
2013 - Dustin whittle - Escalando PHP en la vida real
2013 - Dustin whittle - Escalando PHP en la vida real
PHP Conference Argentina
 
Php optimization
Php optimization
Fabrizio Parrella
 
PHP Performance: Principles and tools
PHP Performance: Principles and tools
10n Software, LLC
 
Making WordPress Fly
Making WordPress Fly
East Bay WordPress Meetup
 
PHP Performance tuning for Drupal 8
PHP Performance tuning for Drupal 8
Acquia
 
Web Performance, Scalability, and Testing Techniques - Boston PHP Meetup
Web Performance, Scalability, and Testing Techniques - Boston PHP Meetup
Jonathan Klein
 
Caching Data For Performance
Caching Data For Performance
Dave Ross
 
Performance tuning with zend framework
Performance tuning with zend framework
Alan Seiden
 
php & performance
php & performance
simon8410
 
PHP & Performance
PHP & Performance
毅 吕
 
Caching strategy and apc
Caching strategy and apc
Võ Duy Tuấn
 
Heavy Web Optimization: Backend
Heavy Web Optimization: Backend
Võ Duy Tuấn
 
Zend Server: A Guided Tour
Zend Server: A Guided Tour
Shahar Evron
 
Scalability In PHP
Scalability In PHP
Ian Selby
 
Dutch php conference_apc_mem2010
Dutch php conference_apc_mem2010
isnull
 
Performance and Scalability
Performance and Scalability
Mediacurrent
 
2013 - Dustin whittle - Escalando PHP en la vida real
2013 - Dustin whittle - Escalando PHP en la vida real
PHP Conference Argentina
 
PHP Performance: Principles and tools
PHP Performance: Principles and tools
10n Software, LLC
 
PHP Performance tuning for Drupal 8
PHP Performance tuning for Drupal 8
Acquia
 
Web Performance, Scalability, and Testing Techniques - Boston PHP Meetup
Web Performance, Scalability, and Testing Techniques - Boston PHP Meetup
Jonathan Klein
 
Caching Data For Performance
Caching Data For Performance
Dave Ross
 
Performance tuning with zend framework
Performance tuning with zend framework
Alan Seiden
 
Ad

Recently uploaded (20)

Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Safe Software
 
9-1-1 Addressing: End-to-End Automation Using FME
9-1-1 Addressing: End-to-End Automation Using FME
Safe Software
 
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Josef Weingand
 
Curietech AI in action - Accelerate MuleSoft development
Curietech AI in action - Accelerate MuleSoft development
shyamraj55
 
Lessons Learned from Developing Secure AI Workflows.pdf
Lessons Learned from Developing Secure AI Workflows.pdf
Priyanka Aash
 
MuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API Catalog
shyamraj55
 
Security Tips for Enterprise Azure Solutions
Security Tips for Enterprise Azure Solutions
Michele Leroux Bustamante
 
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
pcprocore
 
EIS-Webinar-Engineering-Retail-Infrastructure-06-16-2025.pdf
EIS-Webinar-Engineering-Retail-Infrastructure-06-16-2025.pdf
Earley Information Science
 
OpenPOWER Foundation & Open-Source Core Innovations
OpenPOWER Foundation & Open-Source Core Innovations
IBM
 
A Constitutional Quagmire - Ethical Minefields of AI, Cyber, and Privacy.pdf
A Constitutional Quagmire - Ethical Minefields of AI, Cyber, and Privacy.pdf
Priyanka Aash
 
cnc-processing-centers-centateq-p-110-en.pdf
cnc-processing-centers-centateq-p-110-en.pdf
AmirStern2
 
Techniques for Automatic Device Identification and Network Assignment.pdf
Techniques for Automatic Device Identification and Network Assignment.pdf
Priyanka Aash
 
AI vs Human Writing: Can You Tell the Difference?
AI vs Human Writing: Can You Tell the Difference?
Shashi Sathyanarayana, Ph.D
 
UserCon Belgium: Honey, VMware increased my bill
UserCon Belgium: Honey, VMware increased my bill
stijn40
 
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Priyanka Aash
 
Quantum AI Discoveries: Fractal Patterns Consciousness and Cyclical Universes
Quantum AI Discoveries: Fractal Patterns Consciousness and Cyclical Universes
Saikat Basu
 
The Future of Technology: 2025-2125 by Saikat Basu.pdf
The Future of Technology: 2025-2125 by Saikat Basu.pdf
Saikat Basu
 
Cluster-Based Multi-Objective Metamorphic Test Case Pair Selection for Deep N...
Cluster-Based Multi-Objective Metamorphic Test Case Pair Selection for Deep N...
janeliewang985
 
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
Fwdays
 
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Safe Software
 
9-1-1 Addressing: End-to-End Automation Using FME
9-1-1 Addressing: End-to-End Automation Using FME
Safe Software
 
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Josef Weingand
 
Curietech AI in action - Accelerate MuleSoft development
Curietech AI in action - Accelerate MuleSoft development
shyamraj55
 
Lessons Learned from Developing Secure AI Workflows.pdf
Lessons Learned from Developing Secure AI Workflows.pdf
Priyanka Aash
 
MuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API Catalog
shyamraj55
 
Security Tips for Enterprise Azure Solutions
Security Tips for Enterprise Azure Solutions
Michele Leroux Bustamante
 
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
pcprocore
 
EIS-Webinar-Engineering-Retail-Infrastructure-06-16-2025.pdf
EIS-Webinar-Engineering-Retail-Infrastructure-06-16-2025.pdf
Earley Information Science
 
OpenPOWER Foundation & Open-Source Core Innovations
OpenPOWER Foundation & Open-Source Core Innovations
IBM
 
A Constitutional Quagmire - Ethical Minefields of AI, Cyber, and Privacy.pdf
A Constitutional Quagmire - Ethical Minefields of AI, Cyber, and Privacy.pdf
Priyanka Aash
 
cnc-processing-centers-centateq-p-110-en.pdf
cnc-processing-centers-centateq-p-110-en.pdf
AmirStern2
 
Techniques for Automatic Device Identification and Network Assignment.pdf
Techniques for Automatic Device Identification and Network Assignment.pdf
Priyanka Aash
 
AI vs Human Writing: Can You Tell the Difference?
AI vs Human Writing: Can You Tell the Difference?
Shashi Sathyanarayana, Ph.D
 
UserCon Belgium: Honey, VMware increased my bill
UserCon Belgium: Honey, VMware increased my bill
stijn40
 
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Priyanka Aash
 
Quantum AI Discoveries: Fractal Patterns Consciousness and Cyclical Universes
Quantum AI Discoveries: Fractal Patterns Consciousness and Cyclical Universes
Saikat Basu
 
The Future of Technology: 2025-2125 by Saikat Basu.pdf
The Future of Technology: 2025-2125 by Saikat Basu.pdf
Saikat Basu
 
Cluster-Based Multi-Objective Metamorphic Test Case Pair Selection for Deep N...
Cluster-Based Multi-Objective Metamorphic Test Case Pair Selection for Deep N...
janeliewang985
 
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
Fwdays
 

Improving PHP Application Performance with APC

  • 1. Improving PHP Application performance with APC Presented by James McLean
  • 2. Improving PHP Application Performance with APC Who is this clown? PHP Introduction APC Introduction Testing Environment Opcodes? APC Installation APC Configuration APC Shared Memory APC Vanilla Install Performance APC & Stat APC & Caching Variables Conclusion
  • 3. Who is this clown? PHP User since early Version 3. PHP Developer since early 2000 Zend Certified Engineer, PHP5 Web Developer at Iugo Pty Ltd, Adelaide. irc://irc.freenode.org/#phpc Channel Operator Personal Blog: http://blog.phpguy.org
  • 4. PHP Introduction PHP: Hypertext Preprocessor PHP/FI, Created in 1995 by Rasmus Lerdorf General Purpose Language Ideally suited to Web Development Can be used on the command line and for shell scripting, even for GUI apps!
  • 5. APC Introduction APC: Alternative PHP Cache. Free, Open Source Opcode Cache. Benefit from simply installing the module, no code changes required. Ability to cache variables with code changes.
  • 6. Testing Environment All tests were performed with the following: Intel Core 2 Quad Q9450 @ 3.2Ghz 8GB DDR2 800Mhz RAM APC 3.0.19, PHP 5.2.6 & PHP 5.2.6 From Gentoo Portage Custom OO PHP5 Framework PDO Used for all Database Access ab2 -k -c 50 -t 300 http://devwww.vortexdvd.com/
  • 7. Opcodes? Opcodes are, simply, compiled PHP code. Discarded after the page has been executed. PHP Page Compilation: - Scanning / Lexing. Plain Text Code turned into Tokens - Parsing. Tokens are collected into Expressions. - Compilation. Expressions are translated into Opcodes for Execution. - Execution. Opcode stacks are processed, one at a time. APC caches the Opcodes for later execution!
  • 8. APC Installation Quick and Easy to install! PECL - http://pecl.php.net - # pecl install apc . GNU/Linux Package Managers. - Gentoo Portage: dev-php5/pecl-apc . - Debian/Ubuntu: # pecl install apc Windows: http://pecl4win.php.net Ensure the module is loaded into php.ini. - extension=apc.so
  • 9. APC Configuration In a basic APC installation, two major configuration options affect the performance of your applications apc.shm_size – Shared Memory Size. apc.stat – Stat files.
  • 10. APC Shared Memory apc.shm_size controls how much memory will be set aside for APC to use. Memory is cheap! Increasing the memory available to APC will not always improve performance signifigantly.
  • 11. APC Vanilla Install Performance As mentioned before, you can get a performance gain, simply from installing the module. No APC Enabled: APC Enabled, Vanilla Settings: Requests per second: 71.27 [#/sec] (mean) Time per request: 701.510 [ms] (mean) Time per request: 14.030 [ms] (mean, across all concurrent requests) Transfer rate: 898.79 [Kbytes/sec] received Requests per second: 93.55 [#/sec] (mean) Time per request: 534.454 [ms] (mean) Time per request: 10.689 [ms] (mean, across all concurrent requests) Transfer rate: 1181.05 [Kbytes/sec] received Whoa!
  • 12. APC & Stat No.. Not that stat...
  • 13. APC & Stat By Default, PHP checks the modification time of the script and all includes at Execution. You can disable stat checking, for extra performance! Web Server restarts required when files change.
  • 14. APC & Stat Stat Testing: $ ab2 -k -c 50 -t 300 http://devwww.vortexdvd.com/ apc.stat = on apc.stat = off Requests per second: 129.46 [#/sec] (mean) Time per request: 386.208 [ms] (mean) Time per request: 7.724 [ms] (mean, across all concurrent requests) Transfer rate: 1634.77 [Kbytes/sec] received Requests per second: 278.58 [#/sec] (mean) Time per request: 179.481 [ms] (mean) Time per request: 3.590 [ms] (mean, across all concurrent requests) Transfer rate: 3516.54 [Kbytes/sec] received EPIC WIN!!
  • 15. APC & Stat Turning off File Stat yields an excellent performance benefit! Best if your site files don't change very often. Requires a web-server restart when the files are changed.
  • 16. APC & Variable Caching APC allows you to cache variables for speed. Large variables and variables that dont change often, ideally suited to variable caching. Caching Database Query Result Sets can result in extra performance, and save your database!
  • 17. APC & Variable Caching Custom code to enable or disable use of the Query Cache. Query Cache Disabled Query Cache Enabled Requests per second: 124.55 [#/sec] (mean) Time per request: 401.436 [ms] (mean) Time per request: 8.029 [ms] (mean, across all concurrent requests) Transfer rate: 1572.57 [Kbytes/sec] received Requests per second: 91.97 [#/sec] (mean) Time per request: 543.680 [ms] (mean) Time per request: 10.874 [ms] (mean, across all concurrent requests) Transfer rate: 1160.01 [Kbytes/sec] received WIN!
  • 18. Conclusion APC is a great way to get some 'free speed' out of your applications. - Benefit from installing the module, vanilla config! - Minor config changes for a huge benefit with Stat APC doesn't suit everyone and all situations. - Does not suit distributed servers or load balanced. Overall, APC is worth a look next time you need to improve your PHP application performance.
  • 19. References http://www.php.net/apc http://www.debian-administration.org/articles/574 http://blog.phpguy.org/2007/09/20/apc-and-web-application-performance/ http://blog.phpguy.org/2007/09/21/apc-and-web-application-performance-take-2/ http://blog.libssh2.org/index.php?/archives/92-Understanding-Opcodes.html