Bug 55615 - Connections are starved and not balanced when concurrent requests exceed FcgidMaxProcessesPerClass
Summary: Connections are starved and not balanced when concurrent requests exceed Fcgi...
Status: NEW
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mod_fcgid (show other bugs)
Version: 2.4.6
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-09-30 23:09 UTC by Scott
Modified: 2014-12-26 20:41 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Scott 2013-09-30 23:09:23 UTC
When a large number of concurrent requests are made to a FastCGI process which exceeds the number defined in FcgidMaxProcessesPerClass, connections become starved.

From reviewing the source code, In fcgid_spawn_ctl.c when this condition happens, the following piece of code is executed.

/*
 * Process count of this class higher than up limit?
 */
if (current_node->process_counter >= current_node->max_class_process_count) {
    ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, main_server,
                 "mod_fcgid: too many %s processes (current:%d, max:%d), skip the spawn request",
                  command->cgipath, current_node->process_counter,
                  current_node->max_class_process_count);
     return 0;
}

For example, if I have a FastCGI application which returns a 1MB buffer called buffer.exe.  I have configured FcgidMaxProcessesPerClass to 4, and now I launch 64 concurrent requests to buffer.exe which are looping.  The result is that some threads obtain the the buffer while others are simply staved.

The expected result is that I would want these 64 concurrent requests to equally be slow at obtaining the result rather then a few connections getting the result while others are staved.
Comment 1 Scott 2013-09-30 23:28:12 UTC
To produce the buffer.exe application, I'm compiling using libfcgi located here:
http://www.fastcgi.com/dist/fcgi-2.4.1-SNAP-0910052249.tar.gz

Here's an example of what buffer.exe would look like.

#include "fcgi_stdio.h"
#include <stdlib.h>

void main(void)
{
  FCGI_init();

/* Response loop. */
  while (FCGI_Accept() >= 0)   {
    char         *buf = NULL;
    unsigned int  bufsz = 1024*1024;

    printf("Content-type: text/html\r\n\r\n"
    buf = malloc(bufsz);
    FCGI_fwrite(buf, bufsz, 1, stdout);   
    free(buf);
  }
}
Comment 2 Scott 2013-10-01 13:48:40 UTC
In addition, I am running Apache on the Windows platform.  The build is Windows 32-bit compiled under Visual Studio 2010.  Apache 2.4.6.