Dobrica Pavlinušić's random unstructured stuff
titan performance: Revision 7
^ Before performance tuning

^^ Memory

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

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:

.pre
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
.pre

Disk nema uključen dma:

.pre
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
.pre

Instalirao sam: atop, hdparm, vim, sysstat, atsar

Vratio sam direktive za broj apache child-ova:

.pre
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 20:19:55.000000000 +0100
@@ -124,7 +124,7 @@
# KeepAliveTimeout: Number of seconds to wait for the next request from the
# same client on the same connection.
#
-KeepAliveTimeout 15
+KeepAliveTimeout 5

#
# Server-pool size regulation. Rather than making you guess how many
@@ -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 10
+
#
# Number of servers to start initially --- should be a reasonable ballpark
# figure.
#
+StartServers 10
+
#
# 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
.pre

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

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

.pre
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
.pre

sve u svemu, donekle uspješno:

.pre
titan:~# ps ax | egrep '(apache-ssl|mysqld)' | awk '{ print $5 }' | sort | uniq -c
2 /bin/sh
1 /usr/lib/apache-ssl/gcache
62 /usr/sbin/apache-ssl
47 /usr/sbin/mysqld
1 grep
1 logger
titan:~# free
total used free shared buffers cached
Mem: 903920 815964 87956 0 21896 304012
-/+ buffers/cache: 490056 413864
Swap: 995988 164696 831292
titan:~# uptime
20:33:43 up 9 days, 12:38, 4 users, load average: 1.25, 1.34, 2.60
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
0 0 162956 61912 26160 359660 8 3 16 4 3 13 18 12 69 0
0 0 162956 55044 26200 359736 1 0 17 232 285 662 24 1 75 0
6 0 162956 54020 26264 359960 0 0 71 231 337 506 18 1 80 0
1 0 162956 54984 26300 360856 0 0 292 215 425 615 39 2 60 0
1 0 162956 51108 26368 360896 0 0 7 335 320 702 32 3 65 0
1 0 162956 49692 26472 360928 7 0 7 479 439 765 26 2 72 0
4 0 162956 55144 26496 360960 0 0 3 205 331 655 74 4 22 0
2 0 162956 54324 26568 360996 0 0 4 489 466 816 56 5 39 0
0 0 162956 54208 26604 361168 0 0 55 215 310 566 29 2 69 0
4 0 162956 48900 26840 362348 0 0 373 1059 522 1106 44 4 52 0
1 0 162956 40216 27000 363224 0 0 277 732 505 967 37 4 59 0
0 0 162956 55336 27016 363864 0 0 211 220 320 553 47 2 51 0
1 0 162952 60284 27096 364056 1 0 55 417 355 693 32 2 65 0
.pre

uptime oko je 2 (što je za dvoprocesorsku mašinu o.k.), a zapravo ima i nešto idle CPU-a što je uvijek zgodno.