Harri,
On 9/17/25 2:11 AM, Harri Pesonen wrote:
So the statement was actually true for Tomcat 9 (which we use) but
false for Tomcat 10, which loads tcnative-2 first.
I now run several benchmarks to find out if tcnative-1.dll or
tcnative-2.dll make a difference compared to each other and to
running without them. I noticed that when connector is configured to
use APR (org.apache.coyote.http11.Http11AprProtocol), then
tcnative-1 is required or Tomcat does not start.>
I think that it would be better to load the library that is used by
the connector instead of loading one of them depending on the Tomcat
version.
At the point where the library is loaded, the code doesn't know how it
will be used, so it can't make that decision. The AprLifecycleListener
is responsible for loading the tcnative library, and that stage of
startup occurs separately from initializing the connectors.
So this behavior isn't going to change.
The APR connector definitely requires support from the tcnative library
which was removed in tcnative 2.x. The primary distinguishing feature
between tcnative 1.x and 2.x is that the APR stuff was removed. The 2.x
version had everything removed except for support for OpenSSL as the
cryptographic engine for a JSSE provider (for NIO connectors).
Tomcat 10 has removed the APR connector so it shouldn't matter which
tcnative version you use. But Tomcat 9 + APR means you must use tcnative 1.
So if you plan to use APR, then you must not have tcnative-2 included.
No, you should be able to have both libraries on the disk. Tomcat 9
(where APR is present) will load tcnative 1.x first if it's present, and
everything will be fine. Tomcat 10 will load tcnative 2.x first, and
everything should be fine. If you try to use APR with Tomcat 10, Tomcat
will fail to initialize the connector because its GONE and not because
of a library problem.
Of course if Tomcat stops supporting APR, then this problem goes away.
That's what happened in Tomcat 10.
In those benchmarks, I noticed that when using NIO, then Tomcat was
slightly faster without using tcnative-1 or tcnative-2, and
tcnative-2 was a bit faster than -1. When using APR (and
tcnative-1), it was slightly faster than NIO without any native
library. This was with Java 11. JDK 24 with NIO (without native
library) was faster than Java 11 with APR (and tcnative-1).
So general finding was that perhaps Tomcat is better without using
any native libraries, but if using APR, then it tcnative-1 is
required.
All of the above is correct (which benchmarks being somewhat subjective).
NIO is far safer than NIO though the tcnative library is very reliable.
It does crash on occasion and your JVM goes down. But such crashes are
very rare. Note that NIO requires somewhat more CPU usage than APR. We
(the Tomcat team) have decided that, long term, we don't believe the APR
connector is worth supporting, so we removed it. The real win from
tcnative comes from OpenSSL when using TLS and not the IO model. So
tcnative continues to support OpenSSL as a cryptographic provider.
The recent work with Java's FFM moves the plumbing code from tcnative (C
code) into Java and is even /more/ safe. It's likely that the next move
we make is to retire tcnative entirely and give OpenSSL access through
FFM instead of tcnative.
-chris
-----Original Message-----
From: Michael Osipov <[email protected]>
Sent: tiistai 16. syyskuuta 2025 21.20
To: [email protected]
Subject: Re: Tomcat Native 1.3.1 vs 2.0.9
On 2025/09/16 09:09:45 Mark Thomas wrote:
On 16/09/2025 08:49, Michael Osipov wrote:
On 2025/09/12 14:46:44 Mark Thomas wrote:
On 12/09/2025 15:33, Harri Pesonen wrote:
Thanks, currently we have option to use APR but NIO is the default.
Perhaps we drop APR and then switch to Tomcat Native 2.
What if we have both tcnative-1.dll and tcnative-2.dll available,
I guess that Tomcat will use tcnative-2.dll with NIO and
tcnative-1.dll with APR ? 😊
You can only load one version of Tomcat Native into the JVM at any
one time. If both are present, 1.x is used in preference to 2.x.
Not true for 9.0.x
Which part (or parts) of the above statement are you claiming is (are)
not true?
This:
https://github.com/apache/tomcat/blob/ef14a983ab626d7ca777cc1a9e79fe96b9308cd4/java/org/apache/tomcat/jni/Library.java#L31
But from 10.x+:
https://github.com/apache/tomcat/blob/6dcdd3db93253c3599045e29b4491c4fe16c3a9e/java/org/apache/tomcat/jni/Library.java#L24
Preference depends on the version.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]