Hello,<br><br>First of all I would like to say that I tested the server on a 4 cores instance and it works very nicely with 2000 users.<br>The load average is about 0.3 (it was about 9-10 with 2 cores), so it looks very good. I'll test with a larger number of clients, but so far it's a very big improvement.<br>
<br>Unfortunately, as I switched to a larger instance, I immediately configured erlang with --enable-hipe so I'm not sure if that caused an improvement or is it due to the more CPU power. I'll play some more to find out.<br>
<br>In any case, below is the code for the server. I don't know if I can post attachments to the mailing list so I embedded the code inline. The client code is very untidy at the moment, so I didn't include it. Basically it amounts to N processes which do following:<br>
<br><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"></blockquote><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;">ibrowse:send_req(Url, <br>
[{'Content-Type', 'application/x-www-form-urlencoded'}], post, <br> "", <br> [{ssl_options, [{depth, 0}]}, {max_sessions, 1000}, {max_pipeline_size, 1000}], <br> 10000<br> )<br></blockquote>
<div><br></div>The Url is a string such as "<a href="https://test-server.some.domain:9999">https://test-server.some.domain:9999</a><div><br><div><br></div><div>The server is in the file ssl_server.erl. I also didn't provide the SSL keys.</div>
<div><br></div><div><div>-module(ssl_server).</div><div>-export([start/0]).</div><div><br></div><div><br></div><div>-define(HTTPS_OPTS, [</div><div> {port, 9999},</div><div> {name, https_test},</div><div> {ssl, true},</div>
<div> {ssl_opts, [</div><div> {ssl_imp, new},</div><div> {cacertfile, "keys/cacert.pem"},</div><div> {certfile, "keys/cert.pem"},</div><div> {keyfile, "keys/cert.key"},</div><div>
{depth, 0}</div><div> ]}</div><div>]).</div><div><br></div><div>-define(HTTP_OPTS, [</div><div> {port, 8888},</div><div> {name, http_test}</div><div>]).</div><div><br></div><div>start() -></div><div> application:start(crypto),</div>
<div> application:start(ssl),</div><div> </div><div> {ok, FeederPid} = start_feed(),</div><div> </div><div> Loop = fun(Req) -></div><div> dispatch(Req, FeederPid)</div><div> end,</div><div> </div><div> {ok, Https} = mochiweb_http:start([{loop, Loop} | ?HTTPS_OPTS]),</div>
<div> {ok, Http} = mochiweb_http:start([{loop, Loop} | ?HTTP_OPTS]),</div><div> wait_loop().</div><div> </div><div>wait_loop() -></div><div> timer:sleep(60000),</div><div> wait_loop().</div><div><br></div><div>% invoked from mochi web for each request</div>
<div>dispatch(Req, FeederPid) -></div><div> FeederPid ! {add, self()}, % register with the feeder</div><div> receive</div><div> {respond, Message} -> % on feeder signal</div><div> Req:ok({"text/plain", Message})</div>
<div> after 10000 -> Req:not_found() % timeout</div><div> end.</div><div><br></div><div> </div><div>start_feed() -></div><div> FeederPid = proc_lib:spawn_link(fun feeder/0), % start feeder process</div><div> proc_lib:spawn_link(fun() -> heartbeat(FeederPid) end), % start heartbeat process</div>
<div> {ok, FeederPid}.</div><div><br></div><div>% heartbeat - signal feeder in regular intervals</div><div>heartbeat(Feeder) -> </div><div> timer:sleep(5000),</div><div> Feeder ! {broadcast, "message"},</div>
<div> heartbeat(Feeder).</div><div><br></div><div><br></div><div>% feeder </div><div>feeder() -> feeder([]).</div><div><br></div><div>feeder(Children) -></div><div> NewChildren = receive</div><div> {add, Child} -> % child registered</div>
<div> [Child | Children];</div><div> </div><div> {broadcast, Message} -> % heartbeat signaled</div><div> io:format("broadcasting to ~p processes~n", [length(Children)]),</div><div> </div>
<div> lists:foreach(fun(Child) -></div><div> Child ! {respond, Message}</div><div> end, Children),</div><div> []</div><div> end,</div><div> </div><div> feeder(NewChildren).</div></div><br><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;">
</blockquote><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"></blockquote><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;">
</blockquote><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"></blockquote>Best regards,<br>Sasa<br><br><br><br>On Mon, May 9, 2011 at 9:59 AM, Ingela Andin <<a href="mailto:ingela.andin@gmail.com">ingela.andin@gmail.com</a>> wrote:<br>
> Hi!<br>><br>> If you want to make sure that you run the new implementation you can use the<br>> option {ssl_imp, new} but if you run R14B02 and do not specify {ssl_imp, old}<br>> you should get the new one. When looking closer at your earlier post<br>
> the occational error-report<br>> is from the new implementation, so I think that is not the issue. You<br>> mentioned that you could<br>> provide a test program, if you could send that to me so I can test it<br>
> agaist the latest ssl code<br>> that would be great. All your problems might not have to do with<br>> erlang-ssl but it sure looks like<br>> there might be atleast one bug that needs fixing.<br>><br>> Regards Ingela Erlang/OTP team - Ericsson AB<br>
><br>> 2011/5/6 sasa <<a href="mailto:sasa555@gmail.com">sasa555@gmail.com</a>>:<br>>> Hello,<br>>><br>>> On Fri, 2011-05-06 at 21:30 +0200, Ingela Andin wrote:<br>>><br>>> Where you using the old or the new erlang ssl implementation? Old ssl<br>
>> scales poorly.<br>>><br>>> If you use new ssl and not make any special configuration it will<br>>> always automatically<br>>> try to reuse sessions. (The server can refuse to reuse a session if it wants<br>
>> to)<br>>> How the old implementation works I can not remember from the<br>>> top of my head but if you are using the old one I recomend upgrading<br>>> to the new one.<br>>> The new one is default in R14* and before that the old one is default.<br>
>> I recomend R14.<br>>><br>>> I am using erlang R14B02, so I suppose it is the new ssl. Is there any way I<br>>> can verify which implementation is actually used? Could it be that I was<br>>> missing some dependency during the compilation of the erlang and the old ssl<br>
>> is actually used even though it is the version R14?<br>>><br>>> Sasa<br>>> _______________________________________________<br>>> erlang-questions mailing list<br>>> <a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
>> <a href="http://erlang.org/mailman/listinfo/erlang-questions">http://erlang.org/mailman/listinfo/erlang-questions</a><br>>><br>>><br>><br><br></div>