From 3d4974c4eb4a3f03db3d2ad3e14fe2fed0877e4b Mon Sep 17 00:00:00 2001 From: Susan Hinrichs Date: Wed, 24 Jun 2020 23:03:03 +0000 Subject: [PATCH 1/3] Add option for hybrid global and thread session pools --- doc/admin-guide/files/records.config.en.rst | 16 +++++++++++ mgmt/RecordsConfig.cc | 2 ++ proxy/http/Http1ServerSession.cc | 2 +- proxy/http/HttpConfig.cc | 17 +++++++---- proxy/http/HttpConfig.h | 3 +- proxy/http/HttpSM.cc | 7 ++--- proxy/http/HttpSessionManager.cc | 31 ++++++++++++++++++--- proxy/http/HttpSessionManager.h | 29 +++++++++++++++++++ 8 files changed, 92 insertions(+), 15 deletions(-) diff --git a/doc/admin-guide/files/records.config.en.rst b/doc/admin-guide/files/records.config.en.rst index 395a5ad218a..c3dc1f72788 100644 --- a/doc/admin-guide/files/records.config.en.rst +++ b/doc/admin-guide/files/records.config.en.rst @@ -996,6 +996,22 @@ mptcp ``thread`` Re-use sessions from a per-thread pool. ========== ================================================================= +.. ts:cv:: CONFIG proxy.config.http.server_session_sharing.pool_hybrid_limit INT 0 + + Setting :ts:cv:`proxy.config.http.server_session_sharing.pool` to global can reduce + the number of connections to origin for some traffic loads. However, if many + execute threads are active, the thread contention on the global pool can reduce the + lifetime of connections to origin and reduce effective origin connection reuse. The + :ts:cv:`proxy.config.http.server_session_sharing.pool_hybrid_limit` setting lets you + enable a hybrid pool mode using both global and per thread pools. If hybrid mode + is enabled, sessons are returned to the local thread pool if the global pool lock is + not acquired rather than just closing the origin connection as is the case in standard + global mode. + + Setting it to 0, disables hybrid mode. Setting it to -1, enables hybrid + mode with no limit on the size of the thread local pool. Any other number enables hybrid + mode but sets a limit on the size of each thread's pool. + .. ts:cv:: CONFIG proxy.config.http.attach_server_session_to_client INT 0 :overridable: diff --git a/mgmt/RecordsConfig.cc b/mgmt/RecordsConfig.cc index 30ecbcc8dff..e9de65fd7c9 100644 --- a/mgmt/RecordsConfig.cc +++ b/mgmt/RecordsConfig.cc @@ -376,6 +376,8 @@ static const RecordElement RecordsConfig[] = , {RECT_CONFIG, "proxy.config.http.server_session_sharing.pool", RECD_STRING, "thread", RECU_RESTART_TS, RR_NULL, RECC_NULL, nullptr, RECA_NULL} , + {RECT_CONFIG, "proxy.config.http.server_session_sharing.pool_hybrid_limit", RECD_INT, "0", RECU_RESTART_TS, RR_NULL, RECC_NULL, nullptr, RECA_NULL} + , {RECT_CONFIG, "proxy.config.http.default_buffer_size", RECD_INT, "8", RECU_DYNAMIC, RR_NULL, RECC_NULL, nullptr, RECA_NULL} , {RECT_CONFIG, "proxy.config.http.default_buffer_water_mark", RECD_INT, "32768", RECU_DYNAMIC, RR_NULL, RECC_NULL, nullptr, RECA_NULL} diff --git a/proxy/http/Http1ServerSession.cc b/proxy/http/Http1ServerSession.cc index 813a729d6aa..e794668d235 100644 --- a/proxy/http/Http1ServerSession.cc +++ b/proxy/http/Http1ServerSession.cc @@ -52,7 +52,7 @@ Http1ServerSession::destroy() } mutex.clear(); - if (TS_SERVER_SESSION_SHARING_POOL_THREAD == sharing_pool) { + if (httpSessionManager.get_pool_type() == TS_SERVER_SESSION_SHARING_POOL_THREAD) { THREAD_FREE(this, httpServerSessionAllocator, this_thread()); } else { httpServerSessionAllocator.free(this); diff --git a/proxy/http/HttpConfig.cc b/proxy/http/HttpConfig.cc index b32e39c9831..808e6423508 100644 --- a/proxy/http/HttpConfig.cc +++ b/proxy/http/HttpConfig.cc @@ -33,6 +33,7 @@ #include "P_Net.h" #include "records/P_RecUtils.h" #include +#include "HttpSessionManager.h" #define HttpEstablishStaticConfigStringAlloc(_ix, _n) \ REC_EstablishStaticConfigStringAlloc(_ix, _n); \ @@ -1153,6 +1154,11 @@ HttpConfig::startup() http_config_enum_mask_read("proxy.config.http.server_session_sharing.match", c.oride.server_session_sharing_match); HttpEstablishStaticConfigStringAlloc(c.oride.server_session_sharing_match_str, "proxy.config.http.server_session_sharing.match"); http_config_enum_read("proxy.config.http.server_session_sharing.pool", SessionSharingPoolStrings, c.server_session_sharing_pool); + HttpEstablishStaticConfigByte(c.server_session_sharing_pool_hybrid_limit, + "proxy.config.http.server_session_sharing.pool_hybrid_limit"); + + httpSessionManager.set_hybrid_limit(c.server_session_sharing_pool_hybrid_limit); + httpSessionManager.set_pool_type(c.server_session_sharing_pool); RecRegisterConfigUpdateCb("proxy.config.http.insert_forwarded", &http_insert_forwarded_cb, &c); { @@ -1450,11 +1456,12 @@ HttpConfig::reconfigure() params->oride.flow_high_water_mark = params->oride.flow_low_water_mark = 0; } - params->oride.server_session_sharing_match = m_master.oride.server_session_sharing_match; - params->oride.server_session_sharing_match_str = ats_strdup(m_master.oride.server_session_sharing_match_str); - params->oride.server_min_keep_alive_conns = m_master.oride.server_min_keep_alive_conns; - params->server_session_sharing_pool = m_master.server_session_sharing_pool; - params->oride.keep_alive_post_out = m_master.oride.keep_alive_post_out; + params->oride.server_session_sharing_match = m_master.oride.server_session_sharing_match; + params->oride.server_session_sharing_match_str = ats_strdup(m_master.oride.server_session_sharing_match_str); + params->oride.server_min_keep_alive_conns = m_master.oride.server_min_keep_alive_conns; + params->server_session_sharing_pool = m_master.server_session_sharing_pool; + params->server_session_sharing_pool_hybrid_limit = m_master.server_session_sharing_pool_hybrid_limit; + params->oride.keep_alive_post_out = m_master.oride.keep_alive_post_out; params->oride.keep_alive_no_activity_timeout_in = m_master.oride.keep_alive_no_activity_timeout_in; params->oride.keep_alive_no_activity_timeout_out = m_master.oride.keep_alive_no_activity_timeout_out; diff --git a/proxy/http/HttpConfig.h b/proxy/http/HttpConfig.h index 06e1ccb2393..5b585132ed9 100644 --- a/proxy/http/HttpConfig.h +++ b/proxy/http/HttpConfig.h @@ -807,7 +807,8 @@ struct HttpConfigParams : public ConfigInfo { MgmtByte disallow_post_100_continue = 0; MgmtByte keepalive_internal_vc = 0; - MgmtByte server_session_sharing_pool = TS_SERVER_SESSION_SHARING_POOL_THREAD; + MgmtByte server_session_sharing_pool = TS_SERVER_SESSION_SHARING_POOL_THREAD; + MgmtByte server_session_sharing_pool_hybrid_limit = 0; OutboundConnTrack::GlobalConfig outbound_conntrack; diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc index 546715eed03..b3c0363cd3e 100644 --- a/proxy/http/HttpSM.cc +++ b/proxy/http/HttpSM.cc @@ -1781,10 +1781,9 @@ HttpSM::state_http_server_open(int event, void *data) switch (event) { case NET_EVENT_OPEN: { - Http1ServerSession *session = - (TS_SERVER_SESSION_SHARING_POOL_THREAD == t_state.http_config_param->server_session_sharing_pool) ? - THREAD_ALLOC_INIT(httpServerSessionAllocator, mutex->thread_holding) : - httpServerSessionAllocator.alloc(); + Http1ServerSession *session = (TS_SERVER_SESSION_SHARING_POOL_THREAD == httpSessionManager.get_pool_type()) ? + THREAD_ALLOC_INIT(httpServerSessionAllocator, mutex->thread_holding) : + httpServerSessionAllocator.alloc(); session->sharing_pool = static_cast(t_state.http_config_param->server_session_sharing_pool); session->sharing_match = static_cast(t_state.txn_conf->server_session_sharing_match); diff --git a/proxy/http/HttpSessionManager.cc b/proxy/http/HttpSessionManager.cc index bf5ea8d1fb0..2f3fff360e3 100644 --- a/proxy/http/HttpSessionManager.cc +++ b/proxy/http/HttpSessionManager.cc @@ -330,6 +330,7 @@ HSMresult_t HttpSessionManager::acquire_session(Continuation * /* cont ATS_UNUSED */, sockaddr const *ip, const char *hostname, ProxyTransaction *ua_txn, HttpSM *sm) { + // First test for any session bound to the ua_txn Http1ServerSession *to_return = nullptr; TSServerSessionSharingMatchMask match_style = static_cast(sm->t_state.txn_conf->server_session_sharing_match); @@ -370,6 +371,25 @@ HttpSessionManager::acquire_session(Continuation * /* cont ATS_UNUSED */, sockad to_return = nullptr; } + // Otherwise, check the thread pool first + if (this->get_pool_type() == TS_SERVER_SESSION_SHARING_POOL_THREAD || this->get_hybrid_limit() != 0) { + retval = acquire_session(ip, hostname_hash, sm, match_style, TS_SERVER_SESSION_SHARING_POOL_THREAD); + } + + // If you didn't get a match, and the global pool is an option go there. + if (retval != HSM_DONE && (TS_SERVER_SESSION_SHARING_POOL_GLOBAL == this->get_pool_type())) { + retval = acquire_session(ip, hostname_hash, sm, match_style, TS_SERVER_SESSION_SHARING_POOL_GLOBAL); + } + return retval; +} + +HSMresult_t +HttpSessionManager::acquire_session(sockaddr const *ip, CryptoHash const &hostname_hash, HttpSM *sm, + TSServerSessionSharingMatchMask match_style, TSServerSessionSharingPoolType pool_type) +{ + Http1ServerSession *to_return = nullptr; + HSMresult_t retval = HSM_NOT_FOUND; + // Extend the mutex window until the acquired Server session is attached // to the SM. Releasing the mutex before that results in race conditions // due to a potential parallel network read on the VC with no mutex guarding @@ -377,12 +397,10 @@ HttpSessionManager::acquire_session(Continuation * /* cont ATS_UNUSED */, sockad // Now check to see if we have a connection in our shared connection pool EThread *ethread = this_ethread(); Ptr pool_mutex = - (TS_SERVER_SESSION_SHARING_POOL_THREAD == sm->t_state.http_config_param->server_session_sharing_pool) ? - ethread->server_session_pool->mutex : - m_g_pool->mutex; + (TS_SERVER_SESSION_SHARING_POOL_THREAD == pool_type) ? ethread->server_session_pool->mutex : m_g_pool->mutex; MUTEX_TRY_LOCK(lock, pool_mutex, ethread); if (lock.is_locked()) { - if (TS_SERVER_SESSION_SHARING_POOL_THREAD == sm->t_state.http_config_param->server_session_sharing_pool) { + if (TS_SERVER_SESSION_SHARING_POOL_THREAD == pool_type) { retval = ethread->server_session_pool->acquireSession(ip, hostname_hash, match_style, sm, to_return); Debug("http_ss", "[acquire session] thread pool search %s", to_return ? "successful" : "failed"); } else { @@ -446,6 +464,11 @@ HttpSessionManager::release_session(Http1ServerSession *to_release) MUTEX_TRY_LOCK(lock, pool->mutex, ethread); if (lock.is_locked()) { pool->releaseSession(to_release); + } else if (to_release->sharing_pool == TS_SERVER_SESSION_SHARING_POOL_GLOBAL && + (m_hybrid_limit < 0 || ethread->server_session_pool->count() < m_hybrid_limit)) { + // Try again with the thread pool + to_release->sharing_pool = TS_SERVER_SESSION_SHARING_POOL_THREAD; + return release_session(to_release); } else { Debug("http_ss", "[%" PRId64 "] [release session] could not release session due to lock contention", to_release->con_id); released_p = false; diff --git a/proxy/http/HttpSessionManager.h b/proxy/http/HttpSessionManager.h index dcb80c9bac4..a9e937e675a 100644 --- a/proxy/http/HttpSessionManager.h +++ b/proxy/http/HttpSessionManager.h @@ -67,6 +67,11 @@ class ServerSessionPool : public Continuation static bool validate_host_sni(HttpSM *sm, NetVConnection *netvc); static bool validate_sni(HttpSM *sm, NetVConnection *netvc); static bool validate_cert(HttpSM *sm, NetVConnection *netvc); + int + count() const + { + return m_ip_pool.count(); + } protected: using IPTable = IntrusiveHashMap; @@ -110,11 +115,35 @@ class HttpSessionManager void purge_keepalives(); void init(); int main_handler(int event, void *data); + void + set_hybrid_limit(int limit) + { + m_hybrid_limit = limit; + } + void + set_pool_type(int pool_type) + { + m_pool_type = static_cast(pool_type); + } + TSServerSessionSharingPoolType + get_pool_type() const + { + return m_pool_type; + } + int + get_hybrid_limit() const + { + return m_hybrid_limit; + } private: /// Global pool, used if not per thread pools. /// @internal We delay creating this because the session manager is created during global statics init. ServerSessionPool *m_g_pool = nullptr; + HSMresult_t acquire_session(sockaddr const *ip, CryptoHash const &hostname_hash, HttpSM *sm, + TSServerSessionSharingMatchMask match_style, TSServerSessionSharingPoolType pool_type); + int m_hybrid_limit = 0; + TSServerSessionSharingPoolType m_pool_type = TS_SERVER_SESSION_SHARING_POOL_THREAD; }; extern HttpSessionManager httpSessionManager; From 897d602a628d0d8d5e0a8d96632d05cc09ed658c Mon Sep 17 00:00:00 2001 From: Susan Hinrichs Date: Thu, 15 Oct 2020 20:54:21 +0000 Subject: [PATCH 2/3] rename private version of acquire_session --- proxy/http/HttpSessionManager.cc | 8 ++++---- proxy/http/HttpSessionManager.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/proxy/http/HttpSessionManager.cc b/proxy/http/HttpSessionManager.cc index 2f3fff360e3..3b438b990a3 100644 --- a/proxy/http/HttpSessionManager.cc +++ b/proxy/http/HttpSessionManager.cc @@ -373,19 +373,19 @@ HttpSessionManager::acquire_session(Continuation * /* cont ATS_UNUSED */, sockad // Otherwise, check the thread pool first if (this->get_pool_type() == TS_SERVER_SESSION_SHARING_POOL_THREAD || this->get_hybrid_limit() != 0) { - retval = acquire_session(ip, hostname_hash, sm, match_style, TS_SERVER_SESSION_SHARING_POOL_THREAD); + retval = _acquire_session(ip, hostname_hash, sm, match_style, TS_SERVER_SESSION_SHARING_POOL_THREAD); } // If you didn't get a match, and the global pool is an option go there. if (retval != HSM_DONE && (TS_SERVER_SESSION_SHARING_POOL_GLOBAL == this->get_pool_type())) { - retval = acquire_session(ip, hostname_hash, sm, match_style, TS_SERVER_SESSION_SHARING_POOL_GLOBAL); + retval = _acquire_session(ip, hostname_hash, sm, match_style, TS_SERVER_SESSION_SHARING_POOL_GLOBAL); } return retval; } HSMresult_t -HttpSessionManager::acquire_session(sockaddr const *ip, CryptoHash const &hostname_hash, HttpSM *sm, - TSServerSessionSharingMatchMask match_style, TSServerSessionSharingPoolType pool_type) +HttpSessionManager::_acquire_session(sockaddr const *ip, CryptoHash const &hostname_hash, HttpSM *sm, + TSServerSessionSharingMatchMask match_style, TSServerSessionSharingPoolType pool_type) { Http1ServerSession *to_return = nullptr; HSMresult_t retval = HSM_NOT_FOUND; diff --git a/proxy/http/HttpSessionManager.h b/proxy/http/HttpSessionManager.h index a9e937e675a..8d75ed28bda 100644 --- a/proxy/http/HttpSessionManager.h +++ b/proxy/http/HttpSessionManager.h @@ -140,8 +140,8 @@ class HttpSessionManager /// Global pool, used if not per thread pools. /// @internal We delay creating this because the session manager is created during global statics init. ServerSessionPool *m_g_pool = nullptr; - HSMresult_t acquire_session(sockaddr const *ip, CryptoHash const &hostname_hash, HttpSM *sm, - TSServerSessionSharingMatchMask match_style, TSServerSessionSharingPoolType pool_type); + HSMresult_t _acquire_session(sockaddr const *ip, CryptoHash const &hostname_hash, HttpSM *sm, + TSServerSessionSharingMatchMask match_style, TSServerSessionSharingPoolType pool_type); int m_hybrid_limit = 0; TSServerSessionSharingPoolType m_pool_type = TS_SERVER_SESSION_SHARING_POOL_THREAD; }; From 26b1a60c9891559883014029c389a046e5f9cdd4 Mon Sep 17 00:00:00 2001 From: Susan Hinrichs Date: Thu, 15 Oct 2020 21:33:28 +0000 Subject: [PATCH 3/3] Simplify hybrid pool config --- doc/admin-guide/files/records.config.en.rst | 18 +++++++----------- mgmt/RecordsConfig.cc | 2 -- proxy/http/HttpConfig.cc | 18 +++++++----------- proxy/http/HttpConfig.h | 3 +-- proxy/http/HttpProxyAPIEnums.h | 1 + proxy/http/HttpSessionManager.cc | 9 +++++---- proxy/http/HttpSessionManager.h | 11 ----------- 7 files changed, 21 insertions(+), 41 deletions(-) diff --git a/doc/admin-guide/files/records.config.en.rst b/doc/admin-guide/files/records.config.en.rst index c3dc1f72788..8a1aa813b5e 100644 --- a/doc/admin-guide/files/records.config.en.rst +++ b/doc/admin-guide/files/records.config.en.rst @@ -994,23 +994,19 @@ mptcp ========== ================================================================= ``global`` Re-use sessions from a global pool of all server sessions. ``thread`` Re-use sessions from a per-thread pool. + ``hybrid`` Try to work as a global pool, but release server sessions to the + per-thread pool if there is lock contention on the global pool. ========== ================================================================= -.. ts:cv:: CONFIG proxy.config.http.server_session_sharing.pool_hybrid_limit INT 0 Setting :ts:cv:`proxy.config.http.server_session_sharing.pool` to global can reduce the number of connections to origin for some traffic loads. However, if many execute threads are active, the thread contention on the global pool can reduce the - lifetime of connections to origin and reduce effective origin connection reuse. The - :ts:cv:`proxy.config.http.server_session_sharing.pool_hybrid_limit` setting lets you - enable a hybrid pool mode using both global and per thread pools. If hybrid mode - is enabled, sessons are returned to the local thread pool if the global pool lock is - not acquired rather than just closing the origin connection as is the case in standard - global mode. - - Setting it to 0, disables hybrid mode. Setting it to -1, enables hybrid - mode with no limit on the size of the thread local pool. Any other number enables hybrid - mode but sets a limit on the size of each thread's pool. + lifetime of connections to origin and reduce effective origin connection reuse. + + For a hybrid pool, the operation starts as the global pool, but sessons are returned + to the local thread pool if the global pool lock is not acquired rather than just + closing the origin connection as is the case in standard global mode. .. ts:cv:: CONFIG proxy.config.http.attach_server_session_to_client INT 0 :overridable: diff --git a/mgmt/RecordsConfig.cc b/mgmt/RecordsConfig.cc index e9de65fd7c9..30ecbcc8dff 100644 --- a/mgmt/RecordsConfig.cc +++ b/mgmt/RecordsConfig.cc @@ -376,8 +376,6 @@ static const RecordElement RecordsConfig[] = , {RECT_CONFIG, "proxy.config.http.server_session_sharing.pool", RECD_STRING, "thread", RECU_RESTART_TS, RR_NULL, RECC_NULL, nullptr, RECA_NULL} , - {RECT_CONFIG, "proxy.config.http.server_session_sharing.pool_hybrid_limit", RECD_INT, "0", RECU_RESTART_TS, RR_NULL, RECC_NULL, nullptr, RECA_NULL} - , {RECT_CONFIG, "proxy.config.http.default_buffer_size", RECD_INT, "8", RECU_DYNAMIC, RR_NULL, RECC_NULL, nullptr, RECA_NULL} , {RECT_CONFIG, "proxy.config.http.default_buffer_water_mark", RECD_INT, "32768", RECU_DYNAMIC, RR_NULL, RECC_NULL, nullptr, RECA_NULL} diff --git a/proxy/http/HttpConfig.cc b/proxy/http/HttpConfig.cc index 808e6423508..af647d308f1 100644 --- a/proxy/http/HttpConfig.cc +++ b/proxy/http/HttpConfig.cc @@ -165,7 +165,8 @@ http_config_enum_mask_read(const char *name, MgmtByte &value) static const ConfigEnumPair SessionSharingPoolStrings[] = { {TS_SERVER_SESSION_SHARING_POOL_GLOBAL, "global"}, - {TS_SERVER_SESSION_SHARING_POOL_THREAD, "thread"}}; + {TS_SERVER_SESSION_SHARING_POOL_THREAD, "thread"}, + {TS_SERVER_SESSION_SHARING_POOL_HYBRID, "hybrid"}}; int HttpConfig::m_id = 0; HttpConfigParams HttpConfig::m_master; @@ -1154,10 +1155,6 @@ HttpConfig::startup() http_config_enum_mask_read("proxy.config.http.server_session_sharing.match", c.oride.server_session_sharing_match); HttpEstablishStaticConfigStringAlloc(c.oride.server_session_sharing_match_str, "proxy.config.http.server_session_sharing.match"); http_config_enum_read("proxy.config.http.server_session_sharing.pool", SessionSharingPoolStrings, c.server_session_sharing_pool); - HttpEstablishStaticConfigByte(c.server_session_sharing_pool_hybrid_limit, - "proxy.config.http.server_session_sharing.pool_hybrid_limit"); - - httpSessionManager.set_hybrid_limit(c.server_session_sharing_pool_hybrid_limit); httpSessionManager.set_pool_type(c.server_session_sharing_pool); RecRegisterConfigUpdateCb("proxy.config.http.insert_forwarded", &http_insert_forwarded_cb, &c); @@ -1456,12 +1453,11 @@ HttpConfig::reconfigure() params->oride.flow_high_water_mark = params->oride.flow_low_water_mark = 0; } - params->oride.server_session_sharing_match = m_master.oride.server_session_sharing_match; - params->oride.server_session_sharing_match_str = ats_strdup(m_master.oride.server_session_sharing_match_str); - params->oride.server_min_keep_alive_conns = m_master.oride.server_min_keep_alive_conns; - params->server_session_sharing_pool = m_master.server_session_sharing_pool; - params->server_session_sharing_pool_hybrid_limit = m_master.server_session_sharing_pool_hybrid_limit; - params->oride.keep_alive_post_out = m_master.oride.keep_alive_post_out; + params->oride.server_session_sharing_match = m_master.oride.server_session_sharing_match; + params->oride.server_session_sharing_match_str = ats_strdup(m_master.oride.server_session_sharing_match_str); + params->oride.server_min_keep_alive_conns = m_master.oride.server_min_keep_alive_conns; + params->server_session_sharing_pool = m_master.server_session_sharing_pool; + params->oride.keep_alive_post_out = m_master.oride.keep_alive_post_out; params->oride.keep_alive_no_activity_timeout_in = m_master.oride.keep_alive_no_activity_timeout_in; params->oride.keep_alive_no_activity_timeout_out = m_master.oride.keep_alive_no_activity_timeout_out; diff --git a/proxy/http/HttpConfig.h b/proxy/http/HttpConfig.h index 5b585132ed9..06e1ccb2393 100644 --- a/proxy/http/HttpConfig.h +++ b/proxy/http/HttpConfig.h @@ -807,8 +807,7 @@ struct HttpConfigParams : public ConfigInfo { MgmtByte disallow_post_100_continue = 0; MgmtByte keepalive_internal_vc = 0; - MgmtByte server_session_sharing_pool = TS_SERVER_SESSION_SHARING_POOL_THREAD; - MgmtByte server_session_sharing_pool_hybrid_limit = 0; + MgmtByte server_session_sharing_pool = TS_SERVER_SESSION_SHARING_POOL_THREAD; OutboundConnTrack::GlobalConfig outbound_conntrack; diff --git a/proxy/http/HttpProxyAPIEnums.h b/proxy/http/HttpProxyAPIEnums.h index f0d84557210..d27b1abd1fe 100644 --- a/proxy/http/HttpProxyAPIEnums.h +++ b/proxy/http/HttpProxyAPIEnums.h @@ -54,6 +54,7 @@ typedef enum { typedef enum { TS_SERVER_SESSION_SHARING_POOL_GLOBAL, TS_SERVER_SESSION_SHARING_POOL_THREAD, + TS_SERVER_SESSION_SHARING_POOL_HYBRID } TSServerSessionSharingPoolType; // This is use to signal apidefs.h to not define these again. diff --git a/proxy/http/HttpSessionManager.cc b/proxy/http/HttpSessionManager.cc index 3b438b990a3..f0564cd1b5e 100644 --- a/proxy/http/HttpSessionManager.cc +++ b/proxy/http/HttpSessionManager.cc @@ -372,12 +372,14 @@ HttpSessionManager::acquire_session(Continuation * /* cont ATS_UNUSED */, sockad } // Otherwise, check the thread pool first - if (this->get_pool_type() == TS_SERVER_SESSION_SHARING_POOL_THREAD || this->get_hybrid_limit() != 0) { + if (this->get_pool_type() == TS_SERVER_SESSION_SHARING_POOL_THREAD || + this->get_pool_type() == TS_SERVER_SESSION_SHARING_POOL_HYBRID) { retval = _acquire_session(ip, hostname_hash, sm, match_style, TS_SERVER_SESSION_SHARING_POOL_THREAD); } // If you didn't get a match, and the global pool is an option go there. - if (retval != HSM_DONE && (TS_SERVER_SESSION_SHARING_POOL_GLOBAL == this->get_pool_type())) { + if (retval != HSM_DONE && (TS_SERVER_SESSION_SHARING_POOL_GLOBAL == this->get_pool_type() || + TS_SERVER_SESSION_SHARING_POOL_HYBRID == this->get_pool_type())) { retval = _acquire_session(ip, hostname_hash, sm, match_style, TS_SERVER_SESSION_SHARING_POOL_GLOBAL); } return retval; @@ -464,8 +466,7 @@ HttpSessionManager::release_session(Http1ServerSession *to_release) MUTEX_TRY_LOCK(lock, pool->mutex, ethread); if (lock.is_locked()) { pool->releaseSession(to_release); - } else if (to_release->sharing_pool == TS_SERVER_SESSION_SHARING_POOL_GLOBAL && - (m_hybrid_limit < 0 || ethread->server_session_pool->count() < m_hybrid_limit)) { + } else if (this->get_pool_type() == TS_SERVER_SESSION_SHARING_POOL_HYBRID) { // Try again with the thread pool to_release->sharing_pool = TS_SERVER_SESSION_SHARING_POOL_THREAD; return release_session(to_release); diff --git a/proxy/http/HttpSessionManager.h b/proxy/http/HttpSessionManager.h index 8d75ed28bda..66a98bded8d 100644 --- a/proxy/http/HttpSessionManager.h +++ b/proxy/http/HttpSessionManager.h @@ -116,11 +116,6 @@ class HttpSessionManager void init(); int main_handler(int event, void *data); void - set_hybrid_limit(int limit) - { - m_hybrid_limit = limit; - } - void set_pool_type(int pool_type) { m_pool_type = static_cast(pool_type); @@ -130,11 +125,6 @@ class HttpSessionManager { return m_pool_type; } - int - get_hybrid_limit() const - { - return m_hybrid_limit; - } private: /// Global pool, used if not per thread pools. @@ -142,7 +132,6 @@ class HttpSessionManager ServerSessionPool *m_g_pool = nullptr; HSMresult_t _acquire_session(sockaddr const *ip, CryptoHash const &hostname_hash, HttpSM *sm, TSServerSessionSharingMatchMask match_style, TSServerSessionSharingPoolType pool_type); - int m_hybrid_limit = 0; TSServerSessionSharingPoolType m_pool_type = TS_SERVER_SESSION_SHARING_POOL_THREAD; };