Skip to content

Use Tomcat APR connector for performance improvements #7376

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

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
Labels
type: documentation A documentation update

Comments

@PeterJerald
Copy link

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.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 13, 2016
@snicoll snicoll added type: documentation A documentation update status: ideal-for-contribution An issue that a contributor can help us with and removed status: waiting-for-triage An issue we've not yet triaged labels Nov 13, 2016
@philwebb
Copy link
Member

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

@PeterJerald
Copy link
Author

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

@bclozel bclozel self-assigned this Nov 24, 2016
@bclozel
Copy link
Member

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
Copy link
Author

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
Copy link
Contributor

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

@iNikem
Copy link

iNikem commented Mar 8, 2017

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

@PeterJerald
Copy link
Author

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

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

@PeterJerald
Copy link
Author

PeterJerald commented Jul 29, 2017

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

@candrews
Copy link
Contributor

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
Copy link
Member

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 as completed Sep 4, 2017
@FreezeSoul
Copy link

nice

@snicoll snicoll removed the status: ideal-for-contribution An issue that a contributor can help us with label Jan 29, 2018
@dbreaker36
Copy link

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
Labels
type: documentation A documentation update
Projects
None yet
Development

No branches or pull requests

10 participants