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 2020/07/07 22:12:42 UTC

[trafficserver] branch 9.0.x updated: RateLimiting and Connection Config changes (#6968)

This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/9.0.x by this push:
     new e529965  RateLimiting and Connection Config changes (#6968)
e529965 is described below

commit e5299650fd7680184f2ee3602ed238e0c4014641
Author: Sudheer Vinukonda <su...@apache.org>
AuthorDate: Thu Jul 2 09:29:01 2020 -0700

    RateLimiting and Connection Config changes (#6968)
    
    Conn config renaming to support a protocol agnostic
    rate limiter (using request concurrency as opposed to
    active connections)
    
    (cherry picked from commit e2a0d8cf580b0e954848fbc645a77040ebcbd1f3)
---
 doc/admin-guide/files/records.config.en.rst        | 27 ++++++++--------
 .../monitoring/statistics/core/network-io.en.rst   |  2 +-
 iocore/net/Net.cc                                  |  4 +--
 iocore/net/P_Net.h                                 |  2 +-
 iocore/net/P_UnixNet.h                             |  6 ++--
 iocore/net/UnixNet.cc                              | 36 ++++++++++------------
 mgmt/RecordsConfig.cc                              |  2 +-
 7 files changed, 39 insertions(+), 40 deletions(-)

diff --git a/doc/admin-guide/files/records.config.en.rst b/doc/admin-guide/files/records.config.en.rst
index a9db974..217a362 100644
--- a/doc/admin-guide/files/records.config.en.rst
+++ b/doc/admin-guide/files/records.config.en.rst
@@ -414,19 +414,20 @@ Network
 
 .. ts:cv:: CONFIG proxy.config.net.max_connections_in INT 30000
 
-   The total number of client connections that the :program:`traffic_server`
-   can handle simultaneously. This should be tuned according to your memory size,
-   and expected work load (network, cpu etc). This limit includes both keepalive
-   and active client connections that :program:`traffic_server` can handle at
-   any given instant.
-
-.. ts:cv:: CONFIG proxy.config.net.max_active_connections_in INT 10000
-
-   The total number of active client connections that the |TS| can handle
-   simultaneously. This should be tuned according to your memory size,
-   and expected work load (network, cpu etc). If this is set to 0, active
-   connection tracking is disabled and active connections have no separate
-   limit and the total connections follow `proxy.config.net.connections_throttle`
+   The total number of client requests that |TS| can handle simultaneously.
+   This should be tuned according to your memory size, and expected work load
+   (network, cpu etc). This limit includes both idle (keep alive) connections
+   and active requests that |TS| can handle at any given instant. The delta
+   between `proxy.config.net.max_connections_in` and `proxy.config.net.max_requests_in`
+   is the amount of maximum idle (keepalive) connections |TS| will maintain.
+
+.. ts:cv:: CONFIG proxy.config.net.max_requests_in INT 0
+
+   The total number of concurrent requests or active client connections
+   that the |TS| can handle simultaneously. This should be tuned according
+   to your memory size, and expected work load (network, cpu etc). When
+   set to 0, active request tracking is disabled and max requests has no
+   separate limit and the total connections follow `proxy.config.net.connections_throttle`
 
 .. ts:cv:: CONFIG proxy.config.net.default_inactivity_timeout INT 86400
    :reloadable:
diff --git a/doc/admin-guide/monitoring/statistics/core/network-io.en.rst b/doc/admin-guide/monitoring/statistics/core/network-io.en.rst
index 3777359..5ea7687 100644
--- a/doc/admin-guide/monitoring/statistics/core/network-io.en.rst
+++ b/doc/admin-guide/monitoring/statistics/core/network-io.en.rst
@@ -66,7 +66,7 @@ Network I/O
 .. ts:stat:: global proxy.process.net.connections_throttled_out integer
    :type: counter
 
-.. ts:stat:: global proxy.process.net.max.active.connections_throttled_in integer
+.. ts:stat:: global proxy.process.net.max.requests_throttled_in integer
    :type: counter
 
 .. ts:stat:: global proxy.process.net.default_inactivity_timeout_applied integer
diff --git a/iocore/net/Net.cc b/iocore/net/Net.cc
index 2ee21f9..f0cac5b 100644
--- a/iocore/net/Net.cc
+++ b/iocore/net/Net.cc
@@ -142,8 +142,8 @@ register_net_stats()
                      (int)net_connections_throttled_in_stat, RecRawStatSyncSum);
   RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.net.connections_throttled_out", RECD_INT, RECP_PERSISTENT,
                      (int)net_connections_throttled_out_stat, RecRawStatSyncSum);
-  RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.net.max.active.connections_throttled_in", RECD_INT, RECP_PERSISTENT,
-                     (int)net_connections_max_active_throttled_in_stat, RecRawStatSyncSum);
+  RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.net.max.requests_throttled_in", RECD_INT, RECP_PERSISTENT,
+                     (int)net_requests_max_throttled_in_stat, RecRawStatSyncSum);
 }
 
 void
diff --git a/iocore/net/P_Net.h b/iocore/net/P_Net.h
index 45996a6..46a05c3 100644
--- a/iocore/net/P_Net.h
+++ b/iocore/net/P_Net.h
@@ -58,7 +58,7 @@ enum Net_Stats {
   net_tcp_accept_stat,
   net_connections_throttled_in_stat,
   net_connections_throttled_out_stat,
-  net_connections_max_active_throttled_in_stat,
+  net_requests_max_throttled_in_stat,
   Net_Stat_Count
 };
 
diff --git a/iocore/net/P_UnixNet.h b/iocore/net/P_UnixNet.h
index 82c7884..fbc10ec 100644
--- a/iocore/net/P_UnixNet.h
+++ b/iocore/net/P_UnixNet.h
@@ -251,7 +251,7 @@ public:
   /// configuration settings for managing the active and keep-alive queues
   struct Config {
     uint32_t max_connections_in                 = 0;
-    uint32_t max_connections_active_in          = 0;
+    uint32_t max_requests_in                    = 0;
     uint32_t inactive_threshold_in              = 0;
     uint32_t transaction_no_activity_timeout_in = 0;
     uint32_t keep_alive_no_activity_timeout_in  = 0;
@@ -280,8 +280,8 @@ public:
   Config config; ///< Per thread copy of the @c global_config
   // Active and keep alive queue values that depend on other configuration values.
   // These are never updated directly, they are computed from other config values.
-  uint32_t max_connections_per_thread_in        = 0;
-  uint32_t max_connections_active_per_thread_in = 0;
+  uint32_t max_connections_per_thread_in = 0;
+  uint32_t max_requests_per_thread_in    = 0;
   /// Number of configuration items in @c Config.
   static constexpr int CONFIG_ITEM_COUNT = sizeof(Config) / sizeof(uint32_t);
   /// Which members of @c Config the per thread values depend on.
diff --git a/iocore/net/UnixNet.cc b/iocore/net/UnixNet.cc
index f368e07..3e15b97 100644
--- a/iocore/net/UnixNet.cc
+++ b/iocore/net/UnixNet.cc
@@ -276,9 +276,9 @@ NetHandler::update_nethandler_config(const char *str, RecDataT, RecData data, vo
   if (name == "proxy.config.net.max_connections_in"sv) {
     updated_member = &NetHandler::global_config.max_connections_in;
     Debug("net_queue", "proxy.config.net.max_connections_in updated to %" PRId64, data.rec_int);
-  } else if (name == "proxy.config.net.max_active_connections_in"sv) {
-    updated_member = &NetHandler::global_config.max_connections_active_in;
-    Debug("net_queue", "proxy.config.net.max_active_connections_in updated to %" PRId64, data.rec_int);
+  } else if (name == "proxy.config.net.max_requests_in"sv) {
+    updated_member = &NetHandler::global_config.max_requests_in;
+    Debug("net_queue", "proxy.config.net.max_requests_in updated to %" PRId64, data.rec_int);
   } else if (name == "proxy.config.net.inactive_threshold_in"sv) {
     updated_member = &NetHandler::global_config.inactive_threshold_in;
     Debug("net_queue", "proxy.config.net.inactive_threshold_in updated to %" PRId64, data.rec_int);
@@ -321,21 +321,21 @@ NetHandler::init_for_process()
 {
   // read configuration values and setup callbacks for when they change
   REC_ReadConfigInt32(global_config.max_connections_in, "proxy.config.net.max_connections_in");
-  REC_ReadConfigInt32(global_config.max_connections_active_in, "proxy.config.net.max_connections_active_in");
+  REC_ReadConfigInt32(global_config.max_requests_in, "proxy.config.net.max_requests_in");
   REC_ReadConfigInt32(global_config.inactive_threshold_in, "proxy.config.net.inactive_threshold_in");
   REC_ReadConfigInt32(global_config.transaction_no_activity_timeout_in, "proxy.config.net.transaction_no_activity_timeout_in");
   REC_ReadConfigInt32(global_config.keep_alive_no_activity_timeout_in, "proxy.config.net.keep_alive_no_activity_timeout_in");
   REC_ReadConfigInt32(global_config.default_inactivity_timeout, "proxy.config.net.default_inactivity_timeout");
 
   RecRegisterConfigUpdateCb("proxy.config.net.max_connections_in", update_nethandler_config, nullptr);
-  RecRegisterConfigUpdateCb("proxy.config.net.max_active_connections_in", update_nethandler_config, nullptr);
+  RecRegisterConfigUpdateCb("proxy.config.net.max_requests_in", update_nethandler_config, nullptr);
   RecRegisterConfigUpdateCb("proxy.config.net.inactive_threshold_in", update_nethandler_config, nullptr);
   RecRegisterConfigUpdateCb("proxy.config.net.transaction_no_activity_timeout_in", update_nethandler_config, nullptr);
   RecRegisterConfigUpdateCb("proxy.config.net.keep_alive_no_activity_timeout_in", update_nethandler_config, nullptr);
   RecRegisterConfigUpdateCb("proxy.config.net.default_inactivity_timeout", update_nethandler_config, nullptr);
 
   Debug("net_queue", "proxy.config.net.max_connections_in updated to %d", global_config.max_connections_in);
-  Debug("net_queue", "proxy.config.net.max_active_connections_in updated to %d", global_config.max_connections_active_in);
+  Debug("net_queue", "proxy.config.net.max_requests_in updated to %d", global_config.max_requests_in);
   Debug("net_queue", "proxy.config.net.inactive_threshold_in updated to %d", global_config.inactive_threshold_in);
   Debug("net_queue", "proxy.config.net.transaction_no_activity_timeout_in updated to %d",
         global_config.transaction_no_activity_timeout_in);
@@ -569,17 +569,16 @@ NetHandler::manage_active_queue(NetEvent *enabling_ne, bool ignore_queue_size =
 {
   const int total_connections_in = active_queue_size + keep_alive_queue_size;
   Debug("v_net_queue",
-        "max_connections_per_thread_in: %d max_connections_active_per_thread_in: %d total_connections_in: %d "
+        "max_connections_per_thread_in: %d max_requests_per_thread_in: %d total_connections_in: %d "
         "active_queue_size: %d keep_alive_queue_size: %d",
-        max_connections_per_thread_in, max_connections_active_per_thread_in, total_connections_in, active_queue_size,
-        keep_alive_queue_size);
+        max_connections_per_thread_in, max_requests_per_thread_in, total_connections_in, active_queue_size, keep_alive_queue_size);
 
-  if (!max_connections_active_per_thread_in) {
+  if (!max_requests_per_thread_in) {
     // active queue has no max
     return true;
   }
 
-  if (ignore_queue_size == false && max_connections_active_per_thread_in > active_queue_size) {
+  if (ignore_queue_size == false && max_requests_per_thread_in > active_queue_size) {
     return true;
   }
 
@@ -603,12 +602,12 @@ NetHandler::manage_active_queue(NetEvent *enabling_ne, bool ignore_queue_size =
         (ne->active_timeout_in && ne->next_activity_timeout_at <= now)) {
       _close_ne(ne, now, handle_event, closed, total_idle_time, total_idle_count);
     }
-    if (ignore_queue_size == false && max_connections_active_per_thread_in > active_queue_size) {
+    if (ignore_queue_size == false && max_requests_per_thread_in > active_queue_size) {
       return true;
     }
   }
 
-  if (max_connections_active_per_thread_in > active_queue_size) {
+  if (max_requests_per_thread_in > active_queue_size) {
     return true;
   }
 
@@ -619,12 +618,11 @@ void
 NetHandler::configure_per_thread_values()
 {
   // figure out the number of threads and calculate the number of connections per thread
-  int threads                          = eventProcessor.thread_group[ET_NET]._count;
-  max_connections_per_thread_in        = config.max_connections_in / threads;
-  max_connections_active_per_thread_in = config.max_connections_active_in / threads;
+  int threads                   = eventProcessor.thread_group[ET_NET]._count;
+  max_connections_per_thread_in = config.max_connections_in / threads;
+  max_requests_per_thread_in    = config.max_requests_in / threads;
   Debug("net_queue", "max_connections_per_thread_in updated to %d threads: %d", max_connections_per_thread_in, threads);
-  Debug("net_queue", "max_connections_active_per_thread_in updated to %d threads: %d", max_connections_active_per_thread_in,
-        threads);
+  Debug("net_queue", "max_requests_per_thread_in updated to %d threads: %d", max_requests_per_thread_in, threads);
 }
 
 void
@@ -756,7 +754,7 @@ NetHandler::add_to_active_queue(NetEvent *ne)
   } else {
     if (active_queue_full) {
       // there is no room left in the queue
-      NET_SUM_DYN_STAT(net_connections_max_active_throttled_in_stat, 1);
+      NET_SUM_DYN_STAT(net_requests_max_throttled_in_stat, 1);
       return false;
     }
     // in the keep-alive queue or no queue, new to this queue
diff --git a/mgmt/RecordsConfig.cc b/mgmt/RecordsConfig.cc
index c2f4a87..6689252 100644
--- a/mgmt/RecordsConfig.cc
+++ b/mgmt/RecordsConfig.cc
@@ -400,7 +400,7 @@ static const RecordElement RecordsConfig[] =
   ,
   {RECT_CONFIG, "proxy.config.net.max_connections_in", RECD_INT, "30000", RECU_DYNAMIC, RR_NULL, RECC_STR, "^[0-9]+$", RECA_NULL}
   ,
-  {RECT_CONFIG, "proxy.config.net.max_connections_active_in", RECD_INT, "0", RECU_DYNAMIC, RR_NULL, RECC_STR, "^[0-9]+$", RECA_NULL}
+  {RECT_CONFIG, "proxy.config.net.max_requests_active_in", RECD_INT, "0", RECU_DYNAMIC, RR_NULL, RECC_STR, "^[0-9]+$", RECA_NULL}
   ,
 
   //       ###########################