I have a linux server (CentOS 7.4.1708) with Apache (Version 2.4.6) and Tomcat (Version 8.0.28) installed.
My clients connects to the HTML static content on Apache with port 443 (https).
They then call the WebRequest to tomcat with a proxypass rule using the AJP connector (protocol: AJP/1.3).
ProxyPass /MyJavaWebApp/ ajp://localhost:8009/MyJavaWebApp/
Everything works as expected but I experience performance issue when clients download files via a Download servlet in MyJavaWebApp.
// the core code of the servlet is the following
// I use org.apache.commons.io.IOUtils to copy the streams
IOUtils.copy(new FileInputStream(file), response.getOutputStream());
I need to use a servlet as the download access is secure and permission check must be done.
When they download a file, I can see an httpd process using nearly 100% of one core on my linux server. Then, if all cores are used by download request the server becomes really slow, obviously.
If the client download straight from tomcat bypassing Apache it's all good.
That makes me think that the problem comes from the ProxyPass rules.
Is there a way to optimise ProxyPass rule for the download servlet?
If not, what kid of alternative should I use?
Thanks for you help.