Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Improving PHP Application Performance with APC

28,335 views

Published on

Overview of performance gains with APC

Published in: Technology
  • DOWNLOAD THAT BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book that can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer that is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story That Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money That the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths that Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Can you please explain why it is not suited for distributed/load balanced environment ?
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • good one, thanks
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • the performance of apc stat or not is very different
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Nice starter pack for PHP APC (alternative php cache)
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Improving PHP Application Performance with APC

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

×