<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Всем привет!</div><div><br></div><div>Не холливар, просто для размышлений. Долгих :)</div><div><br></div><div><br></div><div>Перевел пример на nodejs - <a href="https://github.com/Meettya/node-url-shortener">https://github.com/Meettya/node-url-shortener</a></div><div>старался по возможности ближе к исходному делать, дабы сравнение было валидно более-менее.</div><div><br></div><div>Если кратко:</div><div>-----</div><div>по скорости - </div><div>perl - <span class="Apple-tab-span" style="white-space:pre">  </span>   <span style="color: rgb(0, 0, 0); font-family: 'Bitstream Vera Sans Mono', Courier, monospace; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 16.78333282470703px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: pre; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); display: inline !important; float: none; ">Requests per second:    423.34</span></div><div><span style="color: rgb(0, 0, 0); font-family: 'Bitstream Vera Sans Mono', Courier, monospace; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 16.78333282470703px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: pre; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); display: inline !important; float: none; "><span style="color: rgb(0, 0, 0); font-family: 'Bitstream Vera Sans Mono', Courier, monospace; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 16.78333282470703px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: pre; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); display: inline !important; float: none; "><span class="Apple-tab-span" style="white-space:pre">     </span>Transfer rate:          42.17 </span></span></div><div><span style="color: rgb(0, 0, 0); font-family: 'Bitstream Vera Sans Mono', Courier, monospace; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 16.78333282470703px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: pre; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); display: inline !important; float: none; ">node -  </span><span style="color: rgb(0, 0, 0); font-family: 'Bitstream Vera Sans Mono', Courier, monospace; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 16.78333282470703px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: pre; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); display: inline !important; float: none; ">Requests per second:    1323.04</span></div><div><span style="color: rgb(0, 0, 0); font-family: 'Bitstream Vera Sans Mono', Courier, monospace; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 16.78333282470703px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: pre; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); display: inline !important; float: none; "><span style="color: rgb(0, 0, 0); font-family: 'Bitstream Vera Sans Mono', Courier, monospace; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 16.78333282470703px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: pre; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); display: inline !important; float: none; "><span class="Apple-tab-span" style="white-space:pre">     </span>Transfer rate:          267.45</span></span></div><div><br></div><div>----</div><div>по стабильности - при попытке сделать на моем маке</div><div><span style="color: rgb(0, 0, 0); font-family: 'Bitstream Vera Sans Mono', Courier, monospace; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 16.78333282470703px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: pre; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); display: inline !important; float: none; ">./ab -n 10000 -c 130 -k <a href="http://192.168.1.2:8080/?url">http://192.168.1.2:8080/?url</a></span><span class="o" style="margin: 0px; padding: 0px; line-height: 16.78333282470703px; font-weight: bold; color: rgb(0, 0, 0); font-family: 'Bitstream Vera Sans Mono', Courier, monospace; font-size: 12px; font-style: normal; font-variant: normal; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: pre; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">=</span><span class="nv" style="margin: 0px; padding: 0px; line-height: 16.78333282470703px; color: rgb(0, 128, 128); font-family: 'Bitstream Vera Sans Mono', Courier, monospace; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: pre; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">$RANDOM</span></div><div>получаю</div><div><pre style="margin: 0px; padding: 0px; font-style: normal; font-variant: normal; font-weight: normal; font-size: 12px; line-height: 1.4em; font-family: 'Bitstream Vera Sans Mono', Courier, monospace; color: rgb(0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div class="line" id="LC18" style="margin: 0px; padding: 0px 0px 0px 1em; line-height: 1.4em; ">Can<span class="err" style="margin: 0px; padding: 0px; line-height: 1.4em; color: rgb(166, 23, 23); background-color: rgb(227, 210, 210); ">'</span>t locate URI/http.pm:   Too many open files at <span class="o" style="margin: 0px; padding: 0px; line-height: 1.4em; font-weight: bold; ">(</span><span class="nb" style="margin: 0px; padding: 0px; line-height: 1.4em; color: rgb(0, 134, 179); ">eval </span>45<span class="o" style="margin: 0px; padding: 0px; line-height: 1.4em; font-weight: bold; ">)</span> line 2, <> line 6.</div><div class="line" id="LC19" style="margin: 0px; padding: 0px 0px 0px 1em; line-height: 1.4em; ">AnyEvent::Handle uncaught error: Broken pipe at /Users/meettya/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/Twiggy/Server.pm line 601.</div><div><br></div></pre></div><div>Если перегрузить ноду она просто делает отлуп ab, ничего не падает</div><div>(хз как его настраивать, не силен я в ab и во всем что с ним связано)</div><div><br></div><div>----</div><div>по расширяемости - для ноды это + 10 строк копипастного кода - и у вас кластер. та-даам!!</div><div><br></div><div>---</div><div>по читаемости - имхо паритет, в любом случае асинхронный код лапшеват выходит, можно отрефакторить, но пока лениво</div><div><br></div><div><br></div><div>все результаты здесь <a href="https://gist.github.com/3216375">https://gist.github.com/3216375</a></div><div>+ можете погонять на своей машине, постарался облегчить процесс установки</div><div><br></div><div>Короче, если кто-то еще считает, что нода "сыро и медленно" - у вас устаревшие сведения. Сильно устаревшие.</div><div><br></div><div>PS. вот описание системы - </div><div>perl - v5.16.0</div><div>node - v0.8.1</div><div><div>uname -a</div><div>Darwin TravelMate.local 11.4.0 Darwin Kernel Version 11.4.0: Mon Apr  9 19:33:05 PDT 2012; root:xnu-1699.26.8~1/RELEASE_I386 i386</div></div><div><br></div><div>PPS. Пошел бы на удаленке на node-powered проект :)</div><br><div><div>On Jul 30, 2012, at 10:04 PM, Alexey Shrub wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>Всем привет,<br><br>набросал для эксперимента простенький сокращатель ссылок на Twiggy<br><a href="https://github.com/worldmind/perl-url-shortener">https://github.com/worldmind/perl-url-shortener</a><br>работает, но у меня пока нет полного понимания всё ли правильно сделано, документации по твигги что-то совсем не нашёл, есть пример<br>https://github.com/miyagawa/Twiggy/blob/master/eg/chat-websocket/chat.psgi<br>но мне это мало помогло (видимо из-за коллбеков) и где-то откопал немного иной стиль с возвратом анонимной сабы и<br>  $w->write( "Short for $url is $server$short_url" );<br>  undef $w;<br>но не понятно какой способ рекомендуемый и чем отличается. Есть хоть какие-то ещё доки и примеры?<br><br>Ещё думаю как его отрефакторить чтобы почитаемее было.<br><br>И падает он периодически, видимо поэтому<br>https://rt.cpan.org/Public/Bug/Display.html?id=78177<br>у кого-то стабильно работает?<br><br>-- <br>Alexey Shrub<br>-- <br>Moscow.pm mailing list<br>moscow-pm@pm.org | http://moscow.pm.org<br></div></blockquote></div><br></body></html>