Introduction to APC

  • 2,342 views
Uploaded on

Introduction to APC: Singapore PHP Usergroup Meetup April 2010. …

Introduction to APC: Singapore PHP Usergroup Meetup April 2010.

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

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
2,342
On Slideshare
0
From Embeds
0
Number of Embeds
11

Actions

Shares
Downloads
21
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

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