Решил я заняться сервером который хостит блог, так как машинка из разряда «я его слепила из того что было», то производительностью не блещет. Для начала хотелось выкосить всё лишнее, но это не помогло, и я занялся сборкой программ, так как бинарные пакеты это конечно хорошо и удобно, но не производительно. Решено — будем собирать, заодно обновимся.
Для начала соберём apache, так как это самая тяжелая программа. Скачиваем исходники и распаковываем.
|
Далее я решил поэксперементировать, и для того чтобы не писать длинную строку конфигурации каждый раз, я написал скриптик apache_compile.sh
cd $1 export CFLAGS=»-O3 -msse -mmmx -msse2 -mtune=pentium4 -march=pentium4 -funroll-loops -mfpmath=sse» ./configure \ —prefix=/ \ —exec-prefix=/usr/ \ —disable-authn-file \ —disable-authn-default \ —disable-authz-host \ —disable-authz-groupfile \ —disable-authz-user \ —disable-authz-default \ —disable-auth-basic \ —disable-include \ —disable-filter \ —disable-charset-lite \ —disable-log-config \ —disable-env \ —disable-setenvif \ —disable-version \ —disable-status \ —disable-autoindex \ —disable-asis \ —disable-cgid \ —disable-cgi \ —disable-negotiation \ —disable-actions \ —disable-userdir \ —disable-alias \ —enable-so\ —with-mpm=prefork make make install
Но это уже окончательная версия, самый первый конфиг я собирал с модулем worker, но так как php прошлось собирать с zts для этого то все прелести worker’а сошли на нет. Пересобрал обратно с модулем prefork и занялся выпиливанием лишнего из php.
|
Аналогично скрипт уже готовой версии php_compile.sh
cd $1 export CFLAGS=»-O3 -msse -mmmx -msse2 -mtune=pentium4 -march=pentium4 -funroll-loops -mfpmath=sse» make clean ./configure \ —prefix=/ \ —exec-prefix=/usr/ \ —disable-all \ —disable-cgi \ —disable-ipv6 \ —disable-libxml \ —disable-ctype \ —disable-inifile \ —disable-flatfile \ —without-cdb \ —disable-dom \ —disable-fileinfo \ —disable-filter \ —enable-mbstring \ —enable-session \ —enable-json \ —with-mysql \ —with-mysql-sock=/var/lib/mysql/mysql.sock \ —disable-pdo \ —disable-simplexml \ —disable-tokenizer \ —disable-xml \ —disable-xmlreader \ —disable-xmlwriter \ —without-pear \ —with-apxs2=/usr/bin/apxs make make install cp /home/dimonyga/$1/libs/libphp5.so /etc/httpd/modules/libphp5.so
Сначала я написал —disable-all и успокоился, но когда взглянул в phpinfo — ужаснулся, он мне насобирал всего всего, пришлось после этого ещё выпиливать каждое дополнение по отдельности.
Далее не тривиальная установка дополнения APC, замечу что при установке APC я не делал make install, а просто скопировал SOшку в папку расширений php и прописал в конфигурации его загрузку. После всех проделанных операций я заменил mysql на его форк MariaDB, так как он на мой взгляд работает быстрее. Как результат — увеличение производительности почти в полтора раза. Вот лог из программы Webserver Stress Tool 7. Оригинал (всё из RPM)
Results of period #1 (from 1 sec to 11 sec ): **************************************************************** Completed Clicks: 13 with 0 Errors (=0,00%) Average Click Time for 10 Users: 2а215 ms Successful clicks per Second: 1,28 (equals 4а615,01 Clicks per Hour) Results of period #2 (from 11 sec to 22 sec ): **************************************************************** Completed Clicks: 13 with 0 Errors (=0,00%) Average Click Time for 10 Users: 2а662 ms Successful clicks per Second: 1,28 (equals 4а612,56 Clicks per Hour) Results of period #3 (from 22 sec to 32 sec ): **************************************************************** Completed Clicks: 14 with 0 Errors (=0,00%) Average Click Time for 10 Users: 2а184 ms Successful clicks per Second: 1,38 (equals 4а967,71 Clicks per Hour) Results of period #4 (from 32 sec to 42 sec ): **************************************************************** Completed Clicks: 12 with 0 Errors (=0,00%) Average Click Time for 10 Users: 2а639 ms Successful clicks per Second: 1,18 (equals 4а247,22 Clicks per Hour) Results of period #5 (from 42 sec to 52 sec ): **************************************************************** Completed Clicks: 13 with 0 Errors (=0,00%) Average Click Time for 10 Users: 2а230 ms Successful clicks per Second: 1,28 (equals 4а593,84 Clicks per Hour) Results of period #6 (from 52 sec to 62 sec ): **************************************************************** Completed Clicks: 14 with 0 Errors (=0,00%) Average Click Time for 10 Users: 2а362 ms Successful clicks per Second: 1,37 (equals 4а942,95 Clicks per Hour) Results of period #7 (from 62 sec to 72 sec ): **************************************************************** Completed Clicks: 13 with 0 Errors (=0,00%) Average Click Time for 10 Users: 2а567 ms Successful clicks per Second: 1,28 (equals 4а599,28 Clicks per Hour) Results of period #8 (from 72 sec to 83 sec ): **************************************************************** Completed Clicks: 14 with 0 Errors (=0,00%) Average Click Time for 10 Users: 2а585 ms Successful clicks per Second: 1,38 (equals 4а952,13 Clicks per Hour) Results of period #9 (from 83 sec to 93 sec ): **************************************************************** Completed Clicks: 14 with 0 Errors (=0,00%) Average Click Time for 10 Users: 2а535 ms Successful clicks per Second: 1,38 (equals 4а949,20 Clicks per Hour) Results of period #10 (from 93 sec to 103 sec ): **************************************************************** Completed Clicks: 15 with 0 Errors (=0,00%) Average Click Time for 10 Users: 2а763 ms Successful clicks per Second: 1,47 (equals 5а305,86 Clicks per Hour)
Далее apache-worker+php-zts (как можно заметить производительность даже упала.)
Results of period #1 (from 2 sec to 12 sec ): **************************************************************** Completed Clicks: 3 with 0 Errors (=0,00%) Average Click Time for 10 Users: 3а129 ms Successful clicks per Second: 0,30 (equals 1а068,31 Clicks per Hour) Results of period #2 (from 12 sec to 22 sec ): **************************************************************** Completed Clicks: 11 with 0 Errors (=0,00%) Average Click Time for 10 Users: 7а299 ms Successful clicks per Second: 1,09 (equals 3а915,77 Clicks per Hour) Results of period #3 (from 22 sec to 32 sec ): **************************************************************** Completed Clicks: 10 with 0 Errors (=0,00%) Average Click Time for 10 Users: 6а577 ms Successful clicks per Second: 0,99 (equals 3а556,48 Clicks per Hour) Results of period #4 (from 32 sec to 43 sec ): **************************************************************** Completed Clicks: 9 with 0 Errors (=0,00%) Average Click Time for 10 Users: 5а894 ms Successful clicks per Second: 0,88 (equals 3а174,42 Clicks per Hour) Results of period #5 (from 43 sec to 53 sec ): **************************************************************** Completed Clicks: 10 with 0 Errors (=0,00%) Average Click Time for 10 Users: 5а590 ms Successful clicks per Second: 0,98 (equals 3а543,48 Clicks per Hour) Results of period #6 (from 53 sec to 63 sec ): **************************************************************** Completed Clicks: 7 with 0 Errors (=0,00%) Average Click Time for 10 Users: 5а960 ms Successful clicks per Second: 0,69 (equals 2а476,08 Clicks per Hour) Results of period #7 (from 63 sec to 73 sec ): **************************************************************** Completed Clicks: 10 with 0 Errors (=0,00%) Average Click Time for 10 Users: 6а414 ms Successful clicks per Second: 0,98 (equals 3а541,72 Clicks per Hour) Results of period #8 (from 73 sec to 83 sec ): **************************************************************** Completed Clicks: 11 with 0 Errors (=0,00%) Average Click Time for 10 Users: 5а894 ms Successful clicks per Second: 1,08 (equals 3а896,69 Clicks per Hour) Results of period #9 (from 83 sec to 93 sec ): **************************************************************** Completed Clicks: 7 with 0 Errors (=0,00%) Average Click Time for 10 Users: 6а798 ms Successful clicks per Second: 0,69 (equals 2а480,51 Clicks per Hour) Results of period #10 (from 93 sec to 104 sec ): **************************************************************** Completed Clicks: 11 with 0 Errors (=0,00%) Average Click Time for 10 Users: 4а839 ms Successful clicks per Second: 1,08 (equals 3а897,33 Clicks per Hour)
Ну и вот окончательный результат
Results of period #1 (from 2 sec to 12 sec ): **************************************************************** Completed Clicks: 15 with 0 Errors (=0,00%) Average Click Time for 10 Users: 1а216 ms Successful clicks per Second: 1,48 (equals 5а342,87 Clicks per Hour) Results of period #2 (from 12 sec to 22 sec ): **************************************************************** Completed Clicks: 15 with 0 Errors (=0,00%) Average Click Time for 10 Users: 1а343 ms Successful clicks per Second: 1,48 (equals 5а336,60 Clicks per Hour) Results of period #3 (from 22 sec to 32 sec ): **************************************************************** Completed Clicks: 18 with 0 Errors (=0,00%) Average Click Time for 10 Users: 1а407 ms Successful clicks per Second: 1,78 (equals 6а398,18 Clicks per Hour) Results of period #4 (from 32 sec to 42 sec ): **************************************************************** Completed Clicks: 16 with 0 Errors (=0,00%) Average Click Time for 10 Users: 1а113 ms Successful clicks per Second: 1,57 (equals 5а636,78 Clicks per Hour) Results of period #5 (from 42 sec to 52 sec ): **************************************************************** Completed Clicks: 16 with 0 Errors (=0,00%) Average Click Time for 10 Users: 1а117 ms Successful clicks per Second: 1,57 (equals 5а666,31 Clicks per Hour) Results of period #6 (from 52 sec to 63 sec ): **************************************************************** Completed Clicks: 17 with 0 Errors (=0,00%) Average Click Time for 10 Users: 1а638 ms Successful clicks per Second: 1,67 (equals 6а018,58 Clicks per Hour) Results of period #7 (from 63 sec to 73 sec ): **************************************************************** Completed Clicks: 13 with 0 Errors (=0,00%) Average Click Time for 10 Users: 1а716 ms Successful clicks per Second: 1,28 (equals 4а605,73 Clicks per Hour) Results of period #8 (from 73 sec to 83 sec ): **************************************************************** Completed Clicks: 14 with 0 Errors (=0,00%) Average Click Time for 10 Users: 1а526 ms Successful clicks per Second: 1,38 (equals 4а960,76 Clicks per Hour) Results of period #9 (from 83 sec to 93 sec ): **************************************************************** Completed Clicks: 17 with 0 Errors (=0,00%) Average Click Time for 10 Users: 1а837 ms Successful clicks per Second: 1,67 (equals 6а019,87 Clicks per Hour) Results of period #10 (from 93 sec to 103 sec ): **************************************************************** Completed Clicks: 12 with 0 Errors (=0,00%) Average Click Time for 10 Users: 2а112 ms Successful clicks per Second: 1,18 (equals 4а244,29 Clicks per Hour)
То-есть получается что в среднем clicks per Second выросли с максимальных 1.38 до 1,78. Ну и средняя планка поднялась чуть выше.