Date post: | 06-May-2015 |
Category: |
Technology |
Upload: | digitaria |
View: | 955 times |
Download: | 0 times |
PERFORMANCE & SCALABILITYWhere to Begin
Brandon Lyon
Performance & Scalability
Define the Objective
Performance & Scalability
Define the Objective Minimize HTTP
Requests
Performance & Scalability
Define the Objective Minimize HTTP
Requests Minimize Server
Processing
Performance & Scalability
Define the Objective Minimize HTTP
Requests Minimize Server
Processing Optimize Server
Processing
Performance & Scalability
Define the Objective Minimize HTTP
Requests Minimize Server
Processing Optimize Server
Processing Optimize the
Database
Performance & Scalability
Define the Objective Minimize HTTP
Requests Minimize Server
Processing Optimize Server
Processing Optimize the
Database
Minimizing HTTP Requests
Aggregate & Compress CSS Files
Minimizing HTTP Requests
Aggregate & Compress CSS Files
Aggregate JavaScript Files
Minimizing HTTP Requests
Aggregate & Compress CSS Files
Aggregate JavaScript Files
Image Sprites
Performance & Scalability
Define the Objective Minimize HTTP
Requests Minimize Server
Processing Optimize Server
Processing Optimize the
Database
Minimize Server Processing
Alternative PHP Cache (APC)
Memcached Varnish Cache
Alternative PHP Cache (APC)
Make sure you've allocated enough memory.apc.shm_segments=1
apc.shm_size=32
Check your script files on every request?apc.stat=0
Memory Fragmentation?apc.ttl=0
Memcached
Basic Implementation
# memcached -m 24 -p 11211 -d
$conf = array(
'memcache_servers' => array(
'localhost:11211' => 'default',
),
'memcache_bins' => array(
'cache' => 'default',
),
Memcached
Server Cluster?$conf = array(
'memcache_servers' => array(
host1:port => cluster,
hostN:port => cluster,
),
'memcache_bins' => array(
bin1 => cluster,
binN => cluster,
),
Varnish Cache
Toss your cookies!if (req.url !~ "^/blog\/.*/") {
set req.http.Cookie =
regsuball(req.http.Cookie, "comment\_.*", "");
}
Define Exceptionsif (req.url ~ "install.php|update.php") {
return(pass);
}
Performance & Scalability
Define the Objective Minimize HTTP
Requests Minimize Server
Processing Optimize Server
Processing Optimize the
Database
Optimize Server Processing
Identify the Problem
Optimize Server Processing
Identify the Problem
FIX IT
Optimize Server Processing
Identifying the Problem Areas Network Linux Apache MySQL PHP
Optimize Server Processing
Identifying the Problem Areas Network Linux Apache MySQL PHP
Optimize Server Processing
Performance Profiling Apache Benchmarking (ab) MySQL Slow Query Log & Profiling PHP Xdebug & KCachegrind
Apache Benchmarking (ab)
10 Concurrent Requests
100 Requests
7.35 Requests/Second 50% of Requests served in
under 1352ms
# ab -n 100 -c 10 http://d7.blyon.lan/
Apache Benchmarking (ab)
Compress Cached Pages Aggregate and Compress CSS files Aggregate JavaScript files
Apache Benchmarking (ab)
10 Concurrent Requests
100 Requests
46.32 Requests/Second 50% of Requests served in
under 213ms
# ab -n 100 -c 10 http://d7.blyon.lan/
Apache Benchmarking (ab)
Install APC Install APC Drupal Module
Apache Benchmarking (ab)
10 Concurrent Requests
100 Requests
648.77 Requests/Second 50% of Requests served in
under 12ms
# ab -n 100 -c 10 http://d7.blyon.lan/
Optimize Server Processing
Performance Profiling Apache Benchmarking (ab) MySQL Slow Query Log & Profiling PHP Xdebug & KCachegrind
MySQL Slow Query Log
/etc/mysql/my.cnflog_slow_queries = /var/log/mysql/mysql-slow.log
long_query_time = 1
# tail -f /var/log/mysql/mysql-slow.log# User@Host: root[root] @ localhost []
# Query_time: 0.000427 Lock_time: 0.000037 Rows_sent: 50
Rows_examined: 50
SET timestamp=1294541182;
select * from node;
Optimize Server Processing
Performance Profiling Apache Benchmarking (ab) MySQL Slow Query Log & Profiling PHP Xdebug & KCachegrind
PHP Xdebug & KCachegrind
Xdebug Features Stack Traces & Function Traces in Error
Messages Memory Allocation Infinite Recursion Protection PHP Profiling Code Coverage Analysis Interactive Debugging support
PHP Xdebug & KCachegrind
Xdebug Configuration zend_extension="/usr/local/php/modules/xdebug.so"
xdebug.profiler_enable_trigger = 1
Xdebug Usage Append ”?XDEBUG_PROFILE=1” to URL
View cachegrind compatible profile log
/tmp/cachegrind.out.10362
PHP Xdebug & KCachegrind
Kcachegrind Profile data Visualization tool Accepts ”Callgrind Profile” formatted data Requires KDE Libraries
PHP Xdebug & KCachegrind
Now FIX IT
Performance & Scalability
Define the Objective Minimize HTTP
Requests Minimize Server
Processing Optimize Server
Processing Optimize the
Database
Optimizing the Database
http://day32.com/MySQL/tuning-primer.sh Analyzes current my.cnf Analyzes resource usage Analyzes Caching Analyzes Tables and Queries Generates recommended my.cnf
PERFORMANCE & SCALABILITYWhere to Begin
Brandon Lyon