From e0755651800a9e7226f660b140d69d97749a0176 Mon Sep 17 00:00:00 2001 From: Jim Jagielski Date: Fri, 20 May 2011 16:29:48 +0000 Subject: [PATCH] Add in BalancerGrowth and its functionality... this lays the framework for adding additional Balancers: post-config by allowing for shm growth. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1125451 13f79535-47bb-0310-9956-ffa450edef68 --- docs/manual/mod/mod_proxy.xml | 54 +++++++++++++++++++----------- include/ap_mmn.h | 3 +- modules/proxy/mod_proxy.c | 23 +++++++++++++ modules/proxy/mod_proxy.h | 3 ++ modules/proxy/mod_proxy_balancer.c | 7 ++-- 5 files changed, 67 insertions(+), 23 deletions(-) diff --git a/docs/manual/mod/mod_proxy.xml b/docs/manual/mod/mod_proxy.xml index 815a246957..289355110a 100644 --- a/docs/manual/mod/mod_proxy.xml +++ b/docs/manual/mod/mod_proxy.xml @@ -637,30 +637,46 @@ expressions -BalancerMember -Add a member to a load balancing group -BalancerMember [balancerurl] url [key=value [key=value ...]] -directory - -BalancerMember is only available in Apache HTTP Server 2.2 +BalancerGrowth +Number of additional Balancers that can be added Post-configuration + BalancerGrowth # + BalancerGrowth 5 + server configvirtual host +BalancerGrowth is only available in Apache HTTP Server 2.3.13 and later. -

This directive adds a member to a load balancing group. It could be used - within a <Proxy balancer://...> container - directive, and can take any of the key value pair parameters available to - ProxyPass directives.

-

One additional parameter is available only to BalancerMember directives: - loadfactor. This is the member load factor - a number between 1 - (default) and 100, which defines the weighted load to be applied to the - member in question.

-

The balancerurl is only needed when not in <Proxy balancer://...> - container directive. It corresponds to the url of a balancer defined in - ProxyPass directive.

+

This directive allows for growth potential in the number of + Balancers available for a virtualhost in addition to the + number pre-configured. It only take effect if there is at + least 1 pre-configured Balancer.

+ + BalancerMember + Add a member to a load balancing group + BalancerMember [balancerurl] url [key=value [key=value ...]] + directory + + BalancerMember is only available in Apache HTTP Server 2.2 + and later. + +

This directive adds a member to a load balancing group. It could be used + within a <Proxy balancer://...> container + directive, and can take any of the key value pair parameters available to + ProxyPass directives.

+

One additional parameter is available only to BalancerMember directives: + loadfactor. This is the member load factor - a number between 1 + (default) and 100, which defines the weighted load to be applied to the + member in question.

+

The balancerurl is only needed when not in <Proxy balancer://...> + container directive. It corresponds to the url of a balancer defined in + ProxyPass directive.

+
+
+ ProxySet Set various Proxy balancer or member parameters diff --git a/include/ap_mmn.h b/include/ap_mmn.h index 83794beec2..394d65abf2 100644 --- a/include/ap_mmn.h +++ b/include/ap_mmn.h @@ -321,6 +321,7 @@ * change AP_DECLARE to AP_CORE_DECLARE: ap_register_log_hooks() * 20110329.2 (2.3.12-dev) Add child_status and end_generation hooks. * 20110329.3 (2.3.12-dev) Add format field to ap_errorlog_info. + * 20110329.4 (2.3.13-dev) bgrowth and max_balancers to proxy_server_conf. */ #define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */ @@ -328,7 +329,7 @@ #ifndef MODULE_MAGIC_NUMBER_MAJOR #define MODULE_MAGIC_NUMBER_MAJOR 20110329 #endif -#define MODULE_MAGIC_NUMBER_MINOR 3 /* 0...n */ +#define MODULE_MAGIC_NUMBER_MINOR 4 /* 0...n */ /** * Determine if the server's current MODULE_MAGIC_NUMBER is at least a diff --git a/modules/proxy/mod_proxy.c b/modules/proxy/mod_proxy.c index ce5a83a815..f387e467c4 100644 --- a/modules/proxy/mod_proxy.c +++ b/modules/proxy/mod_proxy.c @@ -1127,6 +1127,9 @@ static void * create_proxy_config(apr_pool_t *p, server_rec *s) ps->viaopt = via_off; /* initially backward compatible with 1.3.1 */ ps->viaopt_set = 0; /* 0 means default */ ps->req = 0; + ps->max_balancers = 0; + ps->bgrowth = 5; + ps->bgrowth_set = 0; ps->req_set = 0; ps->recv_buffer_size = 0; /* this default was left unset for some reason */ ps->recv_buffer_size_set = 0; @@ -1167,6 +1170,9 @@ static void * merge_proxy_config(apr_pool_t *p, void *basev, void *overridesv) ps->viaopt_set = overrides->viaopt_set || base->viaopt_set; ps->req = (overrides->req_set == 0) ? base->req : overrides->req; ps->req_set = overrides->req_set || base->req_set; + ps->bgrowth = (overrides->bgrowth_set == 0) ? base->bgrowth : overrides->bgrowth; + ps->bgrowth_set = overrides->bgrowth_set || base->bgrowth_set; + ps->max_balancers = overrides->max_balancers || base->max_balancers; ps->recv_buffer_size = (overrides->recv_buffer_size_set == 0) ? base->recv_buffer_size : overrides->recv_buffer_size; ps->recv_buffer_size_set = overrides->recv_buffer_size_set || base->recv_buffer_size_set; ps->io_buffer_size = (overrides->io_buffer_size_set == 0) ? base->io_buffer_size : overrides->io_buffer_size; @@ -1824,6 +1830,21 @@ static const char* return NULL; } +static const char *set_bgrowth(cmd_parms *parms, void *dummy, const char *arg) +{ + proxy_server_conf *psf = + ap_get_module_config(parms->server->module_config, &proxy_module); + + int growth = atoi(arg); + if (growth < 0 || growth > 1000) { + return "BalancerGrowth must be between 0 and 1000"; + } + psf->bgrowth = growth; + psf->bgrowth_set = 1; + + return NULL; +} + static const char *add_member(cmd_parms *cmd, void *dummy, const char *arg) { server_rec *s = cmd->server; @@ -2203,6 +2224,8 @@ static const command_rec proxy_cmds[] = "How to handle bad header line in response: IsError | Ignore | StartBody"), AP_INIT_RAW_ARGS("BalancerMember", add_member, NULL, RSRC_CONF|ACCESS_CONF, "A balancer name and scheme with list of params"), + AP_INIT_TAKE1("BalancerGrowth", set_bgrowth, NULL, RSRC_CONF, + "Number of additional Balancers that can be added post-config"), AP_INIT_TAKE1("ProxyStatus", set_status_opt, NULL, RSRC_CONF, "Configure Status: proxy status to one of: on | off | full"), AP_INIT_RAW_ARGS("ProxySet", set_proxy_param, NULL, RSRC_CONF|ACCESS_CONF, diff --git a/modules/proxy/mod_proxy.h b/modules/proxy/mod_proxy.h index 046f99f9ad..57e0c02009 100644 --- a/modules/proxy/mod_proxy.h +++ b/modules/proxy/mod_proxy.h @@ -138,6 +138,8 @@ typedef struct { const char *id; apr_pool_t *pool; /* Pool used for allocating this struct */ int req; /* true if proxy requests are enabled */ + int max_balancers; /* maximum number of allowed balancers */ + int bgrowth; /* number of post-config balancers can added */ enum { via_off, via_on, @@ -172,6 +174,7 @@ typedef struct { unsigned int badopt_set:1; unsigned int proxy_status_set:1; unsigned int source_address_set:1; + unsigned int bgrowth_set:1; } proxy_server_conf; diff --git a/modules/proxy/mod_proxy_balancer.c b/modules/proxy/mod_proxy_balancer.c index 63efb618af..8123cfaafb 100644 --- a/modules/proxy/mod_proxy_balancer.c +++ b/modules/proxy/mod_proxy_balancer.c @@ -723,13 +723,14 @@ static int balancer_post_config(apr_pool_t *pconf, apr_pool_t *plog, conf = (proxy_server_conf *)ap_get_module_config(sconf, &proxy_module); if (conf->balancers->nelts) { - ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, "Doing balancers create: %d, %d", + conf->max_balancers = conf->balancers->nelts + conf->bgrowth; + ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, "Doing balancers create: %d, %d (%d)", (int)ALIGNED_PROXY_BALANCER_SHARED_SIZE, - (int)conf->balancers->nelts); + (int)conf->balancers->nelts, conf->max_balancers); rv = storage->create(&new, conf->id, ALIGNED_PROXY_BALANCER_SHARED_SIZE, - conf->balancers->nelts, AP_SLOTMEM_TYPE_PREGRAB, pconf); + conf->max_balancers, AP_SLOTMEM_TYPE_PREGRAB, pconf); if (rv != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s, "balancer slotmem_create failed"); return !OK; -- 2.40.0