Message from discussion
SocksJS performance with a lot of users
Received: by 10.58.15.10 with SMTP id t10mr10017292vec.6.1351324046111;
Sat, 27 Oct 2012 00:47:26 -0700 (PDT)
X-BeenThere: sockjs@googlegroups.com
Received: by 10.52.30.49 with SMTP id p17ls5730873vdh.4.gmail; Sat, 27 Oct
2012 00:47:25 -0700 (PDT)
Received: by 10.58.181.65 with SMTP id du1mr9873935vec.36.1351324045671;
Sat, 27 Oct 2012 00:47:25 -0700 (PDT)
Received: by 10.58.181.65 with SMTP id du1mr9873934vec.36.1351324045656;
Sat, 27 Oct 2012 00:47:25 -0700 (PDT)
Return-Path: <glebe...@gmail.com>
Received: from mail-vb0-f49.google.com (mail-vb0-f49.google.com [209.85.212.49])
by gmr-mx.google.com with ESMTPS id bn19si452891vdb.0.2012.10.27.00.47.25
(version=TLSv1/SSLv3 cipher=OTHER);
Sat, 27 Oct 2012 00:47:25 -0700 (PDT)
Received-SPF: pass (google.com: domain of glebe...@gmail.com designates 209.85.212.49 as permitted sender) client-ip=209.85.212.49;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of glebe...@gmail.com designates 209.85.212.49 as permitted sender) smtp.mail=glebe...@gmail.com; dkim=pass header...@gmail.com
Received: by mail-vb0-f49.google.com with SMTP id fo1so3614574vbb.36
for <sockjs@googlegroups.com>; Sat, 27 Oct 2012 00:47:25 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20120113;
h=mime-version:in-reply-to:references:date:message-id:subject:from:to
:cc:content-type;
bh=bYQrni8aedfE1oUSR0y0aUeO9cpthTwTZagmJzZ31l0=;
b=SvQEia0a9vMBv662H4zbrKevM+3BfKJXPQql2F/4HCH6p0oPX0cm1bg3FY7fc6ZtGK
cwNNEzbIHpZSYEDONowXQQl/hWZog3kuTvCa/JhbC1SvaXyC5ovPAtDmbtgSXW3RvsJm
fiYYMqRsquUCjEgTttAWBB/eyPbWdfUtwFPzR/elxm7bduvrrkGgLey9JGqVTwvIKrRd
1e6cjU9rv5sy7R3zZ2pXiZAm7tkNZr7c3SxcifhSeIbLzcA3zhkykzibacBTVwWs1rYz
TUQDR/Ikt8u5lhyyz76iIFqlSHIkpZ0wu5QulMShJ+8dLL8YjjMtt6Ah4zDVIDZbcSCI
mgUQ==
MIME-Version: 1.0
Received: by 10.58.168.135 with SMTP id zw7mr43553842veb.4.1351324045550; Sat,
27 Oct 2012 00:47:25 -0700 (PDT)
Received: by 10.58.64.15 with HTTP; Sat, 27 Oct 2012 00:47:25 -0700 (PDT)
In-Reply-To: <CANZWjw7YHdkA1O9OA4zaFn+v1mZqMzTughgVg_44oc_SZEH...@mail.gmail.com>
References: <CANZWjw4yPegUGg4f7M3Odo0G_QEJPyRYcT5urkTd8r5uqnu...@mail.gmail.com>
<CABzX+qwB+Wbd+qZcFM-RGXZE+jdvDve+4nt1gsK02Bd_QNu...@mail.gmail.com>
<CADOS1qJvZARLQ0yoHvmyBPAy4qhAFcB3WpgY9s56ZOo75Du...@mail.gmail.com>
<CANZWjw5u0YRGWrgeAWP6rveaNNS83ywh3Lim=DW8ua8K5Wq...@mail.gmail.com>
<CABzX+qydQuATvyFsCiOk3THLBNSSVQAh1mSKnZ9pgtOpRg4...@mail.gmail.com>
<CANZWjw50m9-fHtRiyRxv1fjBGiWqyM1h_3hZzjWjEMrfuVn...@mail.gmail.com>
<CADOS1qL429BTqsfac52=GWGBo1CmuhtoXUroswe2uzEig7f...@mail.gmail.com>
<CANZWjw5gE+DbMDdq77NmKRP+=ZmjzTGJYb_ZzEuK-eARRB7...@mail.gmail.com>
<CADOS1qLYF3gCtihFGCAtgKedEtPMY2SrSmJZ059uHVW+sdo...@mail.gmail.com>
<CANZWjw5OMgRwMpQKYf23fB+qeZATBnFCDePFAe4601yoRgu...@mail.gmail.com>
<CADOS1qKdkpntH=3UrvTUTKiLmgBtbCGzKCc_n1jJVLY3VuP...@mail.gmail.com>
<CANZWjw7YHdkA1O9OA4zaFn+v1mZqMzTughgVg_44oc_SZEH...@mail.gmail.com>
Date: Sat, 27 Oct 2012 09:47:25 +0200
Message-ID: <CADOS1qLAO=_8rqO1oEzAB0Zq9r4AgoaY82xQE_zs5wC+3kF...@mail.gmail.com>
Subject: Re: [sockjs] SocksJS performance with a lot of users
From: Gleb Peregud <glebe...@gmail.com>
To: AD <straightfl...@gmail.com>
Cc: Marek Majkowski <maje...@gmail.com>, sockjs <sockjs@googlegroups.com>
Content-Type: multipart/alternative; boundary=047d7b678494b6258904cd05a58f
--047d7b678494b6258904cd05a58f
Content-Type: text/plain; charset=UTF-8
Sounds good in general. But there's no need to do iolist_to_binary in the
end if you do properly prepare the frame to be sent. Also please note that
non-raw-websockets protocol needs different encodings, hence PreparedFame
will have multiple versions of encoded data in the end (I've used record
with 3 binary fields)
On Thursday, October 25, 2012, AD wrote:
> Here is my thought, let me know if this would work. This is just for raw
> websockets for now since this seems to be handled in different places
>
> 1) add a new method in sockjs_session called send_multi/2 which would
> accept 2 params (Data, ListOfConn).
> 2) first step of send_multi would call sockjs_util:encode_frame on Data
> just once
> 3) loop through ListofConn and pass Frame output to send method in
> sockjs_session
> 4) modify sockjs_ws_handler:reply to NOT encode frame and just return
> iolist_to_binary(Frame)
>
> Thoughts ?
>
> On Thu, Oct 18, 2012 at 4:07 PM, Gleb Peregud <glebe...@gmail.com<javascript:_e({}, 'cvml', 'glebe...@gmail.com');>
> > wrote:
>
>> It's my own word, sorry for not explaining. Essentially I am doing it
>> this way:
>> 1) socket handler process (let's call it A) receives a request
>> 2) if a request is going to long-poll, then:
>> 3) A transfers ownership of socket to session process (let's call it B)
>> 4) A issues a infinity-timeout gen_server call with socket and Req to B
>> 5) A is sleeping
>> 6) B handles the request till the end of long-poll including sending the
>> data
>> 7) after it A resumes and finalizes all usual cowboy handling stuff
>> and, usually, dies
>>
>> On Thu, Oct 18, 2012 at 10:03 PM, AD <straightfl...@gmail.com<javascript:_e({}, 'cvml', 'straightfl...@gmail.com');>>
>> wrote:
>> > Thanks, not familiar with "attaching" a sockjs_session process really
>> means.
>> >
>> >
>> > On Wed, Oct 17, 2012 at 2:13 PM, Gleb Peregud <glebe...@gmail.com<javascript:_e({}, 'cvml', 'glebe...@gmail.com');>>
>> wrote:
>> >>
>> >> On Wed, Oct 17, 2012 at 8:09 PM, AD <straightfl...@gmail.com<javascript:_e({}, 'cvml', 'straightfl...@gmail.com');>>
>> wrote:
>> >> > Meaning you dont spawn a new sockjs_session for every connection ?
>> >>
>> >> I do. But that process "attaches" itself to sockjs_session process and
>> >> passes socket's ownership to session. This greatly reduce latency.
>> >>
>> >> For websocket connections, essentially, sockjs_ws_handler duplicates
>> >> all of sockjs_session functions, but in much simplified manner due to
>> >> simplicity of WS connection handling.
>> >
>> >
>>
>
>
--047d7b678494b6258904cd05a58f
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Sounds good in general. But there's no need to do iolist_to_binary in t=
he end if you do properly prepare the frame to be sent. Also please note th=
at non-raw-websockets protocol needs different encodings, hence PreparedFam=
e will have multiple versions of encoded data in the end (I've used rec=
ord with 3 binary fields)<span></span><div>
<br>On Thursday, October 25, 2012, AD wrote:<br><blockquote class=3D"gmail=
_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:=
1ex">Here is my thought, let me know if this would work. This is just for r=
aw websockets for now since this seems to be handled in different places<di=
v>
<br></div><div>1) add a new method in sockjs_session called =C2=A0send_mult=
i/2 which would accept 2 params (Data, ListOfConn).</div>
<div>2) first step of send_multi would call sockjs_util:encode_frame on Dat=
a just once</div><div>3) loop through ListofConn and pass Frame output to s=
end method in sockjs_session</div><div>4) modify sockjs_ws_handler:reply to=
NOT encode frame and just return iolist_to_binary(Frame)<br>
<br>Thoughts ?<br><br><div class=3D"gmail_quote">On Thu, Oct 18, 2012 at 4:=
07 PM, Gleb Peregud <span dir=3D"ltr"><<a href=3D"javascript:_e({}, '=
;cvml', 'glebe...@gmail.com');" target=3D"_blank">gleber.p@gmai=
l.com</a>></span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">
It's my own word, sorry for not explaining. Essentially I am doing it t=
his way:<br>
1) socket handler process (let's call it A) receives a request<br>
2) if a request is going to long-poll, then:<br>
3) A transfers ownership of socket to session process (let's call it B)=
<br>
4) A issues a infinity-timeout gen_server call with socket and Req to B<br>
5) A is sleeping<br>
6) B handles the request till the end of long-poll including sending the da=
ta<br>
7) after it A resumes and finalizes all usual cowboy handling stuff<br>
and, usually, dies<br>
<div><div><br>
On Thu, Oct 18, 2012 at 10:03 PM, AD <<a href=3D"javascript:_e({}, '=
cvml', 'straightfl...@gmail.com');" target=3D"_blank">straightf=
l...@gmail.com</a>> wrote:<br>
> Thanks, not familiar with "attaching" a sockjs_session proce=
ss really means.<br>
><br>
><br>
> On Wed, Oct 17, 2012 at 2:13 PM, Gleb Peregud <<a href=3D"javascrip=
t:_e({}, 'cvml', 'glebe...@gmail.com');" target=3D"_blank">=
glebe...@gmail.com</a>> wrote:<br>
>><br>
>> On Wed, Oct 17, 2012 at 8:09 PM, AD <<a href=3D"javascript:_e({=
}, 'cvml', 'straightfl...@gmail.com');" target=3D"_blank">s=
traightfl...@gmail.com</a>> wrote:<br>
>> > Meaning you dont spawn a new sockjs_session for every connect=
ion ?<br>
>><br>
>> I do. But that process "attaches" itself to sockjs_sessi=
on process and<br>
>> passes socket's ownership to session. This greatly reduce late=
ncy.<br>
>><br>
>> For websocket connections, essentially, sockjs_ws_handler duplicat=
es<br>
>> all of sockjs_session functions, but in much simplified manner due=
to<br>
>> simplicity of WS connection handling.<br>
><br>
><br>
</div></div></blockquote></div><br></div>
</blockquote></div>
--047d7b678494b6258904cd05a58f--