You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Michael Roberts <mi...@7f.com> on 2013/01/29 21:04:06 UTC

latency - websockets vs. REST

I'm seeing some differences in the latency of making a post request via
jQuery versus sending a websockets message.  It maybe that this is overhead
in my application caused by processing the json I am sending in the
message, but I find this hard to believe.  I imagined that web socket
connection should be faster than REST due to it not creating and destroying
the socket, however this does not seem to be the case.  Is there a reason
why websockets should be slower?

I thing I can code up a small test case to illustrate this if this is
something people are interested in ..

MR

Re: latency - websockets vs. REST

Posted by Michael Roberts <mi...@7f.com>.
oh, and this was using an established connection.  text message however.

On Tue, Jan 29, 2013 at 12:19 PM, Michael Roberts <mi...@7f.com> wrote:

>
> This was using .35 with the default connector (just a generic tomcat
> install using the installer, on windows 7 64bit) from current firefox.  I
> can't tell you the exact time difference currently, but I can say that if I
> chain the calling of the REST API off the end off the completion of the
> WebSocket's sendMessage, the REST API call will consistently beat the web
> socket to the end point.  Which (I think) means that either it's latency in
> moz's web socket implementation, or it's at the server end.
>
> I will make a test case which does exact timing and is separated from our
> application and report back on what I find.
>
> MR
>
> On Tue, Jan 29, 2013 at 12:11 PM, Mark Thomas <ma...@apache.org> wrote:
>
>> On 29/01/2013 20:04, Michael Roberts wrote:
>> > I'm seeing some differences in the latency of making a post request via
>> > jQuery versus sending a websockets message.  It maybe that this is
>> overhead
>> > in my application caused by processing the json I am sending in the
>> > message, but I find this hard to believe.  I imagined that web socket
>> > connection should be faster than REST due to it not creating and
>> destroying
>> > the socket, however this does not seem to be the case.  Is there a
>> reason
>> > why websockets should be slower?
>> >
>> > I thing I can code up a small test case to illustrate this if this is
>> > something people are interested in ..
>>
>> Tomcat version?
>> Connector?
>> How much difference?
>>
>> REST can (and should for performance) use HTTP keep-alive.
>>
>> There is some overhead in upgrading an HTTP connection to use WebSocket
>> so for a single request I'd expect the REST request to be faster. Once
>> both connections are established, WebSocket should be faster (note that
>> binary messages will be faster than text ones).
>>
>> If you have a test case that demonstrates this with established
>> connections I'd certainly be interested.
>>
>> Mark
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: dev-help@tomcat.apache.org
>>
>>
>

Re: latency - websockets vs. REST

Posted by Michael Roberts <mi...@7f.com>.
ok, I'll get to this start of next week with a comprehensive test case and
report back.

M

On Tue, Jan 29, 2013 at 12:23 PM, Martin Grigorov <mg...@apache.org>wrote:

> You can check with Google Chrome and/or IE10 to see whether it is not
> something in Firefox
>
>
> On Tue, Jan 29, 2013 at 9:19 PM, Michael Roberts <mi...@7f.com> wrote:
>
> > This was using .35 with the default connector (just a generic tomcat
> > install using the installer, on windows 7 64bit) from current firefox.  I
> > can't tell you the exact time difference currently, but I can say that
> if I
> > chain the calling of the REST API off the end off the completion of the
> > WebSocket's sendMessage, the REST API call will consistently beat the web
> > socket to the end point.  Which (I think) means that either it's latency
> in
> > moz's web socket implementation, or it's at the server end.
> >
> > I will make a test case which does exact timing and is separated from our
> > application and report back on what I find.
> >
> > MR
> >
> > On Tue, Jan 29, 2013 at 12:11 PM, Mark Thomas <ma...@apache.org> wrote:
> >
> > > On 29/01/2013 20:04, Michael Roberts wrote:
> > > > I'm seeing some differences in the latency of making a post request
> via
> > > > jQuery versus sending a websockets message.  It maybe that this is
> > > overhead
> > > > in my application caused by processing the json I am sending in the
> > > > message, but I find this hard to believe.  I imagined that web socket
> > > > connection should be faster than REST due to it not creating and
> > > destroying
> > > > the socket, however this does not seem to be the case.  Is there a
> > reason
> > > > why websockets should be slower?
> > > >
> > > > I thing I can code up a small test case to illustrate this if this is
> > > > something people are interested in ..
> > >
> > > Tomcat version?
> > > Connector?
> > > How much difference?
> > >
> > > REST can (and should for performance) use HTTP keep-alive.
> > >
> > > There is some overhead in upgrading an HTTP connection to use WebSocket
> > > so for a single request I'd expect the REST request to be faster. Once
> > > both connections are established, WebSocket should be faster (note that
> > > binary messages will be faster than text ones).
> > >
> > > If you have a test case that demonstrates this with established
> > > connections I'd certainly be interested.
> > >
> > > Mark
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> > > For additional commands, e-mail: dev-help@tomcat.apache.org
> > >
> > >
> >
>
>
>
> --
> Martin Grigorov
> jWeekend
> Training, Consulting, Development
> http://jWeekend.com <http://jweekend.com/>
>

Re: latency - websockets vs. REST

Posted by Martin Grigorov <mg...@apache.org>.
You can check with Google Chrome and/or IE10 to see whether it is not
something in Firefox


On Tue, Jan 29, 2013 at 9:19 PM, Michael Roberts <mi...@7f.com> wrote:

> This was using .35 with the default connector (just a generic tomcat
> install using the installer, on windows 7 64bit) from current firefox.  I
> can't tell you the exact time difference currently, but I can say that if I
> chain the calling of the REST API off the end off the completion of the
> WebSocket's sendMessage, the REST API call will consistently beat the web
> socket to the end point.  Which (I think) means that either it's latency in
> moz's web socket implementation, or it's at the server end.
>
> I will make a test case which does exact timing and is separated from our
> application and report back on what I find.
>
> MR
>
> On Tue, Jan 29, 2013 at 12:11 PM, Mark Thomas <ma...@apache.org> wrote:
>
> > On 29/01/2013 20:04, Michael Roberts wrote:
> > > I'm seeing some differences in the latency of making a post request via
> > > jQuery versus sending a websockets message.  It maybe that this is
> > overhead
> > > in my application caused by processing the json I am sending in the
> > > message, but I find this hard to believe.  I imagined that web socket
> > > connection should be faster than REST due to it not creating and
> > destroying
> > > the socket, however this does not seem to be the case.  Is there a
> reason
> > > why websockets should be slower?
> > >
> > > I thing I can code up a small test case to illustrate this if this is
> > > something people are interested in ..
> >
> > Tomcat version?
> > Connector?
> > How much difference?
> >
> > REST can (and should for performance) use HTTP keep-alive.
> >
> > There is some overhead in upgrading an HTTP connection to use WebSocket
> > so for a single request I'd expect the REST request to be faster. Once
> > both connections are established, WebSocket should be faster (note that
> > binary messages will be faster than text ones).
> >
> > If you have a test case that demonstrates this with established
> > connections I'd certainly be interested.
> >
> > Mark
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: dev-help@tomcat.apache.org
> >
> >
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com <http://jweekend.com/>

Re: latency - websockets vs. REST

Posted by Michael Roberts <mi...@7f.com>.
This was using .35 with the default connector (just a generic tomcat
install using the installer, on windows 7 64bit) from current firefox.  I
can't tell you the exact time difference currently, but I can say that if I
chain the calling of the REST API off the end off the completion of the
WebSocket's sendMessage, the REST API call will consistently beat the web
socket to the end point.  Which (I think) means that either it's latency in
moz's web socket implementation, or it's at the server end.

I will make a test case which does exact timing and is separated from our
application and report back on what I find.

MR

On Tue, Jan 29, 2013 at 12:11 PM, Mark Thomas <ma...@apache.org> wrote:

> On 29/01/2013 20:04, Michael Roberts wrote:
> > I'm seeing some differences in the latency of making a post request via
> > jQuery versus sending a websockets message.  It maybe that this is
> overhead
> > in my application caused by processing the json I am sending in the
> > message, but I find this hard to believe.  I imagined that web socket
> > connection should be faster than REST due to it not creating and
> destroying
> > the socket, however this does not seem to be the case.  Is there a reason
> > why websockets should be slower?
> >
> > I thing I can code up a small test case to illustrate this if this is
> > something people are interested in ..
>
> Tomcat version?
> Connector?
> How much difference?
>
> REST can (and should for performance) use HTTP keep-alive.
>
> There is some overhead in upgrading an HTTP connection to use WebSocket
> so for a single request I'd expect the REST request to be faster. Once
> both connections are established, WebSocket should be faster (note that
> binary messages will be faster than text ones).
>
> If you have a test case that demonstrates this with established
> connections I'd certainly be interested.
>
> Mark
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>
>

Re: latency - websockets vs. REST

Posted by Mark Thomas <ma...@apache.org>.
On 29/01/2013 20:04, Michael Roberts wrote:
> I'm seeing some differences in the latency of making a post request via
> jQuery versus sending a websockets message.  It maybe that this is overhead
> in my application caused by processing the json I am sending in the
> message, but I find this hard to believe.  I imagined that web socket
> connection should be faster than REST due to it not creating and destroying
> the socket, however this does not seem to be the case.  Is there a reason
> why websockets should be slower?
> 
> I thing I can code up a small test case to illustrate this if this is
> something people are interested in ..

Tomcat version?
Connector?
How much difference?

REST can (and should for performance) use HTTP keep-alive.

There is some overhead in upgrading an HTTP connection to use WebSocket
so for a single request I'd expect the REST request to be faster. Once
both connections are established, WebSocket should be faster (note that
binary messages will be faster than text ones).

If you have a test case that demonstrates this with established
connections I'd certainly be interested.

Mark


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org