Improving PHP Application Performance with APC

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    10 Favorites

    Improving PHP Application Performance with APC - Presentation Transcript

    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

    + vortexauvortexau, 11 months ago

    custom

    4016 views, 10 favs, 11 embeds more stats

    Overview of performance gains with APC

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 4016
      • 3635 on SlideShare
      • 381 from embeds
    • Comments 0
    • Favorites 10
    • Downloads 0
    Most viewed embeds
    • 265 views on http://blog.phpguy.org
    • 73 views on http://www.planet-php.net
    • 16 views on http://planet-php.org
    • 8 views on http://lj-toys.com
    • 7 views on http://www.planet-php.org

    more

    All embeds
    • 265 views on http://blog.phpguy.org
    • 73 views on http://www.planet-php.net
    • 16 views on http://planet-php.org
    • 8 views on http://lj-toys.com
    • 7 views on http://www.planet-php.org
    • 6 views on http://static.slideshare.net
    • 2 views on http://planet-php.net
    • 1 views on file://
    • 1 views on http://xss.yandex.net
    • 1 views on applewebdata://0B839064-0DC3-4BA0-A165-2F72342C18D3
    • 1 views on http://www.phpeye.com

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories