batva
crazy administrator | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору Swappp 100% apache2 юзает Keep-Alive и для динамики. Ок. Ноу проблем пусть будет с Keep-Alive. И все равно разница будет существенной. Давай посмотрим. Кстати, так как ты, не тестируют. Во-первых через top ты ничего не увидишь, а во-вторых, нужно же нагрузить апачь, иначе он и не будет запускать новые процессы, одним уже запущенным все запросы по очереди отдаст. Запускать новый процесс он будет когда "под рукой" нет уже запущенного спящего. Понимаешь о чем я? Отдаем картинку скриптом test.php Код: <?PHP header("Content-type: image/gif"); readfile('ru-board.gif'); ?> | Цитата: [root@host1 bin]# ./ab -n 10000 -c 100 -k http://ru-board.com/test/test.php This is ApacheBench, Version 1.3d <$Revision: 1.73 $> apache-1.3 Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/ Benchmarking ru-board.com (be patient) Completed 1000 requests Completed 2000 requests Completed 3000 requests Completed 4000 requests Completed 5000 requests Completed 6000 requests Completed 7000 requests Completed 8000 requests Completed 9000 requests Finished 10000 requests Server Software: Apache Server Hostname: ru-board.com Server Port: 80 Document Path: /test/test.php Document Length: 6731 bytes Concurrency Level: 100 Time taken for tests: 12.723 seconds Complete requests: 10000 Failed requests: 0 Broken pipe errors: 0 Keep-Alive requests: 9946 Total transferred: 69781168 bytes HTML transferred: 67498468 bytes Requests per second: 785.98 [#/sec] (mean) Time per request: 127.23 [ms] (mean) Time per request: 1.27 [ms] (mean, across all concurrent requests) Transfer rate: 5484.65 [Kbytes/sec] received Connnection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.2 0 4 Processing: 1 91 742.0 11 10830 Waiting: 0 91 742.0 10 10829 Total: 1 91 742.2 11 10831 Percentage of the requests served within a certain time (ms) 50% 11 66% 15 75% 18 80% 20 90% 34 95% 77 98% 213 99% 2615 100% 10831 (last request) | А теперь без скрипта. Цитата: [root@host1 bin]# ./ab -n 10000 -c 100 -k http://ru-board.com/test/ru-board.gif This is ApacheBench, Version 1.3d <$Revision: 1.73 $> apache-1.3 Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/ Benchmarking ru-board.com (be patient) Completed 1000 requests Completed 2000 requests Completed 3000 requests Completed 4000 requests Completed 5000 requests Completed 6000 requests Completed 7000 requests Completed 8000 requests Completed 9000 requests Finished 10000 requests Server Software: Apache Server Hostname: ru-board.com Server Port: 80 Document Path: /test/ru-board.gif Document Length: 6731 bytes Concurrency Level: 100 Time taken for tests: 4.309 seconds Complete requests: 10000 Failed requests: 0 Broken pipe errors: 0 Keep-Alive requests: 9918 Total transferred: 70379203 bytes HTML transferred: 67370579 bytes Requests per second: 2320.72 [#/sec] (mean) Time per request: 43.09 [ms] (mean) Time per request: 0.43 [ms] (mean, across all concurrent requests) Transfer rate: 16333.07 [Kbytes/sec] received Connnection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.2 0 4 Processing: 0 25 254.1 1 3974 Waiting: 0 25 254.1 1 3974 Total: 0 25 254.3 1 3974 Percentage of the requests served within a certain time (ms) 50% 1 66% 2 75% 3 80% 3 90% 4 95% 4 98% 28 99% 246 100% 3974 (last request) [root@host1 bin]# | Перед каждым тестом апачь перезапускался. (чтобы убить существующие процессы.) А вот данные по загрузке процессора, и кол-во процессов по окончании теста. Это картинка скриптом. Цитата: Apache Server Status for 65.75.176.221 Server Version: Apache Server Built: Jul 1 2004 08:49:07 -------------------------------------------------------------------------------- Current Time: Friday, 17-Dec-2004 20:28:45 PST Restart Time: Friday, 17-Dec-2004 20:28:24 PST Parent Server Generation: 0 Server uptime: 21 seconds Total accesses: 10145 - Total Traffic: 65.0 MB CPU Usage: u6.57 s2.47 cu0 cs0 - 43% CPU load 483 requests/sec - 3.1 MB/second - 6.6 kB/request 4 requests currently being processed, 58 idle workers KK_____.______W_______C____.____________________________________ ................................................................ ................................................................ ................................................................ Scoreboard Key: "_" Waiting for Connection, "S" Starting up, "R" Reading Request, "W" Sending Reply, "K" Keepalive (read), "D" DNS Lookup, "C" Closing connection, "L" Logging, "G" Gracefully finishing, "I" Idle cleanup of worker, "." Open slot with no current process Srv PID Acc M CPU SS Req Conn Child Slot Client VHost Request 0-0 5236 9/9/9 K 0.00 5 0 0.0 0.00 0.00 85.91.100.103 smilies.ru-board.com GET /sm/smilie_bett.gif HTTP/1.1 1-0 5242 8/8/8 K 0.01 5 0 0.0 0.00 0.00 85.91.100.103 smilies.ru-board.com GET /sm/mconfused.gif HTTP/1.1 2-0 5243 0/1082/1082 _ 1.01 4 0 0.0 6.95 6.95 65.75.176.221 ru-board.com GET /test/test.php HTTP/1.0 3-0 5244 0/1209/1209 _ 0.93 4 0 0.0 7.76 7.76 65.75.176.221 ru-board.com GET /test/test.php HTTP/1.0 4-0 5245 0/674/674 _ 0.59 4 0 0.0 4.33 4.33 65.75.176.221 ru-board.com GET /test/test.php HTTP/1.0 5-0 5246 0/671/671 _ 0.58 4 0 0.0 4.31 4.31 65.75.176.221 ru-board.com GET /test/test.php HTTP/1.0 6-0 5247 0/632/632 _ 0.57 4 0 0.0 4.06 4.06 65.75.176.221 ru-board.com GET /test/test.php HTTP/1.0 7-0 - 0/0/632 . 0.54 2 0 0.0 0.00 4.06 65.75.176.221 ru-board.com GET /test/test.php HTTP/1.0 8-0 5249 0/476/476 _ 0.42 4 0 0.0 3.06 3.06 65.75.176.221 ru-board.com GET /test/test.php HTTP/1.0 9-0 5250 0/486/486 _ 0.39 4 0 0.0 3.12 3.12 65.75.176.221 ru-board.com GET /test/test.php HTTP/1.0 10-0 5251 0/339/339 _ 0.39 4 0 0.0 2.18 2.18 65.75.176.221 ru-board.com GET /test/test.php HTTP/1.0 11-0 5252 0/377/377 _ 0.37 4 0 0.0 2.42 2.42 65.75.176.221 ru-board.com GET /test/test.php HTTP/1.0 12-0 5253 0/463/463 _ 0.35 4 0 0.0 2.97 2.97 65.75.176.221 ru-board.com GET /test/test.php HTTP/1.0 13-0 5254 0/337/337 _ 0.34 4 0 0.0 2.16 2.16 65.75.176.221 ru-board.com GET /test/test.php HTTP/1.0 14-0 5255 0/377/377 W 0.32 0 0 0.0 2.42 2.42 85.64.128.20 ru-board.com GET /server-status HTTP/1.1 15-0 5256 0/273/273 _ 0.30 4 0 0.0 1.75 1.75 65.75.176.221 ru-board.com GET /test/test.php HTTP/1.0 16-0 5257 0/244/244 _ 0.25 4 0 0.0 1.57 1.57 65.75.176.221 ru-board.com GET /test/test.php HTTP/1.0 17-0 5258 0/235/235 _ 0.24 4 0 0.0 1.51 1.51 65.75.176.221 ru-board.com GET /test/test.php HTTP/1.0 18-0 5259 0/288/288 _ 0.20 4 0 0.0 1.85 1.85 65.75.176.221 ru-board.com GET /test/test.php HTTP/1.0 19-0 5260 0/227/227 _ 0.18 4 0 0.0 1.46 1.46 65.75.176.221 ru-board.com GET /test/test.php HTTP/1.0 20-0 5261 0/152/152 _ 0.19 4 0 0.0 0.98 0.98 65.75.176.221 ru-board.com GET /test/test.php HTTP/1.0 21-0 5262 0/156/156 _ 0.18 4 0 0.0 1.00 1.00 65.75.176.221 ru-board.com GET /test/test.php HTTP/1.0 22-0 5263 0/201/201 C 0.11 0 0 0.0 1.29 1.29 65.75.176.221 ru-board.com GET /test/test.php HTTP/1.0 23-0 5264 0/176/176 _ 0.12 4 0 0.0 1.13 1.13 65.75.176.221 ru-board.com GET /test/test.php HTTP/1.0 24-0 5265 0/80/80 _ 0.14 4 0 0.0 0.51 0.51 65.75.176.221 ru-board.com GET /test/test.php HTTP/1.0 25-0 5266 0/74/74 _ 0.09 4 0 0.0 0.48 0.48 65.75.176.221 ru-board.com GET /test/test.php HTTP/1.0 26-0 5267 0/74/74 _ 0.07 4 0 0.0 0.48 0.48 65.75.176.221 ru-board.com GET /test/test.php HTTP/1.0 27-0 - 0/0/95 . 0.05 0 0 0.0 0.00 0.61 65.75.176.221 ru-board.com GET /test/test.php HTTP/1.0 28-0 5269 0/32/32 _ 0.03 4 0 0.0 0.21 0.21 65.75.176.221 ru-board.com GET /test/test.php HTTP/1.0 29-0 5270 0/39/39 _ 0.03 4 0 0.0 0.25 0.25 65.75.176.221 ru-board.com GET /test/test.php HTTP/1.0 30-0 5271 0/16/16 _ 0.03 4 0 0.0 0.10 0.10 65.75.176.221 ru-board.com GET /test/test.php HTTP/1.0 31-0 5275 0/10/10 _ 0.01 4 0 0.0 0.06 0.06 65.75.176.221 ru-board.com GET /test/test.php HTTP/1.0 32-0 5279 0/1/1 _ 0.01 4 0 0.0 0.01 0.01 65.75.176.221 ru-board.com GET /test/test.php HTTP/1.0 -------------------------------------------------------------------------------- Srv Child Server number - generation PID OS process ID Acc Number of accesses this connection / this child / this slot M Mode of operation CPU CPU usage, number of seconds SS Seconds since beginning of most recent request Req Milliseconds required to process most recent request Conn Kilobytes transferred this connection Child Megabytes transferred this child Slot Total megabytes transferred this slot -------------------------------------------------------------------------------- Apache Server at 65.75.176.221 Port 80 | А это без Цитата: Apache Server Status for 65.75.176.220 Server Version: Apache Server Built: Jul 1 2004 08:49:07 -------------------------------------------------------------------------------- Current Time: Friday, 17-Dec-2004 20:29:58 PST Restart Time: Friday, 17-Dec-2004 20:29:37 PST Parent Server Generation: 0 Server uptime: 21 seconds Total accesses: 10111 - Total Traffic: 64.9 MB CPU Usage: u1.31 s1.38 cu0 cs0 - 12.8% CPU load 481 requests/sec - 3.1 MB/second - 6.6 kB/request 2 requests currently being processed, 15 idle workers _K_________W_____............................................... ................................................................ ................................................................ ................................................................ Scoreboard Key: "_" Waiting for Connection, "S" Starting up, "R" Reading Request, "W" Sending Reply, "K" Keepalive (read), "D" DNS Lookup, "C" Closing connection, "L" Logging, "G" Gracefully finishing, "I" Idle cleanup of worker, "." Open slot with no current process Srv PID Acc M CPU SS Req Conn Child Slot Client VHost Request 0-0 5352 0/1/1 _ 0.00 1 0 0.0 0.00 0.00 85.64.128.20 ru-host.com GET /server-status HTTP/1.1 1-0 5359 1/1/1 K 0.00 8 0 0.0 0.00 0.00 24.188.12.225 dimon.org.ua GET /forum/uploads/av-604.jpg HTTP/1.1 2-0 5363 0/3315/3315 _ 0.96 4 0 0.0 21.28 21.28 65.75.176.221 ru-board.com GET /test/ru-board.gif HTTP/1.0 3-0 5365 0/1582/1582 _ 0.39 4 0 0.0 10.16 10.16 65.75.176.221 ru-board.com GET /test/ru-board.gif HTTP/1.0 4-0 5366 0/1424/1424 _ 0.36 4 0 0.0 9.14 9.14 65.75.176.221 ru-board.com GET /test/ru-board.gif HTTP/1.0 5-0 5368 0/766/766 _ 0.15 4 0 0.0 4.92 4.92 65.75.176.221 ru-board.com GET /test/ru-board.gif HTTP/1.0 6-0 5369 0/770/770 _ 0.18 4 0 0.0 4.94 4.94 65.75.176.221 ru-board.com GET /test/ru-board.gif HTTP/1.0 7-0 5370 0/550/550 _ 0.16 4 0 0.0 3.53 3.53 65.75.176.221 ru-board.com GET /test/ru-board.gif HTTP/1.0 8-0 5371 0/487/487 _ 0.16 4 0 0.0 3.13 3.13 65.75.176.221 ru-board.com GET /test/ru-board.gif HTTP/1.0 9-0 5373 0/247/247 _ 0.08 4 0 0.0 1.59 1.59 65.75.176.221 ru-board.com GET /test/ru-board.gif HTTP/1.0 10-0 5374 0/198/198 _ 0.08 4 0 0.0 1.27 1.27 65.75.176.221 ru-board.com GET /test/ru-board.gif HTTP/1.0 11-0 5375 0/270/270 W 0.03 0 0 0.0 1.73 1.73 85.64.128.20 ru-host.com GET /server-status HTTP/1.1 12-0 5376 0/185/185 _ 0.07 4 0 0.0 1.19 1.19 65.75.176.221 ru-board.com GET /test/ru-board.gif HTTP/1.0 13-0 5377 0/132/132 _ 0.02 4 0 0.0 0.85 0.85 65.75.176.221 ru-board.com GET /test/ru-board.gif HTTP/1.0 14-0 5378 0/106/106 _ 0.03 4 0 0.0 0.68 0.68 65.75.176.221 ru-board.com GET /test/ru-board.gif HTTP/1.0 15-0 5379 0/48/48 _ 0.00 4 0 0.0 0.31 0.31 65.75.176.221 ru-board.com GET /test/ru-board.gif HTTP/1.0 16-0 5380 0/29/29 _ 0.02 4 0 0.0 0.19 0.19 65.75.176.221 ru-board.com GET /test/ru-board.gif HTTP/1.0 -------------------------------------------------------------------------------- Srv Child Server number - generation PID OS process ID Acc Number of accesses this connection / this child / this slot M Mode of operation CPU CPU usage, number of seconds SS Seconds since beginning of most recent request Req Milliseconds required to process most recent request Conn Kilobytes transferred this connection Child Megabytes transferred this child Slot Total megabytes transferred this slot -------------------------------------------------------------------------------- Apache Server at 65.75.176.220 Port 80 | Пару затесавшихся лишних запросов на smilies.ru-board.com не берем. На результат они не влияют, просто не хотелось выключать сайт. Разницу видно? Думаю да. Про память я вообще молчу. Все знают сколько кушает один апачев процесс? Особенно apache2 Посмотреть можно через ps С выключенным Keep-Alive ситуация еще хуже. Тесты показывать не буду, смысл там такой же. php скрипт из двух строк, а если там еще коннект к mysql будет? Тесты показывать? Не буду. Кому нужно сделайте их сами, убедитесь раз и навсегда, что такое хранение картинок в mysql. Добавлено В ПМ была просьба показать тест с мускулом. Показываю. test2.php Код: <?php $link = mysql_connect('localhost', 'ru-board', '***'); mysql_select_db('test'); $query = 'SELECT * FROM test WHERE id =1'; $result = mysql_query($query); $row = mysql_fetch_assoc($result); header("Content-type: image/gif"); echo $row['image']; ?> | Цитата: CREATE TABLE `test` ( `id` int(11) NOT NULL auto_increment, `image` blob NOT NULL, PRIMARY KEY (`id`) ) TYPE=MyISAM | В таблицу была положена одна картинка. Та же самая, что и в предыдущих тестах. В MySQL кеширование включено. Размер кеша-достаточный. max_connections=200 Цитата: [root@host1 bin]# ./ab -n 10000 -c 100 -k http://ru-board.com/test/test2.php This is ApacheBench, Version 1.3d <$Revision: 1.73 $> apache-1.3 Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/ Benchmarking ru-board.com (be patient) Completed 1000 requests Completed 2000 requests Completed 3000 requests Completed 4000 requests Completed 5000 requests Completed 6000 requests Completed 7000 requests Completed 8000 requests Completed 9000 requests Finished 10000 requests Server Software: Apache Server Hostname: ru-board.com Server Port: 80 Document Path: /test/test2.php Document Length: 6733 bytes Concurrency Level: 100 Time taken for tests: 19.655 seconds Complete requests: 10000 Failed requests: 6287 (Connect: 0, Length: 6287, Exceptions: 0) Broken pipe errors: 0 Keep-Alive requests: 9940 Total transferred: 36224667 bytes HTML transferred: 33833756 bytes Requests per second: 508.78 [#/sec] (mean) Time per request: 196.55 [ms] (mean) Time per request: 1.97 [ms] (mean, across all concurrent requests) Transfer rate: 1843.03 [Kbytes/sec] received Connnection Times (ms) min mean[+/-sd] median max Connect: 0 0 4.1 0 98 Processing: 1 169 894.7 17 12518 Waiting: 0 168 894.8 16 12518 Total: 1 170 897.4 17 12518 Percentage of the requests served within a certain time (ms) 50% 17 66% 32 75% 39 80% 44 90% 121 95% 375 98% 1402 99% 6332 100% 12518 (last request) [root@host1 bin]# ./ab -n 10000 -c 100 -k http://ru-board.com/test/test2.php This is ApacheBench, Version 1.3d <$Revision: 1.73 $> apache-1.3 Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/ Benchmarking ru-board.com (be patient) Completed 1000 requests Completed 2000 requests Completed 3000 requests Completed 4000 requests Completed 5000 requests Completed 6000 requests Completed 7000 requests Completed 8000 requests Completed 9000 requests Finished 10000 requests Server Software: Apache Server Hostname: ru-board.com Server Port: 80 Document Path: /test/test2.php Document Length: 6733 bytes Concurrency Level: 100 Time taken for tests: 18.076 seconds Complete requests: 10000 Failed requests: 3113 (Connect: 0, Length: 3113, Exceptions: 0) Broken pipe errors: 0 Keep-Alive requests: 9969 Total transferred: 53110105 bytes HTML transferred: 50774468 bytes Requests per second: 553.22 [#/sec] (mean) Time per request: 180.76 [ms] (mean) Time per request: 1.81 [ms] (mean, across all concurrent requests) Transfer rate: 2938.16 [Kbytes/sec] received Connnection Times (ms) min mean[+/-sd] median max Connect: 0 1 6.0 0 239 Processing: 1 179 625.1 102 9084 Waiting: 0 178 625.1 101 9084 Total: 1 180 627.8 102 9084 Percentage of the requests served within a certain time (ms) 50% 102 66% 122 75% 159 80% 183 90% 237 95% 292 98% 511 99% 4055 100% 9084 (last request) [root@host1 bin]# | Второй тест это с использованием persistent коннектов mysql_pconnect() Кол-во Failed requests заметно ниже. Но все равно.. недопустимо.. Запрет кеширования в MySQL на результат не повлиял. Показатели в общем то остались прежними, изменения мизерны. Но оно и понятно, SQL запрос для мускула слишком простой, тем более что и таблица там супер просто, два поля и одна строка. Без разницы с кеша брать или нет. В реальности с большой таблицей результаты будут конечно хуже. P.S Во время теста, mysql кроме соб-но теста занималась еще кое чем . Выключать сайт ради чистоты тестов я не стал. Я ни коем образом не претендую ни на что. Кого не устраивает что-то, проводите свои тесты. |