Introduction to APC <ul><li>PHP Usergroup Meetup April 2010 </li></ul>
Background <ul><li>Web Engineer
Experience </li><ul><li>Local Media Company, managing a news portal
A privately funded startup </li></ul></ul>
What is APC <ul><li>Armoured Personal Carrier </li><ul><li>Example: Bionix by ST-Kinetics </li></ul></ul>http://en.wikiped...
What is APC <ul><li>Alternative PHP Cache
http://www.php.net/manual/en/book.apc.php </li><ul><li>The Alternative PHP Cache (APC) is a free and open opcode cache for...
Installing <ul><li>Debian-based example
Dependencies </li><ul><li>php5-dev, pecl, re2c, gawk, nawk, apache2-threaded-dev </li></ul><li>apt-get install php5-dev ap...
pecl install apc
50+ MB
Windows: http://downloads.php.net/pierre/ </li></ul>
Basic Configuration <ul><li>php.ini </li><ul><li>extension=apc.so
Upcoming SlideShare
Loading in …5
×

Introduction to APC

2,668 views

Published on

Introduction to APC: Singapore PHP Usergroup Meetup April 2010.

A overview of what APC does for PHP with sample code and a simple benchmark.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
2,668
On SlideShare
0
From Embeds
0
Number of Embeds
351
Actions
Shares
0
Downloads
23
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Introduction to APC

  1. 1. Introduction to APC <ul><li>PHP Usergroup Meetup April 2010 </li></ul>
  2. 2. Background <ul><li>Web Engineer
  3. 3. Experience </li><ul><li>Local Media Company, managing a news portal
  4. 4. A privately funded startup </li></ul></ul>
  5. 5. What is APC <ul><li>Armoured Personal Carrier </li><ul><li>Example: Bionix by ST-Kinetics </li></ul></ul>http://en.wikipedia.org/wiki/Bionix_AFV
  6. 6. What is APC <ul><li>Alternative PHP Cache
  7. 7. http://www.php.net/manual/en/book.apc.php </li><ul><li>The Alternative PHP Cache (APC) is a free and open opcode cache for PHP. Its goal is to provide a free, open, and robust framework for caching and optimizing PHP intermediate code. </li></ul></ul>
  8. 8. Installing <ul><li>Debian-based example
  9. 9. Dependencies </li><ul><li>php5-dev, pecl, re2c, gawk, nawk, apache2-threaded-dev </li></ul><li>apt-get install php5-dev apache2-threaded-dev
  10. 10. pecl install apc
  11. 11. 50+ MB
  12. 12. Windows: http://downloads.php.net/pierre/ </li></ul>
  13. 13. Basic Configuration <ul><li>php.ini </li><ul><li>extension=apc.so
  14. 14. extension=php_apc.dll ( c:/php/ext ) </li></ul><li>apc.enabled
  15. 15. apc.num_files_hint, apc.user_entries_hint
  16. 16. apc.ttl, apc.user_ttl
  17. 17. apc.shm_segments, apc.shm_size </li></ul>
  18. 18. APC Function <ul><li>bool apc_store(string $key, mixed $var [, $ttl =0])
  19. 19. mixed apc_fetch(string $key [,bool &$success])
  20. 20. bool apc_delete(string $key)
  21. 21. Poor Man Key/Value Store </li></ul>
  22. 22. Quick Performance Bench <ul><li>Wordpress </li><ul><li>ab -n 50 http://phpmeetupsg.com/wordpress/
  23. 23. Without APC: ~4.8 req/s
  24. 24. With APC: ~16.0 - 17.0 req/s </li></ul><li>Fineprint: 2GB, T2300 Dual Core System </li></ul>
  25. 25. Configuration & Performance <ul><li>Wordpress </li><ul><li>With apc.stat=0: ~18 - 19+ req/s
  26. 26. Trade off: Server restart required for code changes </li></ul><li>Other Configs </li><ul><li>apc.num_files_hint, apc.user_entries_hint
  27. 27. apc.ttl, apc.user_ttl
  28. 28. apc.shm_segments, apc.shm_size </li></ul></ul>
  29. 29. apc.php <ul><li>APC monitor </li><ul><li>Move from /usr/php/apc.php to a http accessible page
  30. 30. A phpinfo() for APC
  31. 31. Show status of </li><ul><li>Memory usage
  32. 32. Script Cache/Hits </li></ul><li>Use to tune the configuration </li><ul><li>apc.shm_size </li></ul></ul></ul>
  33. 33. Pitfalls <ul><li>Code that uses Xcache functions </li><ul><li>xcache_get
  34. 34. xcache_set... </li></ul><li>Disabling APC does not prevent it from loading into memory </li></ul>
  35. 35. Moving Forward <ul><li>APC is to be release as part of PHP6
  36. 36. http://www.php.net/~derick/meeting-notes.html#id60
  37. 37. Seems to be selected on merit of license compatiblity </li></ul>
  38. 38. Conclusion <ul><li>APC offer performance out of the box
  39. 39. Can configure to tweak to application need
  40. 40. Comes with monitoring/feedback system
  41. 41. To be packaged with PHP 6 </li></ul>Tang Chin Yong http://thinkingnectar.com http://twitter.com/chinyong Quote of the day: The closest I have gotten to .net is php.net

×