You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2010/02/11 20:04:31 UTC

svn commit: r909108 - in /incubator/trafficserver/traffic/trunk/proxy: http2/HttpConfig.cc http2/HttpConfig.h http2/HttpSM.cc http2/HttpSessionManager.cc mgmt2/RecordsConfig.cc

Author: zwoop
Date: Thu Feb 11 19:04:29 2010
New Revision: 909108

URL: http://svn.apache.org/viewvc?rev=909108&view=rev
Log:
TS-116: TS should have the ability to keep a minimum number of connections active for all keep alive cases

	Author: Sean Cosgrave
	Review: Leif

Modified:
    incubator/trafficserver/traffic/trunk/proxy/http2/HttpConfig.cc
    incubator/trafficserver/traffic/trunk/proxy/http2/HttpConfig.h
    incubator/trafficserver/traffic/trunk/proxy/http2/HttpSM.cc
    incubator/trafficserver/traffic/trunk/proxy/http2/HttpSessionManager.cc
    incubator/trafficserver/traffic/trunk/proxy/mgmt2/RecordsConfig.cc

Modified: incubator/trafficserver/traffic/trunk/proxy/http2/HttpConfig.cc
URL: http://svn.apache.org/viewvc/incubator/trafficserver/traffic/trunk/proxy/http2/HttpConfig.cc?rev=909108&r1=909107&r2=909108&view=diff
==============================================================================
--- incubator/trafficserver/traffic/trunk/proxy/http2/HttpConfig.cc (original)
+++ incubator/trafficserver/traffic/trunk/proxy/http2/HttpConfig.cc Thu Feb 11 19:04:29 2010
@@ -1016,6 +1016,8 @@
 
   HttpEstablishStaticConfigLongLong(c.origin_max_connections, "proxy.config.http.origin_max_connections");
 
+  HttpEstablishStaticConfigLongLong(c.origin_min_keep_alive_connections, "proxy.config.http.origin_min_keep_alive_connections");
+
   HttpEstablishStaticConfigLongLong(c.parent_proxy_routing_enable, "proxy.config.http.parent_proxy_routing_enable");
 
   // Wank me.
@@ -1370,6 +1372,14 @@
 
   params->origin_max_connections = m_master.origin_max_connections;
 
+  params->origin_min_keep_alive_connections = m_master.origin_min_keep_alive_connections;
+
+  if( params->origin_max_connections &&
+      params->origin_max_connections < params->origin_min_keep_alive_connections ) {
+    Warning("origin_max_connections < origin_min_keep_alive_connections, setting min=max , please correct your records.config");
+    params->origin_min_keep_alive_connections = params->origin_max_connections;
+  }
+
   params->parent_proxy_routing_enable = INT_TO_BOOL(m_master.parent_proxy_routing_enable);
 
   // Traffic Net

Modified: incubator/trafficserver/traffic/trunk/proxy/http2/HttpConfig.h
URL: http://svn.apache.org/viewvc/incubator/trafficserver/traffic/trunk/proxy/http2/HttpConfig.h?rev=909108&r1=909107&r2=909108&view=diff
==============================================================================
--- incubator/trafficserver/traffic/trunk/proxy/http2/HttpConfig.h (original)
+++ incubator/trafficserver/traffic/trunk/proxy/http2/HttpConfig.h Thu Feb 11 19:04:29 2010
@@ -407,6 +407,7 @@
 
   MgmtInt server_max_connections;
   MgmtInt origin_max_connections;
+  MgmtInt origin_min_keep_alive_connections;
 
   MgmtInt parent_proxy_routing_enable;
   MgmtInt disable_ssl_parenting;
@@ -853,6 +854,7 @@
 outgoing_ip_to_bind_saddr(0),
 server_max_connections(0),
 origin_max_connections(0),
+origin_min_keep_alive_connections(0),
 parent_proxy_routing_enable(false),
 disable_ssl_parenting(0),
 enable_url_expandomatic(0),

Modified: incubator/trafficserver/traffic/trunk/proxy/http2/HttpSM.cc
URL: http://svn.apache.org/viewvc/incubator/trafficserver/traffic/trunk/proxy/http2/HttpSM.cc?rev=909108&r1=909107&r2=909108&view=diff
==============================================================================
--- incubator/trafficserver/traffic/trunk/proxy/http2/HttpSM.cc (original)
+++ incubator/trafficserver/traffic/trunk/proxy/http2/HttpSM.cc Thu Feb 11 19:04:29 2010
@@ -1818,11 +1818,13 @@
   switch (event) {
   case NET_EVENT_OPEN:
     session = THREAD_ALLOC_INIT(httpServerSessionAllocator, mutex->thread_holding);
-    // If origin_max_connections is set then we are limiting the number
+    // If origin_max_connections or origin_min_keep_alive_connections is 
+    // set then we are metering the max and or min number
     // of connections per host.  Set enable_origin_connection_limiting
     // to true in the server session so it will increment and decrement
     // the connection count.
-    if (t_state.http_config_param->origin_max_connections > 0) {
+    if (t_state.http_config_param->origin_max_connections > 0 || 
+        t_state.http_config_param->origin_min_keep_alive_connections > 0) {
       Debug("http_ss", "[%lld] max number of connections: %u",
             sm_id, t_state.http_config_param->origin_max_connections);
       session->enable_origin_connection_limiting = true;

Modified: incubator/trafficserver/traffic/trunk/proxy/http2/HttpSessionManager.cc
URL: http://svn.apache.org/viewvc/incubator/trafficserver/traffic/trunk/proxy/http2/HttpSessionManager.cc?rev=909108&r1=909107&r2=909108&view=diff
==============================================================================
--- incubator/trafficserver/traffic/trunk/proxy/http2/HttpSessionManager.cc (original)
+++ incubator/trafficserver/traffic/trunk/proxy/http2/HttpSessionManager.cc Thu Feb 11 19:04:29 2010
@@ -80,6 +80,32 @@
   s = l2_hash[l2_index].head;
   while (s != NULL) {
     if (s->get_netvc() == net_vc) {
+
+      // if there was a timeout of some kind on a keep alive connection, and 
+      // keeping the connection alive will not keep us above the # of max connections
+      // to the origin and we are below the min number of keep alive connections to this 
+      // origin, then reset the timeouts on our end and do not close the connection
+      if( (event == VC_EVENT_INACTIVITY_TIMEOUT || event == VC_EVENT_ACTIVE_TIMEOUT) &&
+           s->state == HSS_KA_SHARED &&
+           s->enable_origin_connection_limiting ) {
+
+        HttpConfigParams *http_config_params = HttpConfig::acquire();
+        bool connection_count_below_min = s->connection_count->getCount(s->server_ip) <= http_config_params->origin_min_keep_alive_connections;
+        HttpConfig::release(http_config_params);
+
+        if( connection_count_below_min ) {
+          Debug("http_ss", "[%b64d] [session_bucket] session received io notice [%s], "
+                "reseting timeout to maintain minimum number of connections", s->con_id,
+                HttpDebugNames::get_event_name(event));
+          s->get_netvc()->set_inactivity_timeout(HRTIME_SECONDS(
+            HttpConfig::m_master.keep_alive_no_activity_timeout_out));
+          s->get_netvc()->set_active_timeout(HRTIME_SECONDS(
+            HttpConfig::m_master.keep_alive_no_activity_timeout_out));
+          return 0;
+        }
+      }
+
+
       // We've found our server session. Remove it from
       //   our lists and close it down
       Debug("http_ss", "[%lld] [session_bucket] session received "
@@ -284,6 +310,7 @@
     // Transfer control of the write side as well
     to_release->do_io_write(bucket, 0, NULL);
 
+    // we probably don't need the active timeout set, but will leave it for now
     to_release->get_netvc()->
       set_inactivity_timeout(HRTIME_SECONDS(HttpConfig::m_master.keep_alive_no_activity_timeout_out));
     to_release->get_netvc()->

Modified: incubator/trafficserver/traffic/trunk/proxy/mgmt2/RecordsConfig.cc
URL: http://svn.apache.org/viewvc/incubator/trafficserver/traffic/trunk/proxy/mgmt2/RecordsConfig.cc?rev=909108&r1=909107&r2=909108&view=diff
==============================================================================
--- incubator/trafficserver/traffic/trunk/proxy/mgmt2/RecordsConfig.cc (original)
+++ incubator/trafficserver/traffic/trunk/proxy/mgmt2/RecordsConfig.cc Thu Feb 11 19:04:29 2010
@@ -922,6 +922,8 @@
   ,
   {CONFIG, "proxy.config.http.origin_max_connections", "", INK_INT, "0", RU_REREAD, RR_NULL, RC_INT, "^[0-9]+$", RA_NULL}
   ,
+  {CONFIG, "proxy.config.http.origin_min_keep_alive_connections", "", INK_INT, "0", RU_REREAD, RR_NULL, RC_INT, "^[0-9]+$", RA_NULL}
+  ,
 
   //       ##########################
   //       # HTTP referer filtering #