Discussion:
WebSockets and JSPs
Jerry Malcolm
2018-10-16 03:16:01 UTC
Permalink
I have several webapps that do a significant amount of recursive loads
of snippits of HTML utilizing XHR/http/ajax requests. These apps are all
debugged and in production.   The server has no problem whatsoever in
keeping up with the multiple concurrent requests.  However, the
open-connection limits on the browsers that block more than 6 concurrent
connections to a server is killing me in performance.

I've been looking into WebSockets which I understand does not incur the
wrath of the browsers when I have a need for more than 6 concurrent
connections.   I have no problem making a move to WebSockets if that
will indeed help performance.  However, I have literally many hundreds
of JSPs that are coded, tested, and working.  So I'd like to minimize
the rip-up to the JSPs.

I've googled around trying to find answers about how (if) I can invoke
JSPs via WebSockets.  From what I can tell, it appears it's possible. 
But no straightforward explanation.   A WebSocket servlet extends
"WebSocketServlet", correct?  But JSPs extend HTTPServlet, at least by
default, correct.  So that seems like an fairly big immediate problem.

Do I need to do some gyrations like writing a WebSocket router servlet
object that turns around and creates/invokes a normal http call to
invoke the desired JSP?  (BTW... I don't need any of the bi-directional
capabilities of WebSockets currently.... simply an "http emulator"
functionality for now).

I guess I could get multiple IP addresses for the server and set up
multiple secondary domain names to 'fool' the browsers into thinking the
requests aren't all going to the same server thereby getting 6 requests
per 'server'.  But at best that's a total hack, and not an inviting
solution.

Any other suggestions (short of changing up the architecture to no
longer require multiple concurrent loads)  will be welcomed. Likewise,
and corrections to any errant assumptions I have made so far are also
welcome.

Thx.

Jerry


---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@tomcat.apache.org
For additional commands, e-mail: users-***@tomcat.apache.org
Shawn Heisey
2018-10-16 04:00:06 UTC
Permalink
Post by Jerry Malcolm
I have several webapps that do a significant amount of recursive loads
of snippits of HTML utilizing XHR/http/ajax requests. These apps are
all debugged and in production.   The server has no problem whatsoever
in keeping up with the multiple concurrent requests.  However, the
open-connection limits on the browsers that block more than 6
concurrent connections to a server is killing me in performance.
I know pretty much nothing about the things you asked about after this
paragraph.  But I do know about one thing that might help you --
HTTP/2.  It can execute many HTTP requests simultaneously over a single
TCP connection.

Here's a demo:

https://http2.akamai.com/demo

I really have no idea how to enable HTTP/2 in Tomcat, but I know that it
can be done if you have a new enough version. Browsers with HTTP/2
support should automatically multiplex requests to the same server over
fewer connections.

Another possibility is to put your web services behind a load balancer
that supports HTTP/2 on the front end.  Haproxy is one that I am aware
of with that support.

HTTP/2 promises to obsolete many of the development and software tricks
used in the past for improving web performance. Designing applications
for performance has typically involved combining code into fewer files
instead of aspiring to a highly modular application.  With HTTP/2, you
can split things up without killing performance.

If anything I have said above is wrong, I would appreciate the community
informing me about my errors.

Thanks,
Shawn


---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@tomcat.apache.org
For additional commands, e-mail: users-***@tomcat.apache.org
Christopher Schultz
2018-10-18 15:02:06 UTC
Permalink
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Shawn,
Post by Shawn Heisey
Post by Jerry Malcolm
I have several webapps that do a significant amount of recursive
loads of snippits of HTML utilizing XHR/http/ajax requests. These
apps are all debugged and in production. The server has no
problem whatsoever in keeping up with the multiple concurrent
requests. However, the open-connection limits on the browsers
that block more than 6 concurrent connections to a server is
killing me in performance.
I know pretty much nothing about the things you asked about after
this paragraph. But I do know about one thing that might help you
-- HTTP/2. It can execute many HTTP requests simultaneously over a
single TCP connection.
+1

h2 will improve your performance with basically zero other changes to
your environment or to your application.
Post by Shawn Heisey
I really have no idea how to enable HTTP/2 in Tomcat, but I know
that it can be done if you have a new enough version.
It's configured by default in Tomcat 8.5.x and later. Basically, you
just have to add this inside your <Connector> element in
conf/server.xml if it isn't already there:

<UpgradeProtocol className="org.apache.coyote.http2.Http2Protocol" />
Post by Shawn Heisey
Another possibility is to put your web services behind a load
balancer that supports HTTP/2 on the front end. Haproxy is one
that I am aware of with that support.
Basically everyone[1] supports h2. Hmm... no Squid. :(

Jerry, switching to Websocket basically requires you to rewrite your
application using a different protocol. I don't think you really want
to do that.

- -chris

[1] https://en.wikipedia.org/wiki/HTTP/2#Server_software
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAlvIoG4ACgkQHPApP6U8
pFgq8g//bU2tji+UM7j68ZRQIUazDTVlaQePwNLw5JicBuF+kkadBiSsKjp9qytO
P18JiuBTHm6AJZ/PrCvPrG4ceJbT7QzdMD1daj6hD5MkdOyPSiK0QTuqV5r+V7Dm
cjWGZ2F8WRIKN8w9BX3XNPZ3aLyf4pAd68EGow9R4Cm9FoMJ17kT1a1ALs/Iw0pX
5Ditcsl1SbnSyk+CxwgehLRkc7mub0c7Wk7bI6uYCzZrZt2ddNTmNON2Eqgzd+UB
R+6NoOpIiQV/mvP8jFaqBy+OcVIzbuzM/otBzkmgbNDimTrLsT790vOcDLD3BxtB
sZCVk1aC+7wO1Elq+104l/E/bFCPn8bFDspZdMpvp/wxrt80Co36Nw/4Jkg7QoGn
h1l8JI8R/bt5/jOQhcqQH2/4peilP0Zs6ASTB+U0tV0M6J6n/qDLjqo68ueMzgmN
Bo4cYATzO92G55T0WuGlQOynlPhrVS2s4u2mTVuaeMc8m863VdMiGhQh2anEqpJN
MumeH4JKFSsj78lzjWOenjE9/N0Gm00eeO1O0hYsnIOEyftv7osaXxBO0gJoKFHV
ZF1SkX7ogHfutt8Yzga7I6VK8184rt7EYohl6zf7QU4mdQIkVKBHQrlKRxddqIoQ
HIDmUOUPMuiq6V0i0E4QDxpvnG+1Ax1DvRrj20BJ1DuwII0odZY=
=FDC4
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@tomcat.apache.org
For additional commands, e-mail: users-***@tomcat.apache.org

Loading...