0

We have a web application with a java backend and a tomcat frontend server. Before the tomcat there is an Apache. Both of them are on one host. The backend is on another host. Web browsers communicate with Apache/Tomcat using Rest calls. The client application uses a lot of parallel api calls.

While we do a performance test on the Apache using high parallel tcp connection number (~300) browsers can not/very slowly load the client js application.

We tried a lot of prefork/workers/maxclients settings. None of them helped.

After we temporary had replaced the Apache with Nginx this problem was instantly solved. Nginx seems to be an OK alternative but Apache would be better in this environment. Does anybody have any idea what makes the difference?

CPU/Memory/Network can't be the bottleneck.

It's interesting that jmeter gives this response for a lot of requests: Non HTTP response code: java.net.SocketTimeoutException Non HTTP response code: javax.net.ssl.SSLHandshakeException. Of course there are many 200 for this type of requests.

Thanks.

  • Did you try mpm_event? That is the only way Apache can even hope to approach nginx's performance. – Michael Hampton Aug 17 '18 at 22:32
  • Yes, that was the last thing we tried but it didn't help. – Richard Baka Aug 17 '18 at 23:48
  • Please provide a lot more information about each of these components. Operating system, web server, and JVM versions of everything. Host size: CPU, memory. Which VM hypervisor if any. Web server performance configuration, like which MPM for Apache and how it was configured. Profiling data like Linux perf record, and possibly flame graphs based on that. – John Mahowald Aug 18 '18 at 11:09
  • Hi, I will collect it but these things were checked and no problems were found. – Richard Baka Aug 18 '18 at 11:57
  • It's interesting that jmeter gives this response for a lot of requests: Non HTTP response code: java.net.SocketTimeoutException Non HTTP response code: javax.net.ssl.SSLHandshakeException but not for all of course. – Richard Baka Aug 18 '18 at 12:18

1 Answers1

2

It's because of architecture differences. Nginx is lightweight asynchronous(non-blocking) proxy. Apache is full-featured web server.

While apache needs to check and read additional files (.htaccess) on each request, execute all filters and handlers (rewrite, etc), nginx just transfers bytes between client and server (optionally modifying headers)

WhiteWind
  • 251
  • 1
  • 3
  • nginx is also a full-featured web server. Not just a lightweight asynchronous proxy. – Michael Hampton Aug 18 '18 at 13:05
  • 1
    It depends on what do you mean by "full-featured". E.g. nginx can not read .htaccess files to override directory options. It does not execute any code (php, ruby, python) by it's own - it delegates execution to separate processes – WhiteWind Aug 21 '18 at 03:19
  • 2
    The latter, at least, is not something a web server should be doing anyway. That Apache provides a way to do it has been a major source of grief for many years. And there is a lot less need for something like .htaccess these days. – Michael Hampton Aug 21 '18 at 12:26