Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions doc/admin-guide/files/records.config.en.rst
Original file line number Diff line number Diff line change
Expand Up @@ -409,20 +409,21 @@ Network
handled. This should be tuned according to your memory size, and expected
work load. If this is set to 0, the throttling logic is disabled.

.. ts:cv:: CONFIG proxy.config.net.max_connections_in INT 30000
.. ts:cv:: CONFIG proxy.config.net.max_requests_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.
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_requests_in` and `proxy.config.net.max_active_requests_in`
is the amount of maximum idle connections |TS| will maintain.

.. ts:cv:: CONFIG proxy.config.net.max_active_connections_in INT 10000
.. ts:cv:: CONFIG proxy.config.net.max_active_requests_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
request tracking is disabled and max active 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.active.requests_throttled_in integer
:type: counter

.. ts:stat:: global proxy.process.net.default_inactivity_timeout_applied integer
Expand Down
4 changes: 2 additions & 2 deletions iocore/net/Net.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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.active.requests_throttled_in", RECD_INT, RECP_PERSISTENT,
(int)net_requests_max_active_throttled_in_stat, RecRawStatSyncSum);
}

void
Expand Down
2 changes: 1 addition & 1 deletion iocore/net/P_Net.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_active_throttled_in_stat,
Net_Stat_Count
};

Expand Down
10 changes: 5 additions & 5 deletions iocore/net/P_UnixNet.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,8 @@ class NetHandler : public Continuation, public EThread::LoopTailHandler

/// 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 max_requests_active_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;
Expand All @@ -288,7 +288,7 @@ class NetHandler : public Continuation, public EThread::LoopTailHandler
uint32_t &
operator[](int n)
{
return *(&max_connections_in + n);
return *(&max_requests_in + n);
}
};
/** Static global config, set and updated per process.
Expand All @@ -302,8 +302,8 @@ class NetHandler : public Continuation, public EThread::LoopTailHandler
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_requests_per_thread_in = 0;
uint32_t max_requests_active_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.
Expand Down
57 changes: 28 additions & 29 deletions iocore/net/UnixNet.cc
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,11 @@ NetHandler::update_nethandler_config(const char *str, RecDataT, RecData data, vo
uint32_t *updated_member = nullptr; // direct pointer to config member for update.
std::string_view name{str};

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);
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.max_active_connections_in"sv) {
updated_member = &NetHandler::global_config.max_connections_active_in;
updated_member = &NetHandler::global_config.max_requests_active_in;
Debug("net_queue", "proxy.config.net.max_active_connections_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;
Expand Down Expand Up @@ -320,22 +320,22 @@ void
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.max_requests_active_in, "proxy.config.net.max_requests_active_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_requests_in", update_nethandler_config, nullptr);
RecRegisterConfigUpdateCb("proxy.config.net.max_active_connections_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.max_active_connections_in updated to %d", global_config.max_requests_active_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);
Expand Down Expand Up @@ -569,17 +569,17 @@ NetHandler::manage_active_queue(bool ignore_queue_size = false)
{
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_requests_per_thread_in: %d max_requests_active_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,
max_requests_per_thread_in, max_requests_active_per_thread_in, total_connections_in, active_queue_size,
keep_alive_queue_size);

if (!max_connections_active_per_thread_in) {
if (!max_requests_active_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_active_per_thread_in > active_queue_size) {
return true;
}

Expand All @@ -598,12 +598,12 @@ NetHandler::manage_active_queue(bool ignore_queue_size = false)
(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_active_per_thread_in > active_queue_size) {
return true;
}
}

if (max_connections_active_per_thread_in > active_queue_size) {
if (max_requests_active_per_thread_in > active_queue_size) {
return true;
}

Expand All @@ -614,12 +614,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;
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);
int threads = eventProcessor.thread_group[ET_NET]._count;
max_requests_per_thread_in = config.max_requests_in / threads;
max_requests_active_per_thread_in = config.max_requests_active_in / threads;
Debug("net_queue", "max_requests_per_thread_in updated to %d threads: %d", max_requests_per_thread_in, threads);
Debug("net_queue", "max_requests_active_per_thread_in updated to %d threads: %d", max_requests_active_per_thread_in, threads);
}

void
Expand All @@ -628,10 +627,10 @@ NetHandler::manage_keep_alive_queue()
uint32_t total_connections_in = active_queue_size + keep_alive_queue_size;
ink_hrtime now = Thread::get_hrtime();

Debug("v_net_queue", "max_connections_per_thread_in: %d total_connections_in: %d active_queue_size: %d keep_alive_queue_size: %d",
max_connections_per_thread_in, total_connections_in, active_queue_size, keep_alive_queue_size);
Debug("v_net_queue", "max_requests_per_thread_in: %d total_connections_in: %d active_queue_size: %d keep_alive_queue_size: %d",
max_requests_per_thread_in, total_connections_in, active_queue_size, keep_alive_queue_size);

if (!max_connections_per_thread_in || total_connections_in <= max_connections_per_thread_in) {
if (!max_requests_per_thread_in || total_connections_in <= max_requests_per_thread_in) {
return;
}

Expand All @@ -646,14 +645,14 @@ NetHandler::manage_keep_alive_queue()
_close_ne(ne, now, handle_event, closed, total_idle_time, total_idle_count);

total_connections_in = active_queue_size + keep_alive_queue_size;
if (total_connections_in <= max_connections_per_thread_in) {
if (total_connections_in <= max_requests_per_thread_in) {
break;
}
}

if (total_idle_count > 0) {
Debug("net_queue", "max cons: %d active: %d idle: %d already closed: %d, close event: %d mean idle: %d",
max_connections_per_thread_in, total_connections_in, keep_alive_queue_size, closed, handle_event,
max_requests_per_thread_in, total_connections_in, keep_alive_queue_size, closed, handle_event,
total_idle_time / total_idle_count);
}
}
Expand Down Expand Up @@ -734,8 +733,8 @@ bool
NetHandler::add_to_active_queue(NetEvent *ne)
{
Debug("net_queue", "NetEvent: %p", ne);
Debug("net_queue", "max_connections_per_thread_in: %d active_queue_size: %d keep_alive_queue_size: %d",
max_connections_per_thread_in, active_queue_size, keep_alive_queue_size);
Debug("net_queue", "max_requests_per_thread_in: %d active_queue_size: %d keep_alive_queue_size: %d", max_requests_per_thread_in,
active_queue_size, keep_alive_queue_size);
ink_assert(mutex->thread_holding == this_ethread());

bool active_queue_full = false;
Expand All @@ -751,7 +750,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_active_throttled_in_stat, 1);
return false;
}
// in the keep-alive queue or no queue, new to this queue
Expand Down
4 changes: 2 additions & 2 deletions mgmt/RecordsConfig.cc
Original file line number Diff line number Diff line change
Expand Up @@ -398,9 +398,9 @@ static const RecordElement RecordsConfig[] =
,
{RECT_CONFIG, "proxy.config.http.attach_server_session_to_client", RECD_INT, "0", RECU_DYNAMIC, RR_NULL, RECC_INT, "[0-1]", RECA_NULL}
,
{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_requests_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, "10000", RECU_DYNAMIC, RR_NULL, RECC_STR, "^[0-9]+$", RECA_NULL}
{RECT_CONFIG, "proxy.config.net.max_requests_active_in", RECD_INT, "10000", RECU_DYNAMIC, RR_NULL, RECC_STR, "^[0-9]+$", RECA_NULL}
,

// ###########################
Expand Down