Caching Strategy  & APC  Vo Duy Tuan - CEO/Founder From the PHP developer view
$who_am_I? <ul><li>My Name is Võ Duy Tuấn </li></ul><ul><li>PHP 5 Zend Certified Engineer </li></ul><ul><li>Interests: PHP...
Caching Strategy 1
1.1. Web Caching Introduction
1.2. Cache Strategy <ul><li>Heavy load page/module </li></ul><ul><li>HIT & MISS ratio. </li></ul><ul><li>Budget & Technolo...
1.2.1. Cache WHERE?
1.2.2. Cache WHAT? <ul><li>File </li></ul><ul><li>Code </li></ul><ul><li>Query Result </li></ul><ul><li>Object </li></ul><...
1.2.3. Cache HOW LONG? <ul><li>Cache Clear Type: </li></ul><ul><ul><li>Never Expired </li></ul></ul><ul><ul><li>Normal Exp...
Which cache do you  HATE  most?
Alternative PHP Cache - APC 2
2.1. What is APC? <ul><li>Free PHP Extension </li></ul><ul><li>PHP Opcode cache </li></ul><ul><li>Support User data cache ...
 
2.2. APC Installation <ul><li>On linux: </li></ul><ul><ul><li>pecl install apc </li></ul></ul><ul><li>On Windows: </li></u...
2.3. PHP.INI <ul><li>extension=/home/path/to/apc.so </li></ul><ul><li>[apc] </li></ul><ul><li>apc.enabled =  1 </li></ul><...
phpinfo()
2.4. APC Monitor
 
 
2.5. APC Using
 
2.6. APC Tip <ul><li>Opcode your web code only </li></ul><ul><li>Disable APC for PhpMyAdmin </li></ul><Directory &quot;/my...
2.6. APC Tip.. <ul><li>Cache  STRING  is better than  ARRAY </li></ul><ul><li>Long Time To Live better than Short </li></u...
BEFORE
BEFORE
ANALYSE
AFTER
Short TTL make fragmentation
Short TTL make fragmentation
<ul><li>It’s time to  query  … </li></ul>Thanks you!
Upcoming SlideShare
Loading in...5
×

Caching strategy and apc

3,347

Published on

Presentation about Cache strategy for your website and u

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

No Downloads
Views
Total Views
3,347
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
62
Comments
0
Likes
4
Embeds 0
No embeds

No notes for slide
  • Determine the existing size of your shared memory segment: sysctl -a | grep shmmax Set sysctl -w kernel.shmmax=50331648
  • Determine the existing size of your shared memory segment: sysctl -a | grep shmmax Set sysctl -w kernel.shmmax=50331648
  • Caching strategy and apc

    1. 1. Caching Strategy & APC Vo Duy Tuan - CEO/Founder From the PHP developer view
    2. 2. $who_am_I? <ul><li>My Name is Võ Duy Tuấn </li></ul><ul><li>PHP 5 Zend Certified Engineer </li></ul><ul><li>Interests: PHP, Social Network, Optimize Web </li></ul><ul><li>Works: </li></ul><ul><ul><li>Reader.vn CEO/Founder </li></ul></ul><ul><ul><li>Trainer </li></ul></ul><ul><ul><li>Freelancer </li></ul></ul><ul><ul><li>Help customer Optimize & Speed up website </li></ul></ul>
    3. 3. Caching Strategy 1
    4. 4. 1.1. Web Caching Introduction
    5. 5. 1.2. Cache Strategy <ul><li>Heavy load page/module </li></ul><ul><li>HIT & MISS ratio. </li></ul><ul><li>Budget & Technology </li></ul><ul><li>AJAX </li></ul><ul><li>SEO friendly </li></ul><ul><li>Seperating to small tactics </li></ul><ul><ul><li>Cache WHERE ? </li></ul></ul><ul><ul><li>Cache WHAT ? </li></ul></ul><ul><ul><li>Cache HOW LONG ? </li></ul></ul>
    6. 6. 1.2.1. Cache WHERE?
    7. 7. 1.2.2. Cache WHAT? <ul><li>File </li></ul><ul><li>Code </li></ul><ul><li>Query Result </li></ul><ul><li>Object </li></ul><ul><li>Array </li></ul><ul><li>String </li></ul><ul><li>Number </li></ul><ul><li>… </li></ul>
    8. 8. 1.2.3. Cache HOW LONG? <ul><li>Cache Clear Type: </li></ul><ul><ul><li>Never Expired </li></ul></ul><ul><ul><li>Normal Expired </li></ul></ul><ul><ul><li>Force Expired </li></ul></ul>“ More time caching, less real time data.”
    9. 9. Which cache do you HATE most?
    10. 10. Alternative PHP Cache - APC 2
    11. 11. 2.1. What is APC? <ul><li>Free PHP Extension </li></ul><ul><li>PHP Opcode cache </li></ul><ul><li>Support User data cache </li></ul><ul><li>Run on SAME machine with PHP </li></ul><ul><li>NOT support multi servers </li></ul>
    12. 13. 2.2. APC Installation <ul><li>On linux: </li></ul><ul><ul><li>pecl install apc </li></ul></ul><ul><li>On Windows: </li></ul><ul><ul><li>Download apc DLL file to PHP extension directory such as php_apc.dll </li></ul></ul>
    13. 14. 2.3. PHP.INI <ul><li>extension=/home/path/to/apc.so </li></ul><ul><li>[apc] </li></ul><ul><li>apc.enabled = 1 </li></ul><ul><li>apc.cache_by_default= 0 </li></ul><ul><li>apc.shm_segments=1 </li></ul><ul><li>apc.optimization=0 </li></ul><ul><li>apc.shm_size= 128 </li></ul><ul><li>apc.ttl= 7200 </li></ul><ul><li>apc.user_ttl= 7200 </li></ul>
    14. 15. phpinfo()
    15. 16. 2.4. APC Monitor
    16. 19. 2.5. APC Using
    17. 21. 2.6. APC Tip <ul><li>Opcode your web code only </li></ul><ul><li>Disable APC for PhpMyAdmin </li></ul><Directory &quot;/mysite/public_html/&quot;> ... php_admin_flag apc.cache_by_default On </Directory <Directory &quot;/mysite/public_html/ phpmyadmin/ &quot;> ... php_admin_flag apc.cache_by_default Off </Directory>
    18. 22. 2.6. APC Tip.. <ul><li>Cache STRING is better than ARRAY </li></ul><ul><li>Long Time To Live better than Short </li></ul><ul><li>Case study: </li></ul><ul><ul><li>Caching for Feed System: </li></ul></ul>
    19. 23. BEFORE
    20. 24. BEFORE
    21. 25. ANALYSE
    22. 26. AFTER
    23. 27. Short TTL make fragmentation
    24. 28. Short TTL make fragmentation
    25. 29. <ul><li>It’s time to query … </li></ul>Thanks you!
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×