<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On 04 Nov 2013, at 18:09, Anatoly Mikhailov <<a href="mailto:anatoly@sonru.com">anatoly@sonru.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div><br class="Apple-interchange-newline">On 30 Oct 2013, at 12:08, Maxim Dounin <<a href="mailto:mdounin@mdounin.ru">mdounin@mdounin.ru</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Hello!<br><br>On Mon, Oct 28, 2013 at 12:34:33PM -0400, buddha wrote:<br><br><blockquote type="cite">Привет всем.<span class="Apple-converted-space"> </span><br>Знаю что вопрос уже обсуждался - почитал, попробовал - не выходит.<br><br>Есть проблема с медленной отдачей статики. Что это значит:<br><br>Отдача файла(js) ~40kb за 300-400ms<br>на<span class="Apple-converted-space"> </span><a href="http://drive.ru/">drive.ru</a><span class="Apple-converted-space"> </span>или ya 40kb за 70-90ms<br><br>Т.е. разница в разы. и она ощутима.<br><br>ping до сервера ~70ms<br>до drive и ya ~ 20-30ms<br><br>отдает Nginx, config:<br><br>location / {<br>  sendfile on;<br>  access_log off;<br>  expires 4M;<br><br>  root /var/www/static<br>}<br><br>сервер находится у хетцнера.<br><br>Подскажите как можно приблизить скорость отдачи к drive или ya.<br>Если сервер, диск(хотя iowait 0.01-0.05), то подскажите на что его можно<br>заменить<br></blockquote><br>Судя по цифрам, то, что у вас получается - это в первую очередь<span class="Apple-converted-space"> </span><br>результат большого RTT + работы механизмов Congestion Control<span class="Apple-converted-space"> </span><br>протокола TCP.<br><br>Можно пытаться походить в сторону тюнинга initial congestion<span class="Apple-converted-space"> </span><br>window size.  Но, строго говоря, много это всё равно не даст -<span class="Apple-converted-space"> </span><br>где-то пару round trip'ов можно сэкономить при использовании<span class="Apple-converted-space"> </span><br>сейчас усиленно продвигаемого initial cwnd в 10 пакетов (и чем<span class="Apple-converted-space"> </span><br>больше ответ - тем меньше разница).  Ну и на всякий случай<span class="Apple-converted-space"> </span><br>напомню, что с тюнингом таких вещей следует быть осторожным, т.к.  <br>подобные действия отражаются на всех в сети.  Прежде, чем<span class="Apple-converted-space"> </span><br>ковыряться - лучше как минимум ознакомиться с теоретической<span class="Apple-converted-space"> </span><br>стороной вопроса.<br></div></blockquote><div><br></div><div>Максим, разве Google не провел исследования, по результатам</div><div>которых они подняли icwnd до 10 на своих серверах?</div><div><br></div><div>В последних версиях Linux kernel icwnd уже 10 по умолчанию</div><div>и может дать обратный эффект только в очень редких случаях</div><div>на сегодняшний день.</div><div><br></div><div>TCP fast open в kernel 3.6+ следующей шаг, в который Google </div><div>вкладывает силы и деньги. </div></div></blockquote><div><br></div><div><div>Насколько мне известно, TCP Congestion window имеет смысл</div><div>при согласовании окон получателя и отправителя. ICWND 2/3 были</div><div>установлены по умолчанию много лет назад во времена dial-up.</div><div>TCP Slow Start обязательно иметь включенным, но start after idle </div><div>нет смысла оставлять 1 сек, как и размер окна 2/3.</div><div><br></div></div><div>Мы уделяли большое внимание оптимизации TCP/IP стэка, результаты</div><div>ниже. В течение длительного времени я не заметил побочных эффектов,</div><div>возможно они и есть. Ваше мнение?</div><div><br></div><div><div><span class="Apple-tab-span" style="white-space:pre">      </span>net.ipv4.tcp_slow_start_after_idle = 0</div><div><span class="Apple-tab-span" style="white-space:pre">       </span>net.ipv4.tcp_sack = 0</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>net.ipv4.tcp_timestamps = 0</div><div><span class="Apple-tab-span" style="white-space:pre">  </span>net.core.wmem_max = 256960</div><div><span class="Apple-tab-span" style="white-space:pre">   </span>net.core.rmem_max = 256960</div><div><span class="Apple-tab-span" style="white-space:pre">   </span>net.core.wmem_default = 256960</div><div><span class="Apple-tab-span" style="white-space:pre">       </span>net.core.rmem_default = 256960</div><div><span class="Apple-tab-span" style="white-space:pre">       </span>net.ipv4.tcp_wmem = 4096<span class="Apple-tab-span" style="white-space:pre">    </span>87380<span class="Apple-tab-span" style="white-space:pre">       </span>16777216</div><div><span class="Apple-tab-span" style="white-space:pre">     </span>net.ipv4.tcp_rmem = 4096<span class="Apple-tab-span" style="white-space:pre">    </span>87380<span class="Apple-tab-span" style="white-space:pre">       </span>16777216</div></div><div><br></div><br><blockquote type="cite"><div style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br><blockquote type="cite"><div style="font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br>Вообще, IMHO, в первую очередь имеет смысл смотреть за тем, чтобы<span class="Apple-converted-space"> </span><br>с клиентами обеспечивались постоянные соединения.  В nginx'е они<span class="Apple-converted-space"> </span><br>по умолчанию включены, но лишний раз проверить не помешает.  В<span class="Apple-converted-space"> </span><br>частности - посмотреть на директиву keepalive_timeout и убедиться,<span class="Apple-converted-space"> </span><br>что там никто не написал 0 в попытке поэкономить соединения.<br><br>--<span class="Apple-converted-space"> </span><br>Maxim Dounin<br><a href="http://nginx.org/en/donation.html">http://nginx.org/en/donation.html</a><br><br>_______________________________________________<br>nginx-ru mailing list<br><a href="mailto:nginx-ru@nginx.org">nginx-ru@nginx.org</a><br><a href="http://mailman.nginx.org/mailman/listinfo/nginx-ru">http://mailman.nginx.org/mailman/listinfo/nginx-ru</a></div></blockquote></div><br style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;">_______________________________________________</span><br style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;">nginx-ru mailing list</span><br style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><a href="mailto:nginx-ru@nginx.org" style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">nginx-ru@nginx.org</a><br style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><a href="http://mailman.nginx.org/mailman/listinfo/nginx-ru" style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">http://mailman.nginx.org/mailman/listinfo/nginx-ru</a></blockquote></div><br></body></html>