Commit 3f6e54fa authored by Stefan Fritsch's avatar Stefan Fritsch
Browse files

Some improvements for handling of many connections for MPM event:

- Process lingering close asynchronously instead of tying up worker threads
  (based on patch by Jeff Trawick).

- If the number of connections of a process is above

     threads_per_child  +  WORKER_OVERCOMMIT * (idle_workers - 1)

  (WORKER_OVERCOMMIT is fixed at 2, at the moment), or if all workers are busy,
  don't accept new connections in that process. Such a dynamic connection limit
  is necessary because we may have both async and non-async (ssl) connections.
  WORKER_OVERCOMMIT should be a config option.

- Don't count idle workers of not-accepting processes against MinSpareThreads,
  so that the parent will spawn new processes when necessary.

- If we receive a keep-alive request while all workers are busy, don't block
  but close the connection immediately so that the client will re-connect to a
  different process.

Related changes:

- Log what is going on at trace loglevels.
- Remove the bypass_push poll type flag, this code cannot be hit anymore
  (if it ever could?).
- Add some macro helpers for dealing with timeout queues.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1137358 13f79535-47bb-0310-9956-ffa450edef68
parent c962c793
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -2,6 +2,13 @@

Changes with Apache 2.3.13

  *) mpm_event: If the number of connections of a process is very high, or if
     all workers are busy, don't accept new connections in that process.
     [Stefan Fritsch]

  *) mpm_event: Process lingering close asynchronously instead of tying up
     worker threads. [Jeff Trawick, Stefan Fritsch]

  *) mpm_event: If MaxMemFree is set, limit the number of pools that is kept
     around. [Stefan Fritsch]

+5 −2
Original line number Diff line number Diff line
@@ -333,14 +333,17 @@
 *                         Add ap_context_*(), ap_set_context_info(), ap_set_document_root()
 * 20110605.1 (2.3.13-dev) add ap_(get|set)_core_module_config()
 * 20110605.2 (2.3.13-dev) add ap_get_conn_socket()
 * 20110619.0 (2.3.13-dev) add async connection infos to process_score in scoreboard,
 *                         add ap_start_lingering_close(),
 *                         add conn_state_e:CONN_STATE_LINGER_NORMAL and CONN_STATE_LINGER_SHORT
 */

#define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */

#ifndef MODULE_MAGIC_NUMBER_MAJOR
#define MODULE_MAGIC_NUMBER_MAJOR 20110605
#define MODULE_MAGIC_NUMBER_MAJOR 20110619
#endif
#define MODULE_MAGIC_NUMBER_MINOR 2                    /* 0...n */
#define MODULE_MAGIC_NUMBER_MINOR 0                    /* 0...n */

/**
 * Determine if the server's current MODULE_MAGIC_NUMBER is at least a
+3 −1
Original line number Diff line number Diff line
@@ -70,6 +70,8 @@ AP_CORE_DECLARE(void) ap_flush_conn(conn_rec *c);
 */
AP_DECLARE(void) ap_lingering_close(conn_rec *c);

AP_DECLARE(int) ap_start_lingering_close(conn_rec *c);

/* Hooks */
/**
 * create_connection is a RUN_FIRST hook which allows modules to create 
+3 −1
Original line number Diff line number Diff line
@@ -1133,7 +1133,9 @@ typedef enum {
    CONN_STATE_HANDLER,
    CONN_STATE_WRITE_COMPLETION,
    CONN_STATE_SUSPENDED,
    CONN_STATE_LINGER
    CONN_STATE_LINGER,
    CONN_STATE_LINGER_NORMAL,
    CONN_STATE_LINGER_SHORT
} conn_state_e;

/** 
+9 −1
Original line number Diff line number Diff line
@@ -132,9 +132,17 @@ typedef struct process_score process_score;
struct process_score {
    pid_t pid;
    ap_generation_t generation;	/* generation of this child */
    int quiescing;          /* the process whose pid is stored above is
    char quiescing;         /* the process whose pid is stored above is
                             * going down gracefully
                             */
    char not_accepting;     /* the process is busy and is not accepting more
                             * connections (for async MPMs)
                             */
    apr_uint32_t connections;       /* total connections (for async MPMs) */
    apr_uint32_t write_completion;  /* async connections doing write completion */
    apr_uint32_t lingering_close;   /* async connections in lingering close */
    apr_uint32_t keep_alive;        /* async connections in keep alive */
    apr_uint32_t suspended;         /* connections suspended by some module */
};

/* Scoreboard is now in 'local' memory, since it isn't updated once created,
Loading