OK, the competition comes again. I finally wrote a client that performs decently. It's <a href="https://github.com/awsong/Golang-WebSocket-Client" target="_blank">here</a>.<div><br></div><div>I tested my previous Cowboy first( I changed send_interval from 1000 to 900000 of line 64 of src/websocket_handler.erl in cowboy_examples ). Here is the version:</div>




<div><b>Cowboy_examples</b>: 343d002 Initial commit with a default and websocket handler.</div><div><b>Cowboy</b>: 5d69825 Add a max_connections transport option, Mon May 9 22:01:31 2011</div><div><br></div><div>The command line I use on the client is "./conn -c 10000 -n 10". It'll create 100K connections, 10K per IP to the server. It takes about 7 and half minutes to finish creating these connections. During the creation, server CPU usage is about 110%(dual core), client cpu usage is under 20%. </div>




<div><br></div><div>Server memory usage(Cowboy residence memory) :</div><div>Right after Cowboy starts: 525M</div><div><div>After 100K connection established: 1842M</div></div>
<div><div>After 5M packets passed: 2824M</div></div><div>After 9M packets passed: 3231M</div><div><div>After 87.7 M packets passed, 5746M</div></div><div><div>[{total,<a href="tel:4155518040" value="+14155518040" target="_blank">4155518040</a>},</div>


<div> {processes,1701318856},</div>
<div> {processes_used,1701299096},</div><div> {system,2454199184},</div><div> {atom,497457},</div><div> {atom_used,482279},</div><div> {binary,1787851232},</div><div> {code,4041219},</div><div> {ets,41231176}]</div></div>




<div>There seems a memory leak. If I don't stop, the memory usage will keep going higher. 40% CPU, 1.5 MB/s traffic. </div><div><br></div><div><b>Latest Cowboy and Cowboy_examples</b> (same send_interval change). It takes about 7 and half minutes to finish creating 100K connections. During the creation, server CPU usage is about 110%(dual core), client cpu usage is under 20%. After 158.9M packets passed, 1464M residence memory used, 30% CPU, 1.5 MB/s traffic, .</div>




<div><br></div><div><b>Latest Misultin</b> from github, with patch (see attachment):</div><div>It takes about 45s to finish creating 100K connections, during creation cpu usage is 120%. After creation, residence memory usage is 2684M. And it goes down slowly to 1416M after 40M packets are passed, cpu usage is about 50%</div>

<div><br></div><div>Another thing worth to note is that when I hit CTRL-C on the client side, misultin will quickly destroy the connections and release memory and go back to normal. But Cowboy will consume almost all the cpu time and stay there for a long time (I didn't have the patience to measure how long, so just hit ctrl-c to quick erlang).</div>

<div><br></div><div>Cheers</div><div>Andy</div>
<div><br></div><div><br><div class="gmail_quote">On Wed, Jun 1, 2011 at 8:26 PM, Andy W. Song <span dir="ltr"><<a href="mailto:wsongcn@gmail.com" target="_blank">wsongcn@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">




BTW, the latest version uses less memory too, about 3.2G for 200K connections.<div><div></div><div><br><br><div class="gmail_quote">On Wed, Jun 1, 2011 at 8:23 PM, Andy W. Song <span dir="ltr"><<a href="mailto:wsongcn@gmail.com" target="_blank">wsongcn@gmail.com</a>></span> wrote:<br>





<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Missed one attachment.<div><div></div><div><br><br><div class="gmail_quote">On Wed, Jun 1, 2011 at 8:21 PM, Andy W. Song <span dir="ltr"><<a href="mailto:wsongcn@gmail.com" target="_blank">wsongcn@gmail.com</a>></span> wrote:<br>





<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I tested out the latest Misultin with this change, CPU usage is about 2 to 3 percent lower. <div><br></div><div>With the attached Misultin package, I can still reproduce the large packet problem. </div><div><br></div><div>







With latest version, Misultin doesn't report any error. But it doesn't reply to the client either. Seems it just drops the packet. Another attached file is the tcpdump result. </div><div><br></div><div>I will try Mochiweb later just to compare.<div>






<div></div><div><br>
<br><div class="gmail_quote">On Wed, Jun 1, 2011 at 12:09 AM, Roberto Ostinelli <span dir="ltr"><<a href="mailto:roberto@widetag.com" target="_blank">roberto@widetag.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">







<div style="word-wrap:break-word"><div><br><div><div>On May 31, 2011, at 12:54 PM, Andy W. Song wrote:</div><br><blockquote type="cite"><div>Would you mind testing it using my C client? Search "->len" and give<br>







it a value between 1500 and 2000, hopefully you'll see the result I<br>saw.<br><br>Regards<br>Andy</div></blockquote><br></div></div><div>Hi Andy,</div><div><br></div><div>will do that.</div><div><br></div><div>Meanwhile, I've added an undocumented option, {ws_no_header, true} so that headers are not duplicated in the record and should use less memory. plus, I've optimized binary code for websockets.</div>







<div><br></div><div>can you please retry the test so we have a matter of comparison?</div><div><br></div><div>the only thing you need to change is to add this option in misultin initialization, i.e.:</div><div><br></div>






<div>
<div>% start misultin http server</div><div>start(Port) -></div><div><span style="white-space:pre-wrap">       </span>misultin:start_link([</div><div><span style="white-space:pre-wrap">            </span> <b>{ws_no_header, true},</b></div>







<div><span style="white-space:pre-wrap">          </span>{port, Port}, {loop, fun(Req) -> handle_http(Req, Port) end},</div><div><span style="white-space:pre-wrap">         </span>{ws_loop, fun(Ws) -> handle_websocket(Ws) end}, {ws_autoexit, false}</div>







<div><span style="white-space:pre-wrap">  </span>]).</div><div><br></div><div>please let me know...</div><div><br></div><font color="#888888"><div>r.</div></font></div></div></blockquote></div><br><br clear="all"><br></div>






</div>-- <br><div>
<div>---------------------------------------------------------------</div><div>有志者,事竟成,破釜沉舟,百二秦关终属楚</div><div>苦心人,天不负,卧薪尝胆,三千越甲可吞吴</div><br>
</div></div>
</blockquote></div><br><br clear="all"><br>-- <br><div>---------------------------------------------------------------</div><div>有志者,事竟成,破釜沉舟,百二秦关终属楚</div><div>苦心人,天不负,卧薪尝胆,三千越甲可吞吴</div><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><div>---------------------------------------------------------------</div><div>有志者,事竟成,破釜沉舟,百二秦关终属楚</div><div>苦心人,天不负,卧薪尝胆,三千越甲可吞吴</div><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><div>---------------------------------------------------------------</div><div>有志者,事竟成,破釜沉舟,百二秦关终属楚</div><div>苦心人,天不负,卧薪尝胆,三千越甲可吞吴</div><br>
</div>