Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Tomcat APR connector for performance improvements #7376

Closed
PeterJerald opened this issue Nov 13, 2016 · 12 comments
Closed

Use Tomcat APR connector for performance improvements #7376

PeterJerald opened this issue Nov 13, 2016 · 12 comments
Assignees

Comments

@PeterJerald
Copy link

@PeterJerald PeterJerald commented Nov 13, 2016

In apache tomcat uses apache portable runtime(APR) to provide better performance and scalability with native execution. APR uses system resources and execute natively. If we compare the execution performance BIO , NIO and APR connectors APR provides superior performance.

I have experience the same in my development phase. I created two sets of artifacts which is standalone Jar with spring boot embedded tomcat and spring boot war file and deployed on "tomcat" both are same code base but APR configuration is only difference.

Spring boot by default all the threads execution based on “NIO”, so I have compiled APR libraries based on below link:-

https://tomcat.apache.org/tomcat-8.0-doc/apr.html

Executed Spring Boot Jar file with APR. Now I can see performance results are exactly same.

In our spring boot documentation does not have APR guide to add in embedded tomcat. If we add it will help other developers as well.

@philwebb

This comment has been minimized.

Copy link
Member

@philwebb philwebb commented Nov 14, 2016

I think @bclozel may have been looking into this a little. It would be nice if we could somehow make this easier.

@PeterJerald

This comment has been minimized.

Copy link
Author

@PeterJerald PeterJerald commented Nov 24, 2016

@philwebb Do you required any information from my side to continue further ?

@bclozel bclozel self-assigned this Nov 24, 2016
@bclozel

This comment has been minimized.

Copy link
Member

@bclozel bclozel commented Nov 24, 2016

This is also related to using native libs for TLS support, which is very handy for http/2 support.

Quick questions @PeterJerald:

  • how would you expect to enable those native bindings?
  • how are you adding those libraries to your JVM library path? Are you adding those in a well-known location in your operating system? Or are you using a JVM argument such as -Djava.library.path=/usr/local/lib/?
  • Are you using the native OpenSSL integration as well?
@PeterJerald

This comment has been minimized.

Copy link
Author

@PeterJerald PeterJerald commented Nov 26, 2016

@bclozel Please find below for my answers

How would you expect to enable those native bindings?

If we enable under application common location that help us.

How are you adding those libraries to your JVM library path? Are you adding those in a well-known location in your operating system? Or are you using a JVM argument such as -Djava.library.path=/usr/local/lib/?

Currently I kept along with application and I have added -Djava.library.path path variable in JVM. If we kept under OS also fine.

Are you using the native OpenSSL integration as well?

Yes. By default tomcat native lib(8 +) requires; OpenSSL 0.9.7+, so i have installed in OS

@OrangeDog

This comment has been minimized.

Copy link

@OrangeDog OrangeDog commented Jan 30, 2017

I guess it should work similarly to how netty-transport-native-epoll is detected.

@iNikem

This comment has been minimized.

Copy link

@iNikem iNikem commented Mar 8, 2017

@PeterJerald are there some benchmark results comparing NIO and APR based applications?

@PeterJerald

This comment has been minimized.

Copy link
Author

@PeterJerald PeterJerald commented Jul 29, 2017

https://gist.github.com/andreldm/7f89a3279438467a0bd41e6c1249d014

Please refer above sample program to enable APR in spring boot.

@PeterJerald

This comment has been minimized.

Copy link
Author

@PeterJerald PeterJerald commented Jul 29, 2017

@iNikem we tested with business logic code and compared the results. let me try with sample code

@candrews

This comment has been minimized.

Copy link
Contributor

@candrews candrews commented Aug 7, 2017

It doesn't look like using the APR connector is a good idea because:

However, enabling the use of tomcat-native/APR so the OpenSSL implementation is available to the non-APR connectors is a good idea (see the benchmarks in the aforementioned pdf). Notably, enabling APR also allows for the use of http/2.

candrews added a commit to candrews/spring-boot that referenced this issue Aug 7, 2017
Adds AprLifecycleListener to the Tomcat listeners.

Fixes spring-projects#7376
candrews added a commit to candrews/spring-boot that referenced this issue Aug 25, 2017
@bclozel bclozel changed the title Spring boot Embedded tomcat Performance Improvements Use Tomcat APR connector for performance improvements Sep 4, 2017
@bclozel

This comment has been minimized.

Copy link
Member

@bclozel bclozel commented Sep 4, 2017

Closing this issue, see #10079 (comment).

We will consider tomcat-native for the TLS use case in #10043.

@bclozel bclozel closed this Sep 4, 2017
@FreezeSoul

This comment has been minimized.

Copy link

@FreezeSoul FreezeSoul commented Jan 6, 2018

nice

@dbreaker36

This comment has been minimized.

Copy link

@dbreaker36 dbreaker36 commented Sep 11, 2019

https://gist.github.com/andreldm/7f89a3279438467a0bd41e6c1249d014 - This link seems to be broken. Are there other examples for enabling APR in spring boot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
10 participants
You can’t perform that action at this time.