1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
<tt>
Is 13.6K/connection considered a lot? Once you start doing SSL, each connection will be about 80K, IMHO the most important factor for huge ammount of COMET users is latency, which Cowboy and Erlang do great.<div><br></div><br>
<div>-rambocoder<br><br><div class="gmail_quote">On Fri, Apr 26, 2013 at 2:11 AM, yongboy <span dir="ltr"><<a href="mailto:[email protected]" target="_blank">[email protected]</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<div dir="ltr"><div><div>I have tested one long-hold webapp, when 512000 user connected, the app used <br></div>6801M memory, 6801M*1024K / 512000 = 13.6K/Connection.<br><br></div><div>Does anyone give me some advice on how to reduce the memory usage per one connection, thanks very much !<br><br>
<br>
</div><div><br></div>Here is the code snippet:<br><br>start(_Type, _Args) -><br>������� Dispatch = cowboy_router:compile([<br>����������� {'_', [{'_', htmlfile_handler, []}]}<br>������� ]),<br>������� cowboy:start_http(my_http_listener, 100,<br><br>
<br>
����������� [{port, 8000}, {max_connections, infinity}],<br>����������� [{env, [{dispatch, Dispatch}]}]<br>������� ),<br>������� count_server:start(),<br>������� htmlfilesimple_sup:start_link().<br><br>......<br><br>-module(htmlfile_handler).<br><br>
<br>
-behaviour(cowboy_loop_handler).<br>-export([init/3, info/3, terminate/3]).<br>-define(HEARBEAT_TIMEOUT, 20*1000).<br>-record(status, {count=0}).<br><br>init(_Any, Req, State) -><br>������� NowCount = count_server:welcome(),<br><br>
<br>
������� io:format("online user ~p :))~n", [NowCount]),<br><br>������� output_first(Req),<br>������� Req2 = cowboy_req:compact(Req),<br>������� {loop, Req2, State, hibernate}.<br><br>%% POST/Short Request<br>info(_Any, Req, State) -><br><br>
<br>
������� {loop, Req, State, hibernate}.<br><br>output_first(Req) -><br>������� {ok, Reply} = cowboy_req:chunked_reply(200, [{<<"Content-Type">>, <<"text/html; charset=utf-8">>},<br><br>
<br>
���������������������������������������������������������������� {<<"Connection">>, <<"keep-alive">>}], Req),<br>������� cowboy_req:chunk(<<"<html><body><script>var _ = function (msg) { parent.s._(msg, document); };</script>����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������� ">>,<br><br>
<br>
��������������������������������������������������������������� Reply),<br>������� cowboy_req:chunk(gen_output("1::"), Reply).<br><br>gen_output(String) -><br>������� DescList = io_lib:format("<script>_('~s');</script>", [String]),<br><br>
<br>
������� list_to_binary(DescList).<br><br>terminate(Reason, _Req, _State) -><br>������� NowCount = count_server:bye(),<br>������� io:format("offline user ~p :(( ~n", [NowCount]).<br><br><br><br></div><br>
<br>_______________________________________________<br><br>
Extend mailing list<br><br>
<a href="mailto:[email protected]">[email protected]</a><br><br>
<a href="http://lists.ninenines.eu:81/listinfo/extend" target="_blank">http://lists.ninenines.eu:81/listinfo/extend</a><br><br>
<br></blockquote></div><br></div><br>
</tt>
|