Caching strategy and apc

Post on 18-May-2015

3.294 views 1 download

Tags:

description

Presentation about Cache strategy for your website and u

Transcript of Caching strategy and apc

Caching Strategy & APC

Vo Duy Tuan - CEO/Founder

From the PHP developer view

$who_am_I?

My Name is Võ Duy Tuấn PHP 5 Zend Certified Engineer Interests: PHP, Social Network, Optimize Web Works:

Reader.vn CEO/Founder Trainer Freelancer Help customer Optimize & Speed up website

Caching Strategy1

1.1. Web Caching Introduction

1.2. Cache Strategy

Heavy load page/module HIT & MISS ratio. Budget & Technology AJAX SEO friendly Seperating to small tactics

Cache WHERE ? Cache WHAT ? Cache HOW LONG ?

1.2.1. Cache WHERE?

1.2.2. Cache WHAT?

File Code Query Result Object Array String Number …

1.2.3. Cache HOW LONG?

Cache Clear Type: Never Expired Normal Expired Force Expired

“More time caching, less real time data.”

Which cache do you HATE most?

Alternative PHP Cache - APC2

2.1. What is APC?

Free PHP Extension PHP Opcode cache Support User data cache Run on SAME machine with PHP NOT support multi servers

2.2. APC Installation

On linux: pecl install apc

On Windows: Download apc DLL file to PHP extension directory

such as php_apc.dll

2.3. PHP.INI

extension=/home/path/to/apc.so

[apc]

apc.enabled = 1

apc.cache_by_default=0

apc.shm_segments=1

apc.optimization=0

apc.shm_size=128

apc.ttl=7200

apc.user_ttl=7200

phpinfo()

2.4. APC Monitor

2.5. APC Using

2.6. APC Tip

Opcode your web code only Disable APC for PhpMyAdmin

<Directory "/mysite/public_html/">

...

php_admin_flag apc.cache_by_default On

</Directory

<Directory "/mysite/public_html/phpmyadmin/">

...

php_admin_flag apc.cache_by_default Off

</Directory>

2.6. APC Tip..

Cache STRING is better than ARRAY Long Time To Live better than Short Case study:

Caching for Feed System:

BEFORE

BEFORE

ANALYSE

AFTER

Short TTL make fragmentation

Short TTL make fragmentation

It’s time to query …

Thanks you!