Tuesday, February 21, 2017

How To Increase Tomcat Performance Using Tomcat Native Library ?

The Apache Tomcat Native Library is an optional component for use with Apache Tomcat that allows Tomcat to use certain native resources for performance, compatibility, etc.


Specifically, the Apache Tomcat Native Library gives Tomcat access to the Apache Portable Runtime (APR) library's network connection (socket) implementation and random-number generator.


Summary

=============

1) Download Softwares APR library, OpenSSL libraries & Tomcat Native Library
2) Install APR library
3) Install OpenSSL libraries 
4) Install Tomcat Native Library
5) Add the Libraries Path to tomcat CLASSPATH
6) Restart Tomcat Server & Validate Libraries Loaded or Not at Run time.

Steps:
=====

1) Download Softwares APR library, OpenSSL libraries & Tomcat Native Library

Use Below links for downloading software's




Copy all setup files to remote machine using WinSCP



2) Install APR library

Extract the file apr-1.5.2.tar.gz using below command.

tar -zxvf apr-1.5.2.tar.gz


Use below commands for installation

cd /home/tomcat/native/apr-1.5.2

./configure --prefix=/home/tomcat/native/apr

make

make install

Note down the apr-1-config location, which will be used in next steps

/home/tomcat/native/apr/bin/apr-1-config 


3) Install OpenSSL libraries 


Extract the file openssl-1.0.2j.tar.gz using below command.

tar -zxvf openssl-1.0.2j.tar.gz

Use below commands for installation

cd /home/tomcat/native/openssl-1.0.2j

./config --prefix=/home/tomcat/native/openssl -fPIC

make

make install

Note: For older versions after configure another additional step needed ie. "make depend"


4) Install Tomcat Native Library

Extract the file tomcat-native-1.2.10-src.tar.gz using below command.

 tar -zxvf tomcat-native-1.2.10-src.tar.gz

Use below commands for installation

cd /home/tomcat/native/tomcat-native-1.2.10-src/native


./configure --with-apr=/home/tomcat/native/apr/bin/apr-1-config  --with-java-home=/home/tomcat/java/jdk1.8.0_112 --with-ssl=/home/tomcat/native/openssl --prefix=/home/tomcat/instance1/apache-tomcat-8.5.9


make

make install

Output
=============

--------------------------------------------------------------------
Libraries have been installed in:
   /home/tomcat/instance1/apache-tomcat-8.5.9/lib

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
--------------------------------------------------------------------

5) Add the Libraries Path to tomcat CLASSPATH

Append below line in JAVA_OPTION of setenv.sh file

cd /home/tomcat/instance1/apache-tomcat-8.5.9/bin

vi setenv.sh

-Djava.library.path=/home/tomcat/instance1/apache-tomcat-8.5.9/lib 



6) Restart Tomcat Server & Validate Libraries Loaded or Not at Run time.

cd /home/tomcat/instance1/apache-tomcat-8.5.9/bin

./shutdown.sh

./startup.sh

Now check logs:

cd /home/tomcat/instance1/apache-tomcat-8.5.9/logs

vi catalina.out

22-Dec-2016 20:28:27.801 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded APR based Apache Tomcat Native library 1.2.10 using APR version 1.5.2.

No comments:

Post a Comment