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
6 changes: 6 additions & 0 deletions doc/admin-guide/monitoring/logging/log-formats.en.rst
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,12 @@ The following list describes |TS| custom logging fields.
from a single server session. A value greater than 0 indicates connection
reuse.

.. _sscc:

``sscc``
The number of open connections to specified origin at the time of
connection establishment.

.. _ttms:

``ttms``
Expand Down
22 changes: 11 additions & 11 deletions proxy/http/HttpSM.cc
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ HttpSM::HttpSM()
server_response_hdr_bytes(0), server_response_body_bytes(0), client_response_hdr_bytes(0), client_response_body_bytes(0),
cache_response_hdr_bytes(0), cache_response_body_bytes(0), pushed_response_hdr_bytes(0), pushed_response_body_bytes(0),
client_tcp_reused(false), client_ssl_reused(false), client_connection_is_ssl(false), client_sec_protocol("-"),
client_cipher_suite("-"), server_transact_count(0), server_connection_is_ssl(false), plugin_tag(0), plugin_id(0),
client_cipher_suite("-"), server_transact_count(0), server_connection_is_ssl(false), server_connection_count(0), plugin_tag(0), plugin_id(0),
hooks_set(false), cur_hook_id(TS_HTTP_LAST_HOOK), cur_hook(NULL), cur_hooks(0), callout_state(HTTP_API_NO_CALLOUT),
terminate_sm(false), kill_this_async_done(false), parse_range_done(false)
{
Expand Down Expand Up @@ -1678,9 +1678,9 @@ HttpSM::state_http_server_open(int event, void *data)
// 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.txn_conf->origin_max_connections > 0 || t_state.http_config_param->origin_min_keep_alive_connections > 0) {
if (t_state.txn_conf->origin_max_connections > 0 || t_state.http_config_param->origin_min_keep_alive_connections > 0 || t_state.reverse_proxy) {
DebugSM("http_ss", "[%" PRId64 "] max number of connections: %" PRIu64, sm_id, t_state.txn_conf->origin_max_connections);
session->enable_origin_connection_limiting = true;
session->enable_origin_connection_tracking = true;
}
/*UnixNetVConnection * vc = (UnixNetVConnection*)(ua_session->client_vc);
UnixNetVConnection *server_vc = (UnixNetVConnection*)data;
Expand Down Expand Up @@ -4656,7 +4656,14 @@ HttpSM::do_http_server_open(bool raw)
}

DebugSM("http_seq", "[HttpSM::do_http_server_open] Sending request to server");

ConnectionCount *connections = ConnectionCount::getInstance();
INK_MD5 hostname_hash;
MD5Context md5_ctx;
md5_ctx.hash_immediate(hostname_hash, static_cast<const void *>(t_state.current.server->name),
strlen(t_state.current.server->name));
server_connection_count = connections->getCount(t_state.current.server->dst_addr, hostname_hash,
(TSServerSessionSharingMatchType)t_state.txn_conf->server_session_sharing_match);

milestones[TS_MILESTONE_SERVER_CONNECT] = Thread::get_hrtime();
if (milestones[TS_MILESTONE_SERVER_FIRST_CONNECT] == 0) {
milestones[TS_MILESTONE_SERVER_FIRST_CONNECT] = milestones[TS_MILESTONE_SERVER_CONNECT];
Expand Down Expand Up @@ -4802,13 +4809,6 @@ HttpSM::do_http_server_open(bool raw)
// Check to see if we have reached the max number of connections on this
// host.
if (t_state.txn_conf->origin_max_connections > 0) {
ConnectionCount *connections = ConnectionCount::getInstance();

INK_MD5 hostname_hash;
MD5Context md5_ctx;
md5_ctx.hash_immediate(hostname_hash, static_cast<const void *>(t_state.current.server->name),
strlen(t_state.current.server->name));

ip_port_text_buffer addrbuf;
if (connections->getCount(t_state.current.server->dst_addr, hostname_hash,
(TSServerSessionSharingMatchType)t_state.txn_conf->server_session_sharing_match) >=
Expand Down
1 change: 1 addition & 0 deletions proxy/http/HttpSM.h
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,7 @@ class HttpSM : public Continuation
const char *client_cipher_suite;
int server_transact_count;
bool server_connection_is_ssl;
int server_connection_count;

TransactionMilestones milestones;
ink_hrtime api_timer;
Expand Down
4 changes: 2 additions & 2 deletions proxy/http/HttpServerSession.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ HttpServerSession::new_connection(NetVConnection *new_vc)
HTTP_INCREMENT_DYN_STAT(http_total_server_connections_stat);
// Check to see if we are limiting the number of connections
// per host
if (enable_origin_connection_limiting == true) {
if (enable_origin_connection_tracking == true) {
if (connection_count == NULL)
connection_count = ConnectionCount::getInstance();
connection_count->incrementCount(server_ip, hostname_hash, sharing_match);
Expand Down Expand Up @@ -138,7 +138,7 @@ HttpServerSession::do_io_close(int alerrno)

// Check to see if we are limiting the number of connections
// per host
if (enable_origin_connection_limiting == true) {
if (enable_origin_connection_tracking == true) {
if (connection_count->getCount(server_ip, hostname_hash, sharing_match) >= 0) {
connection_count->incrementCount(server_ip, hostname_hash, sharing_match, -1);
ip_port_text_buffer addrbuf;
Expand Down
4 changes: 2 additions & 2 deletions proxy/http/HttpServerSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class HttpServerSession : public VConnection
HttpServerSession()
: VConnection(NULL), hostname_hash(), con_id(0), transact_count(0), state(HSS_INIT), to_parent_proxy(false),
server_trans_stat(0), private_session(false), sharing_match(TS_SERVER_SESSION_SHARING_MATCH_BOTH),
sharing_pool(TS_SERVER_SESSION_SHARING_POOL_GLOBAL), enable_origin_connection_limiting(false), connection_count(NULL),
sharing_pool(TS_SERVER_SESSION_SHARING_POOL_GLOBAL), enable_origin_connection_tracking(false), connection_count(NULL),
read_buffer(NULL), server_vc(NULL), magic(HTTP_SS_MAGIC_DEAD), buf_reader(NULL)
{
ink_zero(server_ip);
Expand Down Expand Up @@ -151,7 +151,7 @@ class HttpServerSession : public VConnection

// Keep track of connection limiting and a pointer to the
// singleton that keeps track of the connection counts.
bool enable_origin_connection_limiting;
bool enable_origin_connection_tracking;
ConnectionCount *connection_count;

// The ServerSession owns the following buffer which use
Expand Down
2 changes: 1 addition & 1 deletion proxy/http/HttpSessionManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ ServerSessionPool::eventHandler(int event, void *data)
// 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) {
s->enable_origin_connection_tracking) {
bool connection_count_below_min = s->connection_count->getCount(s->server_ip, s->hostname_hash, s->sharing_match) <=
http_config_params->origin_min_keep_alive_connections;

Expand Down
5 changes: 5 additions & 0 deletions proxy/logging/Log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,11 @@ Log::init_fields()
&LogAccess::unmarshal_int_to_str);
global_field_list.add(field, false);
ink_hash_table_insert(field_symbol_hash, "sca", field);

field = new LogField("server_connection_count", "sscc", LogField::sINT, &LogAccess::marshal_server_connection_count,
&LogAccess::unmarshal_int_to_str);
global_field_list.add(field, false);
ink_hash_table_insert(field_symbol_hash, "sscc", field);

field = new LogField("cached_resp_status_code", "csssc", LogField::sINT, &LogAccess::marshal_cache_resp_status_code,
&LogAccess::unmarshal_http_status);
Expand Down
8 changes: 8 additions & 0 deletions proxy/logging/LogAccess.cc
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,14 @@ LogAccess::marshal_server_connect_attempts(char *buf)
DEFAULT_INT_FIELD;
}

/*-------------------------------------------------------------------------
-------------------------------------------------------------------------*/
int
LogAccess::marshal_server_connection_count(char *buf)
{
DEFAULT_INT_FIELD;
}

/*-------------------------------------------------------------------------
-------------------------------------------------------------------------*/

Expand Down
1 change: 1 addition & 0 deletions proxy/logging/LogAccess.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ class LogAccess
inkcoreapi virtual int marshal_server_resp_time_s(char *); // INT
inkcoreapi virtual int marshal_server_transact_count(char *); // INT
inkcoreapi virtual int marshal_server_connect_attempts(char *); // INT
inkcoreapi virtual int marshal_server_connection_count(char *); // INT

//
// cache -> client fields
Expand Down
14 changes: 14 additions & 0 deletions proxy/logging/LogAccessHttp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1153,6 +1153,20 @@ LogAccessHttp::marshal_server_connect_attempts(char *buf)
return INK_MIN_ALIGN;
}

/*-------------------------------------------------------------------------
-------------------------------------------------------------------------*/

int
LogAccessHttp::marshal_server_connection_count(char *buf)
{
if (buf) {
int64_t count;
count = m_http_sm->server_connection_count;
marshal_int(buf, count);
}
return INK_MIN_ALIGN;
}

/*-------------------------------------------------------------------------
-------------------------------------------------------------------------*/

Expand Down
1 change: 1 addition & 0 deletions proxy/logging/LogAccessHttp.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ class LogAccessHttp : public LogAccess
virtual int marshal_server_resp_time_s(char *); // INT
virtual int marshal_server_transact_count(char *); // INT
virtual int marshal_server_connect_attempts(char *); // INT
virtual int marshal_server_connection_count(char *); // INT

//
// cache -> client fields
Expand Down