
Performance tuning
-check server status
# sar -u
# mysqladmin status
# df -h // check /tmp is full
# uptime // check server load for past 1, 5, and 15 minutes to see improvements
# free -m
APACHE: Performance Tuning
-resources:
http://2bits.com/ (search apache)
MaxClients - defines how many simultaneous requests can be served. Any connection requests from browsers that come in after that will be queued. Default hard limit of 256. Is ok to set high for static content, but bad for rendered pages.
MaxSpareServers
MinSpareServers
StartServers
ServerLimit
Thrashing - where the system is just swapping pages from physical memory to virtual memory (on disk), and vice versa, without doing any real work.
Apache processes with modules (mod_perl, mod_python, mod_php) can easily be 21MB per process.
Can improve with PHP op-code cache/accelerator, then you can make each Apache process take as little as 12MB.
-this is where one_liner for RSS
-sort processes by mem usage
# ps auwxx --sort rss
# icps "semiphores"
-if apache is high mem usage, check MaxRequestsPerChild and keepalives
qMail
# qmHandle -s
/etc/init.d/smtp_psa
cps =
We started by adding the following to the smtp_psa xinet.d config file:
per_source = 1
cps = 20 25
in /var/qmail/control/
concurrencylocal
concurrencyremote
mySqltuner.pl
slow queries
Indexing - if table has no primary keys and indexes at all and every query is doing the table scanning which is very I/O intensive.
When indexes are created on MySQL tables the database builds another block of information that needs to be updated every time there are changes made to the table. This could have a negative impact on performance if you are constantly updating, inserting and removing entries.
Indexes will be needed for those fields that are used in a WHERE clause.
Creating an Index - New Table
CREATE TABLE students (
name VARCHAT(50),
studentID INT, INDEX (studentID)
)
Creating an Index - Existing Table
CREATE INDEX id_index ON students(employeeID)
Find any slow queries and investigate. Queries that return large results must write to a temp table in temp space, usually /tmp.
mysql> show processlist;
# mysqladmin processlist
# watch -i 1 mysqladmin processlist
mysql> show create table tableName;
-use EXPLAIN to see if queries are using indexes
mysql> EXPLAIN SELECT * FROM students WHERE studentID='45334';
-impact of having IDE vs. SCSI drives
-------
-check what is using the most mem
-sort processes by mem usage
# ps auwxx --sort rss
# icps "semiphores"
sar -r