Dobrica Pavlinušić's random unstructured stuff
titan performance: Revision 4

Before performance tuning

Memory

titan:~# free
             total       used       free     shared    buffers     cached
Mem:        903920     884360      19560          0       6728     167636
-/+ buffers/cache:     709996     193924
Swap:       995988     367732     628256

Koristi relativno mnogo swap-a, dmesg ima poruke o OOM-u, dakle treba mu više swap-a (ideja: smanjiti broj apache childova, jer je apache-ssl zapravo jako velik).

Mašina zapravo brutalno swap-a, pa nije ni čudo da se vuče kao crknuta krava:

titan:~# vmstat 3
procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa
 6 37 430500   7692   3728 105088    8    2    14     3    2   11 18 12 69  0
 3 45 432800   6512   3632 103128 2524 1596  4019  1931 1370 1613 11 28 61  0
 2 47 442860   7460   3608 102216  649 2553   857  2664  489  381  3 32 65  0
 5 56 444028   4760   3620 102328  497 1840   556  1869  464  282  3 37 60  0
16 44 472132   6788   3684 102392 4467 10889  5239 11409 3297 2770  5 34 61  0
11 36 474232   5868   3784 103212 1589 1212  2047  1435  681  812 13 28 59  0
 3 38 488996   5232   3708 102672 1952 5435  2985  5885 1704 1675  7 30 63  0
 1 18 493556   6976   3808 104396  491  855  1291  1105  866  643  8 31 61  0
 0 24 497508   6024   3736 104160  203 1576  1008  1768  551  592  6 36 59  0
 2 20 499324   5900   3800 105964  509  375  1549   533  517  727  8 30 62  0
 6 23 501608   5928   3844 106700  300 1528   804  1647  505  466  5 35 60  0
 2 26 500752   7804   3872 106388  629  583  1281   795  508  588  6 29 64  0
 4 26 500240   8068   3872 107264  533  300  1311   439  465  580  9 28 63  0

Disk nema uključen dma:

titan:~# hdparm /dev/hda

/dev/hda:
 multcount    = 16 (on)
 IO_support   =  0 (default 16-bit)
 unmaskirq    =  0 (off)
 using_dma    =  0 (off)
 keepsettings =  0 (off)
 readonly     =  0 (off)
 readahead    =  8 (on)
 geometry     = 9729/255/63, sectors = 156299375, start = 0

titan:~# hdparm -d 1 -c 3 -a 16 -m 16 /dev/hda

Instalirao sam: atop, hdparm, vim, sysstat

Vratio sam direktive za broj apache child-ova:

titan:~# diff -urw /etc/apache-ssl/httpd.conf.before_dpavlin /etc/apache-ssl/httpd.conf

*** /etc/apache-ssl/httpd.conf.before_dpavlin 2007-02-07 19:29:54.000000000 +0100
*** /etc/apache-ssl/httpd.conf 2007-02-07 19:34:07.000000000 +0100

@@ -139,10 +139,15 @@
 # a new spare. If there are more than MaxSpareServers, some of the
 # spares die off. The default values are probably OK for most sites.
 #
+MinSpareServers 10
+MaxSpareServers 20
+
 #
 # Number of servers to start initially --- should be a reasonable ballpark
 # figure.
 #
+StartServers 50
+
 #
 # Limit on total number of servers running, i.e., limit on the number
 # of clients who can simultaneously connect --- if this limit is ever
@@ -150,6 +155,8 @@
 # It is intended mainly as a brake to keep a runaway server from taking
 # the system with it as it spirals down...
 #
+MaxClients 512
+#MaxClients 2048

 #
 # MaxRequestsPerChild: the number of requests each child process is

Brojevi su namjerno konzervativno mali, cilj je prestati koristiti swap.

Pokušao sam smanjiti broj konekacija iz php-a na mysql:

titan:~# diff -urw /etc/php4/apache/php.ini.before_dpavlin /etc/php4/apache/php.ini

*** /etc/php4/apache/php.ini.before_dpavlin 2007-01-31 22:19:05.000000000 +0100
*** /etc/php4/apache/php.ini 2007-02-07 19:45:40.000000000 +0100

@@ -530,7 +530,7 @@
 mysql.max_persistent = 16

 ; Maximum number of links (persistent + non-persistent). -1 means no limit.
-mysql.max_links = 256
+mysql.max_links = 32
 mysql.connect_timeout = 30

 ; Default port number for mysql_connect(). If unset, mysql_connect() will use

sve u svemu, ne naročito uspješno:

titan:~# ps ax | egrep '(apache-ssl|mysqld)' | awk '{ print $5 }' | sort | uniq -c
     98 /usr/sbin/apache-ssl
     57 /usr/sbin/mysqld
titan:~# free
             total       used       free     shared    buffers     cached
Mem:        903920     855524      48396          0       8560     177080
-/+ buffers/cache:     669884     234036
Swap:       995988     236548     759440