Re: Long lasting websocket sessions

2024-02-16 Thread Alex O'Ree
No devices in-between, browser to local host. Good feedback though, I'll
try to reproduce with the snake app
Thanks!

On Fri, Feb 16, 2024, 2:47 PM Chuck Caldarale  wrote:

>
> > On Feb 16, 2024, at 11:31, Mark Thomas  wrote:
> >
> > On 09/02/2024 13:47, Alex O'Ree wrote:
> >> I've been experimenting with tomcat 9.x in seeing how long i can get a
> web
> >> socket session to last. I'm currently struggling to get past 30 minutes
> or
> >> so. Looking for guidance on how to best increase this or if this is a
> bad
> >> idea.
> >> Here's the current configuration and what i've tried thus far:
> >> The server continuously streams messages the client, about 1 per second
> >> The client periodically (every 30 seconds) sends a keep alive text
> message
> >> back to the server
> >> The server side endpoint sets the Session.setTimeout(0); according to
> the
> >> docs, this should prevent timeouts
> >> The server side WAR file/WEB-INF/web.xml had a session timeout defined
> at
> >> 15 minutes but i then removed it in order to increase the websocket
> >> duration.
> >> Despite all this, both the client and server log a session disconnect,
> but
> >> i'm still not sure what the reasoning is. I'm still assuming it's some
> kind
> >> of timeout mechanism.
> >
> > I think you need to do a little more investigation with your
> application. I've been running the snake WebSocket example on 9.0.x for
> over any hour wihtout any issues.
>
>
> Are there any boxes (eg, load balancer, firewall) between the client and
> server that might be forcibly dropping TCP connections after 30 minutes?
>
>   - Chuck
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>


Re: Long lasting websocket sessions

2024-02-16 Thread Chuck Caldarale


> On Feb 16, 2024, at 11:31, Mark Thomas  wrote:
> 
> On 09/02/2024 13:47, Alex O'Ree wrote:
>> I've been experimenting with tomcat 9.x in seeing how long i can get a web
>> socket session to last. I'm currently struggling to get past 30 minutes or
>> so. Looking for guidance on how to best increase this or if this is a bad
>> idea.
>> Here's the current configuration and what i've tried thus far:
>> The server continuously streams messages the client, about 1 per second
>> The client periodically (every 30 seconds) sends a keep alive text message
>> back to the server
>> The server side endpoint sets the Session.setTimeout(0); according to the
>> docs, this should prevent timeouts
>> The server side WAR file/WEB-INF/web.xml had a session timeout defined at
>> 15 minutes but i then removed it in order to increase the websocket
>> duration.
>> Despite all this, both the client and server log a session disconnect, but
>> i'm still not sure what the reasoning is. I'm still assuming it's some kind
>> of timeout mechanism.
> 
> I think you need to do a little more investigation with your application. 
> I've been running the snake WebSocket example on 9.0.x for over any hour 
> wihtout any issues.


Are there any boxes (eg, load balancer, firewall) between the client and server 
that might be forcibly dropping TCP connections after 30 minutes?

  - Chuck


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



Re: Long lasting websocket sessions

2024-02-16 Thread Mark Thomas

On 09/02/2024 13:47, Alex O'Ree wrote:

I've been experimenting with tomcat 9.x in seeing how long i can get a web
socket session to last. I'm currently struggling to get past 30 minutes or
so. Looking for guidance on how to best increase this or if this is a bad
idea.

Here's the current configuration and what i've tried thus far:

The server continuously streams messages the client, about 1 per second
The client periodically (every 30 seconds) sends a keep alive text message
back to the server
The server side endpoint sets the Session.setTimeout(0); according to the
docs, this should prevent timeouts
The server side WAR file/WEB-INF/web.xml had a session timeout defined at
15 minutes but i then removed it in order to increase the websocket
duration.

Despite all this, both the client and server log a session disconnect, but
i'm still not sure what the reasoning is. I'm still assuming it's some kind
of timeout mechanism.


I think you need to do a little more investigation with your 
application. I've been running the snake WebSocket example on 9.0.x for 
over any hour wihtout any issues.


Mark

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



Re: ConnectionPool JDBC vs. DBCP

2024-02-16 Thread Christopher Schultz

Andreas,

On 2/16/24 02:21, Döscher, Andreas (ESI) wrote:

Moin,
in the docpage https://tomcat.apache.org/tomcat-10.1-doc/jdbc-pool.html it says


The JDBC Connection Pool org.apache.tomcat.jdbc.pool is a replacement or an 
alternative to the Apache Commons DBCP connection pool.

So why do we need a new connection pool?

Here are a few of the reasons:

Commons DBCP 1.x is single threaded. In order to be thread safe Commons 
locks the entire pool for short periods during both object allocation and 
object return. Note that this does not apply to Commons DBCP 2.x.

[...snip...]

I thought that Tomcat uses DBCP 2.x per default, is this document still 
relevant or is it outdated?


Recent versions of Tomcat do indeed use DBCP2.

You are reading the documentation for the pool itself, which is 
justifying the reason it was developed in the first place, back when 
Tomcat shipped with DBCP1. DBCP2 was created for many of the same 
reasons tomcat-pool was created, just on different schedules.


This document could be updated to make it clear that the comparison of 
tomcat-pool against DBCP1 is a historical comparison, and that Tomcat 
now uses DBCP2 by default which does not suffer from the same problems 
tomcat-pool was designed to address.


There are some significant architectural and feature differences between 
DBCP2 and tomcat-pool which is why we haven't shut the sub-project down.


-chris

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



Re: Tomcat/Java starts using too much memory and not by the heap or non-heap memory

2024-02-16 Thread Christopher Schultz

Chuck and Brian,

On 2/15/24 10:53, Chuck Caldarale wrote:



On Feb 15, 2024, at 09:04, Brian Braun  wrote:

I discovered the JCMD command to perform the native memory tracking. When
running it, after 3-4 days since I started Tomcat, I found out that the
compiler was using hundreds of MB and that is exactly why the Tomcat
process starts abusing the memory! This is what I saw when executing "sudo jcmd 
 VM.native_memory scale=MB":

Compiler (reserved=3D340MB, commited=3D340MB)
(arena=3D340MB #10)

Then I discovered the Jemalloc tool (http://jemalloc.net 
) and its jeprof
tool, so I started launching Tomcat using it. Then, after 3-4 days after
Tomcat starts I was able to create some GIF images from the dumps that
Jemalloc creates. The GIF files show the problem: 75-90% of the memory is
being used by some weird activity in the compiler! It seems that something
called "The C2 compile/JIT compiler" starts doing something after 3-4 days,
and that creates the leak. Why after 3-4 days and not sooner? I don't know.



There have been numerous bugs filed with OpenJDK for C2 memory leaks over the 
past few years, mostly related to recompiling certain methods. The C2 compiler 
kicks in when fully optimizing methods, and it may recompile methods after 
internal instrumentation shows that additional performance can be obtained by 
doing so.



I am attaching the GIF in this email.



Attachments are stripped on this mailing list.


:(

I'd love to see these.


Does anybody know how to deal with this?



You could disable the C2 compiler temporarily, and just let C1 handle your 
code. Performance will be somewhat degraded, but may well still be acceptable. 
Add the following to the JVM options when you launch Tomcat:

-XX:TieredStopAtLevel=1



By the way, I'm running my website using Tomcat 9.0.58, Java
"11.0.21+9-post-Ubuntu-0ubuntu122.04", Ubuntu 22.04.03. And I am developing
using Eclipse and compiling my WAR file with a "Compiler compliance
level:11".



You could try a more recent JVM version; JDK 11 was first released over 5 years 
ago, although it is still being maintained.


There is an 11.0.22 -- just a patch-release away from what you appear to 
have. I'm not sure if it's offered through your package-manager, but you 
could give it a try directly from e.g. Eclipse Adoptium / Temurin.


Honestly, if your code runs on Java 11, it's very likely that it will 
run just fine on Java 17 or Java 21. Debian has packages for Java 17 for 
sure, so I suspect Ubuntu will have them available as well.


Debian-based distros will allow you to install and run multiple 
JDKs/JREs in parallel, so you can install Java 17 (or 21) without 
cutting-off access to Java 11 if you still want it.


-chris

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