7. 1.2. Pagination – Why?
How do we make pagination feature?
mysql_query(‘SELECT COUNT(*) FROM tbl WHERE col LIKE “%word%”’)
> Get total record > Get toal page > Build page number list with a simple loop
mysql_query(‘SELECT * FROM tbl WHERE col LIKE “%word%” LIMIT 0,20’)
> Get data of current page (page 1, with 20 rows/page)
Do you have the answer ?
8. 1.3. Get enough data from remote server
Send HEAD to detect 404 error from remote
URL
Read first bytes of remote file to detect image
type,width/height
10. 2.1. Where is Back-end?
“80% of the end-user response time is spent on the front-
end. Most of this time is tied up in downloading all the
components in the page: images, stylesheets, scripts, Flash,
etc. Reducing the number of components in turn reduces the
number of HTTP requests required to render the page. This
is the key to faster pages.”
11. 2.2. Back-end Optimize Theory
Reduce disk In/Out
Reduce complex/fuzzy
Reduce budget
22. 3.1. What is De-normalization?
Most of use live with Relational DB.
What is normalization?
Database normalization is the process of organizing
the fields and tables of a relational database to
minimize redundancy and dependency .(Wiki)
What is De-normalization?
Denormalization is the process of attempting to
optimise the read performance of a database by
adding redundant data or by grouping data. (Wiki)
23. 3.2. How to de-normalize?
Vertical Split.
Pre-calculated value.
Duplicate data.
37. 5.2. What is APC?
Alternative PHP Cache – APC
Free PHP Extension
PHP Opcode cache
Support User data cache
Run on SAME machine with PHP
NOT support multi servers
44. 5.5. 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>
45. 2.6. APC Tip..
Cache STRING is better than ARRAY
Long Time To Live better than Short
Case study:
Caching for Feed System: