0

We have an apache server 2.4.X which we are using as a reverse proxy in front of one Java Application . We have enabled Apache status module Apache Status and we are able to see that number of idle worker threads will always be zero , Hence performance of our application is poor . Our hosting server have 32 cores and 64 GB of RAM . We are using mpm_worker module of Apache . Apache mpm_worker .Our Current mpm_worker configuration is :

 <IfModule mpm_worker_module> ServerLimit 150 StartServers 8 MinSpareThreads 25 MaxSpareThreads 75 ThreadsPerChild 25 MaxRequestWorkers 150 MaxConnectionsPerChild 10000 </IfModule> 

.We went through Apache performance tuning article and found that we can have 2930 request workers as per our server configuration .My questions are .

  1. Changing MaxRequestWorkers alone to 2930 will work ?

  2. Do we need to change ThreadsPerChild also ?

  3. StartServers which represents Apache child processes also needs to be changed /Or can we change this also for optimum performance based on our server configuration.

  4. What should be ServerLimit value for updated MaxRequestWorkers case which will be 2930 ?

2
  • Why would you expect to have any worker threads on a reverse proxy? Why use apache for this, and not nginx? Commented Jul 10, 2020 at 8:49
  • 1
    @TomTom Yes that is correct but as we are working in a bank so new package approval is little bit hard to get Commented Jul 10, 2020 at 9:11

1 Answer 1

1

To be able to create a suiting profile for your Server you need to understand what each Configuration of this Directive means:

  • ServerLimit
    The maximum Number of Processes that the Server will create
  • StartServers
    The Number of Processes that the Server will create on Start-Up
  • ThreadsPerChild
    The Number of Threads that each Process will create
  • MinSpareThreads
    The Minimum Number of Threads that must exist. (Mostly at Start-Up)
  • MaxSpareThreads
    The Maximum Number of Threads that the Server will keep running.
  • MaxRequestWorkers
    Maximum number of connections that the Server will accept simultaneously.
  • MaxConnectionsPerChild
    The Maximum Number of Connections that each Process will accept. This determines the Time of Life of a Child Process.

Having said this. How many Child Processes are running usually?
Did you already reach the ServerLimit of Child Processes?

You should also look at the MaxClients Setting that it will admit all the Request that are coming in.

If no Worker Threads are available increase the number of MaxSpareThreads

Launching new Child Processes will consume CPU Cycles so on a busy Site the MaxSpareThreads limit should be big.

But disposing old Processes will also free your System Memory, so you should limit the Time of Life of the Processes with MaxConnectionsPerChild.

On the other Hand Application Run Time keeps your Threads busy. Being faster with your Java Application will free Threads and Memory.

As an Example: Receiving 50 requests / second and each Request takes 4 seconds to complete. you would need 200 Threads to cover this Demand.
If each Request took only 2 seconds you could cover it with only 100 Threads.

10
  • 1
    if you reached MaxRequestWorkers you would be unable to connect to the Site and receive a "Connection refused" Response. Commented Jul 10, 2020 at 9:58
  • 1
    Indicating that your CPU usage is low indicates that the Proxy is not working but rather waiting for the Tomcat Response. Enable in the Logs the %D Stats to track the Processing Time of your Java Application. Please refer to this documentation httpd.apache.org/docs/current/mod/mod_log_config.html Commented Jul 10, 2020 at 10:04
  • 1
    @Deepak How many Request / Second do you receive? and how long is the Processing Time for each Request? Commented Jul 10, 2020 at 10:14
  • 1
    @Deepak 1) Your incoming traffic is far bigger than 150 Requests / Second. 2) from the Hardware profile I conclude that your Proxy Server is mostly empty with low workload. But it can do much more. -> Permit as much ThreadsPerChild as you have CPU cores ThreadsPerChild 32. As a Proxy Server I suppose your Child Process Size is small thus you can set a high limit on ServerLimit. So you can set easily ServerLimit 1000 and MaxRequestWorkers 1000. That way you will be able to see the real usage and traffic volume and do fine adjustments later. Commented Jul 10, 2020 at 13:27
  • 1
    Having at your Disposition such a Monster of Server with 65536 MB RAM and asuming a Process Size of 20 MB per Apache Process you Server can easily serve more than 2000 Apache Processes at a time: $ echo "scale=3; 64 * 1024 /20 *.9"|bc -l 2949.120. So, 1000 Processes is a safe value. But still you don't know how many Request per Second actually come in. On this Number depends the StartServer which is the Number of Processes at Server Start Up Commented Jul 10, 2020 at 21:20

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.