Permalink
Browse files

TS-1893 Add configuration options for server session matching.

  • Loading branch information...
1 parent 8456a6e commit 0d8bfb404df781637da317af68487d8b10671152 @SolidWallOfCode SolidWallOfCode committed Feb 14, 2014
View
@@ -1,6 +1,8 @@
-*- coding: utf-8 -*-
Changes with Apache Traffic Server 5.0.0
+ *) [TS-1893] Add more options to server session control.
+
*) [TS-2239] Initial ALPN TLS extension support.
*) [TS-2568] Better template messages.
@@ -24,3 +24,7 @@ Introduction
This is a documentation stub on how to hack Apache Traffic Server. Here we try to document things such as how to write
and run unit or regression tests or how to inspect the state of the core with a debugger.
+.. toctree::
+ :maxdepth: 1
+
+ config-var-impl.en
@@ -598,9 +598,41 @@ Value Effect
origin servers.
.. ts:cv:: CONFIG proxy.config.http.share_server_sessions INT 1
+ :deprecated:
Enables (``1``) or disables (``0``) the reuse of server sessions.
+.. ts:cv:: CONFIG proxy.config.http.server_session_sharing.match STRING both
+
+ Enable and set the ability to re-use server connections across client connections. The valid values are
+
+ none
+ Do not match, do not re-use server sessions.
+
+ ip
+ Re-use server sessions, check only that the IP address and port of the origin server matches.
+
+ host
+ Re-use server sessions, check only that the fully qualified domain name matches.
+
+ both
+ Re-use server sessions, but only if the IP address and fully qualified domain name match.
+
+ It is strongly recommended to use either *none* or *both* for this value unless you have a specific need to use *ip*
+ or *host*. The most common reason is virtual hosts that share an IP address in which case performance can be enhanced
+ if those sessions can be re-used. However, not all web servers support requests for different virtual hosts on the
+ same connection so use with caution.
+
+.. ts:cv:: CONFIG proxy.config.http.server_session_sharing.pool STRING thread
+
+ Control the scope of server session re-use if it is enabled by :ts:cv:`proxy.config.server_session_sharing.match`. The valid values are
+
+ global
+ Re-use sessions from a global pool of all server sessions.
+
+ thread
+ Re-use sessions from a per-thread pool.
+
.. ts:cv:: CONFIG proxy.config.http.record_heartbeat INT 0
:reloadable:
@@ -1196,15 +1228,15 @@ Cache Control
.. ts:cv:: CONFIG proxy.config.cache.limits.http.max_alts INT 5
- The maximum number of alternates that are allowed for any given URL.
+ The maximum number of alternates that are allowed for any given URL.
Disable by setting to 0. Note that this setting will not strictly enforce
- this if the variable ``proxy.config.cache.vary_on_user_agent`` is set
+ this if the variable ``proxy.config.cache.vary_on_user_agent`` is set
to 1 (by default it is 0).
.. ts:cv:: CONFIG proxy.config.cache.target_fragment_size INT 1048576
- Sets the target size of a contiguous fragment of a file in the disk cache. Accepts values that are powers of 2, e.g. 65536, 131072,
- 262144, 524288, 1048576, 2097152, etc. When setting this, consider that larger numbers could waste memory on slow connections,
+ Sets the target size of a contiguous fragment of a file in the disk cache. Accepts values that are powers of 2, e.g. 65536, 131072,
+ 262144, 524288, 1048576, 2097152, etc. When setting this, consider that larger numbers could waste memory on slow connections,
but smaller numbers could increase (waste) seeks.
RAM Cache
@@ -1406,8 +1438,8 @@ hostname to ``host_x.y.com``.
.. ts:cv:: CONFIG proxy.config.dns.validate_query_name INT 0
- When enabled (1) provides additional resilience against DNS forgery (for instance
- in DNS Injection attacks), particularly in forward or transparent proxies, but
+ When enabled (1) provides additional resilience against DNS forgery (for instance
+ in DNS Injection attacks), particularly in forward or transparent proxies, but
requires that the resolver populates the queries section of the response properly.
HostDB
@@ -428,6 +428,10 @@ RecordElement RecordsConfig[] = {
,
{RECT_CONFIG, "proxy.config.http.share_server_sessions", RECD_INT, "2", RECU_RESTART_TS, RR_NULL, RECC_NULL, NULL, RECA_NULL}
,
+ {RECT_CONFIG, "proxy.config.http.server_session_sharing.match", RECD_STRING, "both", RECU_RESTART_TS, RR_NULL, RECC_NULL, NULL, RECA_NULL}
+ ,
+ {RECT_CONFIG, "proxy.config.http.server_session_sharing.pool", RECD_STRING, "thread", RECU_RESTART_TS, RR_NULL, RECC_NULL, NULL, RECA_NULL}
+ ,
{RECT_CONFIG, "proxy.config.http.record_heartbeat", RECD_INT, "0", RECU_DYNAMIC, RR_NULL, RECC_NULL, NULL, RECA_NULL}
,
{RECT_CONFIG, "proxy.config.http.record_tcp_mem_hit", RECD_INT, "0", RECU_DYNAMIC, RR_NULL, RECC_NULL, NULL, RECA_NULL}
View
@@ -2976,7 +2976,7 @@ TSMimeHdrFieldNext(TSMBuffer bufp, TSMLoc hdr, TSMLoc field)
return TS_NULL_MLOC;
if (f->is_live()) {
MIMEFieldSDKHandle *h = sdk_alloc_field_handle(bufp, handle->mh);
-
+
h->field_ptr = f;
return reinterpret_cast<TSMLoc>(h);
}
@@ -3913,7 +3913,7 @@ TSCacheKeyDigestSet(TSCacheKey key, const char *input, int length)
sdk_assert(sdk_sanity_check_cachekey(key) == TS_SUCCESS);
sdk_assert(sdk_sanity_check_iocore_structure((void*) input) == TS_SUCCESS);
sdk_assert(length > 0);
-
+
if (((CacheInfo *) key)->magic != CACHE_INFO_MAGIC_ALIVE)
return TS_ERROR;
@@ -4617,7 +4617,7 @@ TSHttpTxnServerReqGet(TSHttpTxn txnp, TSMBuffer *bufp, TSMLoc *obj)
*obj = reinterpret_cast<TSMLoc>(hptr->m_http);
sdk_sanity_check_mbuffer(*bufp);
return TS_SUCCESS;
- }
+ }
return TS_ERROR;
}
@@ -5179,7 +5179,7 @@ TSHttpTxnTransformRespGet(TSHttpTxn txnp, TSMBuffer *bufp, TSMLoc *obj)
*(reinterpret_cast<HTTPHdr**>(bufp)) = hptr;
*obj = reinterpret_cast<TSMLoc>(hptr->m_http);
return sdk_sanity_check_mbuffer(*bufp);
- }
+ }
return TS_ERROR;
}
@@ -5200,7 +5200,7 @@ sockaddr const*
TSHttpTxnClientAddrGet(TSHttpTxn txnp)
{
sdk_assert(sdk_sanity_check_txn(txnp) == TS_SUCCESS);
-
+
TSHttpSsn ssnp = TSHttpTxnSsnGet(txnp);
return TSHttpSsnClientAddrGet(ssnp);
}
@@ -5221,7 +5221,7 @@ sockaddr const*
TSHttpTxnIncomingAddrGet(TSHttpTxn txnp)
{
sdk_assert(sdk_sanity_check_txn(txnp) == TS_SUCCESS);
-
+
TSHttpSsn ssnp = TSHttpTxnSsnGet(txnp);
return TSHttpSsnIncomingAddrGet(ssnp);
}
@@ -7265,7 +7265,7 @@ TSReturnCode
TSAIOWrite(int fd, off_t offset, char* buf, const size_t bufSize, TSCont contp)
{
sdk_assert(sdk_sanity_check_iocore_structure (contp) == TS_SUCCESS);
-
+
Continuation* pCont = (Continuation*) contp;
AIOCallback* pAIO = new_AIOCallback();
@@ -7305,7 +7305,7 @@ TSRecordDump(TSRecordType rec_type, TSRecordDumpCb callback, void *edata)
RecDumpRecords((RecT)rec_type, (RecDumpEntryCb)callback, edata);
}
-/* ability to skip the remap phase of the State Machine
+/* ability to skip the remap phase of the State Machine
this only really makes sense in TS_HTTP_READ_REQUEST_HDR_HOOK
*/
void
@@ -7352,7 +7352,14 @@ _conf_to_memberp(TSOverridableConfigKey conf, HttpSM* sm, OverridableDataType *t
ret = &sm->t_state.txn_conf->keep_alive_post_out;
break;
case TS_CONFIG_HTTP_SHARE_SERVER_SESSIONS:
- ret = &sm->t_state.txn_conf->share_server_sessions;
+ ink_assert("Deprecated config key value - TS_CONFIG_HTTP_SHARE_SERVER_SESSIONS");
+// ret = &sm->t_state.txn_conf->share_server_sessions;
+ break;
+ case TS_CONFIG_HTTP_SERVER_SESSION_SHARING_POOL:
+ ret = &sm->t_state.txn_conf->server_session_sharing_pool;
+ break;
+ case TS_CONFIG_HTTP_SERVER_SESSION_SHARING_MATCH:
+ ret = &sm->t_state.txn_conf->server_session_sharing_match;
break;
case TS_CONFIG_NET_SOCK_RECV_BUFFER_SIZE_OUT:
typ = OVERRIDABLE_TYPE_INT;
@@ -7639,6 +7646,26 @@ TSHttpTxnConfigIntSet(TSHttpTxn txnp, TSOverridableConfigKey conf, TSMgmtInt val
s->t_state.setup_per_txn_configs();
+ // 4.1.X backwards compatibility - remove for 5.0
+ if (TS_CONFIG_HTTP_SHARE_SERVER_SESSIONS == conf) {
+ switch (value) {
+ case 0: s->t_state.txn_conf->server_session_sharing_match = TS_SERVER_SESSION_SHARING_MATCH_NONE; break;
+ case 1:
+ s->t_state.txn_conf->server_session_sharing_match = TS_SERVER_SESSION_SHARING_MATCH_BOTH;
+ s->t_state.txn_conf->server_session_sharing_pool = TS_SERVER_SESSION_SHARING_POOL_GLOBAL;
+ break;
+ case 2:
+ s->t_state.txn_conf->server_session_sharing_match = TS_SERVER_SESSION_SHARING_MATCH_BOTH;
+ s->t_state.txn_conf->server_session_sharing_pool = TS_SERVER_SESSION_SHARING_POOL_THREAD;
+ break;
+ default:
+ return TS_ERROR;
+ break; // make the compiler happy
+ }
+ return TS_SUCCESS;
+ }
+ // end 4.1.X BC
+
void *dest = _conf_to_memberp(conf, s, &type);
if (!dest)
@@ -7664,8 +7691,26 @@ TSHttpTxnConfigIntGet(TSHttpTxn txnp, TSOverridableConfigKey conf, TSMgmtInt *va
sdk_assert(sdk_sanity_check_txn(txnp) == TS_SUCCESS);
sdk_assert(sdk_sanity_check_null_ptr((void*)value) == TS_SUCCESS);
+ HttpSM *s = reinterpret_cast<HttpSM*>(txnp);
OverridableDataType type;
- void* src = _conf_to_memberp(conf, (HttpSM*)txnp, &type);
+
+ // 4.1.X backwards compatibility - remove for 5.0
+ if (TS_CONFIG_HTTP_SHARE_SERVER_SESSIONS == conf) {
+ if (s->t_state.txn_conf->server_session_sharing_match == TS_SERVER_SESSION_SHARING_MATCH_NONE)
+ *value = 0;
+ else if (s->t_state.txn_conf->server_session_sharing_match == TS_SERVER_SESSION_SHARING_MATCH_BOTH &&
+ s->t_state.txn_conf->server_session_sharing_pool == TS_SERVER_SESSION_SHARING_POOL_GLOBAL)
+ *value = 1;
+ else if (s->t_state.txn_conf->server_session_sharing_match == TS_SERVER_SESSION_SHARING_MATCH_BOTH &&
+ s->t_state.txn_conf->server_session_sharing_pool == TS_SERVER_SESSION_SHARING_POOL_THREAD)
+ *value = 2;
+ else
+ return TS_ERROR;
+ return TS_SUCCESS;
+ }
+ // end 4.1.X BC
+
+ void* src = _conf_to_memberp(conf, s, &type);
if (!src)
return TS_ERROR;
@@ -8040,6 +8085,10 @@ TSHttpTxnConfigFind(const char* name, int length, TSOverridableConfigKey *conf,
else if (!strncmp(name, "proxy.config.http.cache.max_open_read_retries", length))
cnf = TS_CONFIG_HTTP_CACHE_MAX_OPEN_READ_RETRIES;
break;
+ case 'l':
+ if (0 == strncmp(name, "proxy.config.http.server_session_sharing.pool", length))
+ cnf = TS_CONFIG_HTTP_SERVER_SESSION_SHARING_POOL;
+ break;
}
break;
@@ -8069,6 +8118,10 @@ TSHttpTxnConfigFind(const char* name, int length, TSOverridableConfigKey *conf,
if (!strncmp(name, "proxy.config.http.forward.proxy_auth_to_parent", length))
cnf = TS_CONFIG_HTTP_FORWARD_PROXY_AUTH_TO_PARENT;
break;
+ case 'h':
+ if (0 == strncmp(name, "proxy.config.http.server_session_sharing.match", length))
+ cnf = TS_CONFIG_HTTP_SERVER_SESSION_SHARING_MATCH;
+ break;
}
break;
View
@@ -6096,8 +6096,7 @@ cache_hook_handler(TSCont contp, TSEvent event, void *edata)
TSSkipRemappingSet(txnp,1);
TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
break;
-
-
+
case TS_EVENT_HTTP_CACHE_LOOKUP_COMPLETE:
{
int lookup_status;
@@ -6259,7 +6258,7 @@ EXCLUSIVE_REGRESSION_TEST(SDK_API_HttpTxnCache) (RegressionTest * test, int /* a
socktest->first_time = true;
socktest->magic = MAGIC_ALIVE;
TSContDataSet(cont, socktest);
-
+
TSHttpHookAdd(TS_HTTP_READ_REQUEST_HDR_HOOK, cont);
/* Register to HTTP hooks that are called in case of a cache MISS */
TSHttpHookAdd(TS_HTTP_READ_CACHE_HDR_HOOK, cont);
@@ -6752,7 +6751,7 @@ transform_hook_handler(TSCont contp, TSEvent event, void *edata)
} else {
SDK_RPRINT(data->test, "TSHttpTxnTransformedResponseCache", "TestCase1", TC_FAIL, "Value's Mismatch");
}
-
+
/* Note: response is available using test->browser->response pointer */
*(data->pstatus) = REGRESSION_TEST_PASSED;
if (data->browser1->status != REQUEST_SUCCESS) {
@@ -6835,9 +6834,9 @@ EXCLUSIVE_REGRESSION_TEST(SDK_API_HttpTxnTransform) (RegressionTest * test, int
/* Prepare the buffer to be appended to responses */
load(TRANSFORM_APPEND_STRING);
-
+
TSHttpHookAdd(TS_HTTP_READ_REQUEST_HDR_HOOK, cont); //so we can skip remapping
-
+
/* Register to HTTP hooks that are called in case of a cache MISS */
TSHttpHookAdd(TS_HTTP_READ_RESPONSE_HDR_HOOK, cont);
@@ -7345,6 +7344,8 @@ const char *SDK_Overridable_Configs[TS_CONFIG_LAST_ENTRY] = {
"proxy.config.http.keep_alive_enabled_out",
"proxy.config.http.keep_alive_post_out",
"proxy.config.http.share_server_sessions",
+ "proxy.config.http.server_session_sharing.pool",
+ "proxy.config.http.server_session_sharing.match",
"proxy.config.net.sock_recv_buffer_size_out",
"proxy.config.net.sock_send_buffer_size_out",
"proxy.config.net.sock_option_flag_out",
@@ -7433,7 +7434,7 @@ REGRESSION_TEST(SDK_API_OVERRIDABLE_CONFIGS) (RegressionTest * test, int /* atyp
const char *sval_read;
const char *test_string = "The Apache Traffic Server";
int len;
-
+
s->init();
@@ -7457,6 +7458,9 @@ REGRESSION_TEST(SDK_API_OVERRIDABLE_CONFIGS) (RegressionTest * test, int /* atyp
switch (type) {
case TS_RECORDDATATYPE_INT:
ival_rand = generator.random() % 126; // to fit in a signed byte
+ // 4.1 backwards compatibility - remove for 5.0
+ if (TS_CONFIG_HTTP_SHARE_SERVER_SESSIONS == key) ival_rand %= 2;
+ // end BC
TSHttpTxnConfigIntSet(txnp, key, ival_rand);
TSHttpTxnConfigIntGet(txnp, key, &ival_read);
if (ival_rand != ival_read) {
View
@@ -520,6 +520,27 @@ extern "C"
AFTER_BODY
} TSFetchWakeUpOptions;
+#ifndef _HTTP_PROXY_API_ENUMS_H_
+#define _HTTP_PROXY_API_ENUMS_H_
+ /// Server session sharing values - match
+ /// Must be identical to definition in HttpProxyAPIEnums.h
+ typedef enum
+ {
+ TS_SERVER_SESSION_SHARING_MATCH_NONE,
+ TS_SERVER_SESSION_SHARING_MATCH_BOTH,
+ TS_SERVER_SESSION_SHARING_MATCH_IP,
+ TS_SERVER_SESSION_SHARING_MATCH_HOST
+ } TSServerSessionSharingMatchType;
+
+ /// Server session sharing values - pool
+ /// Must be identical to definition in HttpProxyAPIEnums.h
+ typedef enum
+ {
+ TS_SERVER_SESSION_SHARING_POOL_GLOBAL,
+ TS_SERVER_SESSION_SHARING_POOL_THREAD
+ } TSServerSessionSharingPoolType;
+#endif
+
/* librecords types */
/* The values of this enum must match enum RecT in I_RecDefs.h */
@@ -612,7 +633,9 @@ extern "C"
TS_CONFIG_HTTP_KEEP_ALIVE_ENABLED_IN,
TS_CONFIG_HTTP_KEEP_ALIVE_ENABLED_OUT,
TS_CONFIG_HTTP_KEEP_ALIVE_POST_OUT,
- TS_CONFIG_HTTP_SHARE_SERVER_SESSIONS,
+ TS_CONFIG_HTTP_SHARE_SERVER_SESSIONS, // DEPRECATED
+ TS_CONFIG_HTTP_SERVER_SESSION_SHARING_POOL,
+ TS_CONFIG_HTTP_SERVER_SESSION_SHARING_MATCH,
TS_CONFIG_NET_SOCK_RECV_BUFFER_SIZE_OUT,
TS_CONFIG_NET_SOCK_SEND_BUFFER_SIZE_OUT,
TS_CONFIG_NET_SOCK_OPTION_FLAG_OUT,
Oops, something went wrong.

0 comments on commit 0d8bfb4

Please sign in to comment.