From d51060df662fc16478983222c739598286337024 Mon Sep 17 00:00:00 2001 From: Kyle Vosper Date: Fri, 7 Jun 2019 11:08:51 +0100 Subject: [PATCH 01/13] Update overview document. We dont really need the without-comments section, I think --- docs/user-guide/configure-overview.md | 332 ++++++++++++-------------- 1 file changed, 148 insertions(+), 184 deletions(-) diff --git a/docs/user-guide/configure-overview.md b/docs/user-guide/configure-overview.md index afee692b26..287896ad35 100644 --- a/docs/user-guide/configure-overview.md +++ b/docs/user-guide/configure-overview.md @@ -12,192 +12,156 @@ using environment variables with the same name as the property. ### Example styx-config ```yaml - # A string uniquely identifying the host running the application, must be different for all running instances of the application - # the default value is suitable only for non clustered environments - jvmRouteName: "${jvm.route:noJvmRouteSet}" - - - proxy: - connectors: - - type: http - # Server port for Styx proxy. - port: 8080 - - # 0 -> availableProcessors / 2 threads will be used - bossThreadsCount: 1 - - # styx client worker threads are those performing all the asynchronous I/O operation to the backend origins. - # 0 -> availableProcessors / 2 threads will be used - clientWorkerThreadsCount: 0 - - # Worker threads are those performing all the asynchronous I/O operation on the inbound channel. - # 0 -> availableProcessors / 2 threads will be used - - workerThreadsCount: 0 - - tcpNoDelay: true - nioReuseAddress: true - nioKeepAlive: true - maxInitialLength: 4096 - maxHeaderSize: 8192 - maxChunkSize: 8192 - maxContentLength: 65536 - - - # A timeout for idle persistent connections, in milliseconds. - keepAliveTimeoutMillis: 12000 - - # Time in milliseconds Styx Proxy Service waits for an incoming request from client - # before replying with 408 Request Timeout. - requestTimeoutMillis: 12000 - - - admin: - connectors: - - type: http - # Server port for Styx admin interface. - port: 9000 - - # Number of threads for handling incoming connections on admin interface. 0 -> availableProcessors / 2 threads will be used. - bossThreadsCount: 1 - - # Number of worker threads for admin interface - # Worker threads are those performing all the asynchronous I/O operation on the inbound channel. - # 0 -> availableProcessors / 2 threads will be used - workerThreadsCount: 1 - - tcpNoDelay: true - nioReuseAddress: true - nioKeepAlive: true - maxInitialLength: 4096 - maxHeaderSize: 8192 - maxChunkSize: 8192 - maxContentLength: 65536 - - # Whether to cache the generated JSON for the /admin/metrics and /admin/jvm pages - metricsCache: - enabled: true - expirationMillis: 10000 - - loadBalancing: - strategy: #Check load balancing documentation for all the possible strategies - factory: {class: "com.hotels.styx.client.loadbalancing.strategies.PowerOfTwoStrategy$Factory"} - - - - adaptive: - # Adaptive loadbalancer warm-up count. The count is the number of requests that has to hit the - # load balancer before it upswitches from round robin strategy to least response time strategy. - warmupCount: 100 - - metrics: - graphite: - enabled: true - # Host of the Graphite endpoint. Overrides the property from CoreFoundation +# A string uniquely identifying the host running the application, must be different for all running instances of the application +# the default value is suitable only for non clustered environments +jvmRouteName: "${jvm.route:noJvmRouteSet}" + +proxy: + connectors: + http: + # Server port for Styx proxy. + port: 8080 + https: + port: 8443 + sslProvider: OPENSSL + sessionTimeoutMillis: 300000 + sessionCacheSize: 20000 + protocols: + - TLSv1.2 + cipherSuites: + - TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 + - TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 + - TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 + - TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 + # 0 -> availableProcessors / 2 threads will be used + bossThreadsCount: 1 + # styx client worker threads are those performing all the asynchronous I/O operation to the backend origins. + # 0 -> availableProcessors / 2 threads will be used + clientWorkerThreadsCount: 0 + # Worker threads are those performing all the asynchronous I/O operation on the inbound channel. + # 0 -> availableProcessors / 2 threads will be used + workerThreadsCount: 0 + tcpNoDelay: true + nioReuseAddress: true + nioKeepAlive: true + maxInitialLength: 4096 + maxHeaderSize: 65536 + maxChunkSize: 8192 + maxContentLength: 65536 + # Time in milliseconds Styx Proxy Service waits for an incoming request from client + # before replying with 408 Request Timeout. + requestTimeoutMillis: 12000 + # A timeout for idle persistent connections, in milliseconds. + keepAliveTimeoutMillis: 120000 + maxConnectionsCount: 4000 + + +admin: + connectors: + http: + # Server port for Styx admin interface. + port: 9000 + # Number of threads for handling incoming connections on admin interface. 0 -> availableProcessors / 2 threads will be used. + bossThreadsCount: 1 + # Number of worker threads for admin interface + # Worker threads are those performing all the asynchronous I/O operation on the inbound channel. + # 0 -> availableProcessors / 2 threads will be used + workerThreadsCount: 2 + tcpNoDelay: true + nioReuseAddress: true + nioKeepAlive: true + maxInitialLength: 4096 + maxHeaderSize: 8192 + maxChunkSize: 8192 + maxContentLength: 65536 + + # Whether to cache the generated JSON for the /admin/metrics and /admin/jvm pages + metricsCache: + enabled: true + expirationMillis: 10000 + +services: + factories: + backendServiceRegistry: + class: "com.hotels.styx.proxy.backends.file.FileBackedBackendServicesRegistry$Factory" + config: + originsFile: "${STYX_HOME}/conf/env-development/origins.yaml" + graphite: + class: "com.hotels.styx.metrics.reporting.graphite.GraphiteReporterServiceFactory" + config: + prefix: "my.metrics" + # Host of the Graphite endpoint. host: "destination.host" - - # Port of the Graphite endpoint. Overrides the property from CoreFoundation + # Port of the Graphite endpoint. port: 2003 - # Graphite reporting interval in milliseconds - intervalMillis: 5000 - jmx: - # Enable reporting of metrics via JMX. Overrides the property from CoreFoundation - enabled: true - - request-logging: - # Enable logging of requests and responses (with requestId to match them up). - # Logs are produced on server and origin side, so there is an information on - # how the server-side (inbound) and origin-side (outbound) request/response look like. - # In long format log entry contains additionally headers and cookies. - inbound: - enabled: true - longFormat: true - outbound: - enabled: true - longFormat: true - - # Determines the format of the response info header - responseInfoHeaderFormat: {INSTANCE};{REQUEST_ID} + intervalMillis: 15000 + jmx: + class: "com.hotels.styx.metrics.reporting.jmx.JmxReporterServiceFactory" + config: + domain: "com.hotels.styx" + +retrypolicy: + policy: + factory: + class: "com.hotels.styx.client.retry.RetryPolicyFactory" + config: {count: 2} + +loadBalancing: + strategy: #Check load balancing documentation for all the possible strategies + factory: {class: "com.hotels.styx.client.loadbalancing.strategies.PowerOfTwoStrategy$Factory"} + +originRestrictionCookie: restrict_origins + + + +request-logging: + # Enable logging of requests and responses (with requestId to match them up). + # Logs are produced on server and origin side, so there is an information on + # how the server-side (inbound) and origin-side (outbound) request/response look like. + # In long format log entry contains additionally headers and cookies. + inbound: + enabled: ${REQUEST_LOGGING_INBOUND_ENABLED:false} + longFormat: ${REQUEST_LOGGING_INBOUND_LONG_FORMAT:false} + outbound: + enabled: ${REQUEST_LOGGING_OUTBOUND_ENABLED:false} + longFormat: ${REQUEST_LOGGING_OUTBOUND_LONG_FORMAT:false} + +# Configures the names of the headers that Styx adds to messages it proxies (see headers.md) +# If not configured, defaults will be used. +styxHeaders: + styxInfo: + name: "X-Styx-Info" + format: "{INSTANCE};{REQUEST_ID}" + originId: + name: "X-Styx-Origin-Id" + requestId: + name: "X-Styx-Request-Id" - # Configures the names of the headers that Styx adds to messages it proxies (see headers.md) - # If not configured, defaults will be used. - styxHeaders: - styxInfo: - name: "X-Styx-Info" - format: "{INSTANCE};{REQUEST_ID}" - originId: - name: "X-Styx-Origin-Id" - requestId: - name: "X-Styx-Request-Id" - - # Enables request tracking. This is a debugging feature that shows information about - # each proxied request. Accepts a boolean value (true/false). - requestTracking: false +# Enables request tracking. This is a debugging feature that shows information about +# each proxied request. Accepts a boolean value (true/false). +requestTracking: false + +# Allow and Encode the list of unwise chars. +url: + encoding: + unwiseCharactersToEncode: "|,;,{,}" + +plugins: + active: plugin1, plugin2 + all: + plugin1: + factory: + class: "foo.bar.Plugin1Factory" + classPath: "/foo/bar/" + config: + foo: "bar" + bar: "foo" + plugin2: + factory: + class: "pack.age.Plugin2Factory" + classPath: "/foo/bar/" + config: + some: "config" + et: "cetera" ``` - -Without the comments, it looks like this: -```yaml - jvmRouteName: "${jvm.route:noJvmRouteSet}" - proxy: - connectors: - - type: http - port: 8080 - bossThreadsCount: 1 - clientWorkerThreadsCount: 0 - workerThreadsCount: 0 - tcpNoDelay: true - nioReuseAddress: true - nioKeepAlive: true - maxInitialLength: 4096 - maxHeaderSize: 8192 - maxChunkSize: 8192 - maxContentLength: 65536 - requestTimeoutMillis: 12000 - - admin: - connectors: - - type: http - port: 9000 - bossThreadsCount: 1 - workerThreadsCount: 1 - tcpNoDelay: true - nioReuseAddress: true - nioKeepAlive: true - maxInitialLength: 4096 - maxHeaderSize: 8192 - maxChunkSize: 8192 - maxContentLength: 65536 - metricsCache: - enabled: true - expirationMillis: 10000 - - loadBalancing: - strategy: "ADAPTIVE" - adaptive: - warmupCount: 100 - - metrics: - graphite: - enabled: true - host: "destination.host" - port: 2003 - intervalMillis: 5000 - jmx: - enabled: true - - request-logging: - inbound: - enabled: true - - styxHeaders: - styxInfo: - name: "X-Styx-Info" - format: "{INSTANCE};{REQUEST_ID}" - originId: - name: "X-Styx-Origin-Id" - requestId: - name: "X-Styx-Request-Id" - - requestTracking: false -``` \ No newline at end of file From 8aa01534ed946a9bc8ec40de56b591e80f39f6bc Mon Sep 17 00:00:00 2001 From: Kyle Vosper Date: Fri, 7 Jun 2019 14:47:27 +0100 Subject: [PATCH 02/13] Add some comments --- docs/user-guide/configure-overview.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/user-guide/configure-overview.md b/docs/user-guide/configure-overview.md index 287896ad35..380b0cb351 100644 --- a/docs/user-guide/configure-overview.md +++ b/docs/user-guide/configure-overview.md @@ -80,6 +80,8 @@ admin: enabled: true expirationMillis: 10000 +# A list of services that Styx should run upon starting. Any service that can be constructed by a factory extending +# com.hotels.styx.api.configuration.ServiceFactory can be included here services: factories: backendServiceRegistry: @@ -113,8 +115,6 @@ loadBalancing: originRestrictionCookie: restrict_origins - - request-logging: # Enable logging of requests and responses (with requestId to match them up). # Logs are produced on server and origin side, so there is an information on @@ -147,13 +147,18 @@ url: encoding: unwiseCharactersToEncode: "|,;,{,}" +# Configure plugins that Styx will use plugins: + # List of plugin IDs from the configured plugins under "all". Only the plugins listed in "active" will be loaded. active: plugin1, plugin2 all: plugin1: factory: + # the name of a class that implements com.hotels.styx.api.plugins.spi.PluginFactory class: "foo.bar.Plugin1Factory" + # the path (directory or jar) from which the factory class can be loaded classPath: "/foo/bar/" + # configuration for the plugin. the exact structure is up to the plugin creator config: foo: "bar" bar: "foo" From ae1e0ee15e9435ca0df63b00e00512471bfde608 Mon Sep 17 00:00:00 2001 From: Kyle Vosper Date: Mon, 10 Jun 2019 10:05:29 +0100 Subject: [PATCH 03/13] Small update --- docs/user-guide/configure-load-balancing.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/user-guide/configure-load-balancing.md b/docs/user-guide/configure-load-balancing.md index b612e00d3a..34920cb6de 100644 --- a/docs/user-guide/configure-load-balancing.md +++ b/docs/user-guide/configure-load-balancing.md @@ -2,6 +2,7 @@ Styx supports three load balancing strategies: + - Power of Two - Round robin - Busy From 8b3fa53d36b406e35eb100b195f4ee9e43b0dc74 Mon Sep 17 00:00:00 2001 From: Kyle Vosper Date: Mon, 10 Jun 2019 13:20:31 +0100 Subject: [PATCH 04/13] Changes requested in code review --- .../conf/environment/styx-config-alternative.yml | 9 ++------- .../test/resources/conf/environment/styx-config-test.yml | 9 ++------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/components/proxy/src/test/resources/conf/environment/styx-config-alternative.yml b/components/proxy/src/test/resources/conf/environment/styx-config-alternative.yml index 97b27ee386..ac196603b1 100644 --- a/components/proxy/src/test/resources/conf/environment/styx-config-alternative.yml +++ b/components/proxy/src/test/resources/conf/environment/styx-config-alternative.yml @@ -33,13 +33,8 @@ admin: maxContentLength: 65536 loadBalancing: - strategy: adaptive - strategies: - adaptive: - factory: {class: "com.hotels.styx.client.loadbalancing.strategies.AdaptiveStrategy$Factory"} - warmUpCount: 100 - rr: - factory: {class: "com.hotels.styx.client.loadbalancing.strategies.RoundRobinStrategy$Factory"} + strategy: + factory: {class: "com.hotels.styx.client.loadbalancing.strategies.PowerOfTwoStrategy$Factory"} metrics: graphite: diff --git a/components/proxy/src/test/resources/conf/environment/styx-config-test.yml b/components/proxy/src/test/resources/conf/environment/styx-config-test.yml index 10f200961f..fa8c8d23fa 100644 --- a/components/proxy/src/test/resources/conf/environment/styx-config-test.yml +++ b/components/proxy/src/test/resources/conf/environment/styx-config-test.yml @@ -33,13 +33,8 @@ admin: maxContentLength: 65536 loadBalancing: - strategy: adaptive - strategies: - adaptive: - factory: {class: "com.hotels.styx.client.loadbalancing.strategies.StrategyFactory"} - warmUpCount: 100 - rr: - factory: {class: "com.hotels.styx.client.loadbalancing.strategies.StrategyFactory"} + strategy: + factory: {class: "com.hotels.styx.client.loadbalancing.strategies.PowerOfTwoStrategy$Factory"} metrics: graphite: From 4105ff05f79c3910bed6d526ffb9b7febbba5e72 Mon Sep 17 00:00:00 2001 From: kvosper Date: Mon, 10 Jun 2019 13:32:12 +0100 Subject: [PATCH 05/13] Update docs/user-guide/configure-load-balancing.md Co-Authored-By: David Latorre --- docs/user-guide/configure-load-balancing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user-guide/configure-load-balancing.md b/docs/user-guide/configure-load-balancing.md index 34920cb6de..0292b6fb58 100644 --- a/docs/user-guide/configure-load-balancing.md +++ b/docs/user-guide/configure-load-balancing.md @@ -2,7 +2,7 @@ Styx supports three load balancing strategies: - - Power of Two + - Power of two - Round robin - Busy From 3749eb329670e8ca93bb6dce5e15ac365dd07c2e Mon Sep 17 00:00:00 2001 From: kvosper Date: Mon, 10 Jun 2019 13:32:24 +0100 Subject: [PATCH 06/13] Update docs/user-guide/configure-load-balancing.md Co-Authored-By: David Latorre --- docs/user-guide/configure-load-balancing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user-guide/configure-load-balancing.md b/docs/user-guide/configure-load-balancing.md index 0292b6fb58..c65fdaeba2 100644 --- a/docs/user-guide/configure-load-balancing.md +++ b/docs/user-guide/configure-load-balancing.md @@ -3,7 +3,7 @@ Styx supports three load balancing strategies: - Power of two - - Round robin + - Round-robin - Busy Styx also provides a mechanism to bypass the load balancer and force From 81119bb9ef9bdb2958850d7d2744b7a1f40aa0a5 Mon Sep 17 00:00:00 2001 From: Kyle Vosper Date: Mon, 10 Jun 2019 15:13:03 +0100 Subject: [PATCH 07/13] WIP - responding to review comments --- .../styx/server/HttpsConnectorConfig.java | 25 +++++++++++++++++++ .../styx/server/ServerEventLoopFactory.java | 12 +++++++-- .../styx/server/netty/NettyServerConfig.java | 5 ++++ docs/user-guide/configure-overview.md | 17 +++++++++---- 4 files changed, 52 insertions(+), 7 deletions(-) diff --git a/components/server/src/main/java/com/hotels/styx/server/HttpsConnectorConfig.java b/components/server/src/main/java/com/hotels/styx/server/HttpsConnectorConfig.java index 13d64dcd74..40acd8ab9e 100644 --- a/components/server/src/main/java/com/hotels/styx/server/HttpsConnectorConfig.java +++ b/components/server/src/main/java/com/hotels/styx/server/HttpsConnectorConfig.java @@ -60,6 +60,11 @@ public String type() { return "https"; } + /** + * Implementation of SSL functionality, can be JDK or OPENSSL. + * + * @return SSL provider + */ public String sslProvider() { return sslProvider; } @@ -72,18 +77,38 @@ public String certificateKeyFile() { return certificateKeyFile; } + /** + * The cipher suites to enable, in the order of preference. + * + * @return cipher suites + */ public List ciphers() { return cipherSuites; } + /** + * Timeout for the cached SSL session objects. + * + * @return timeout + */ public long sessionTimeoutMillis() { return sessionTimeoutMillis; } + /** + * Size of the cache used for storing SSL session objects. + * + * @return cache size + */ public long sessionCacheSize() { return sessionCacheSize; } + /** + * The TLS protocol versions to enable. + * + * @return protocols + */ public List protocols() { return protocols; } diff --git a/components/server/src/main/java/com/hotels/styx/server/ServerEventLoopFactory.java b/components/server/src/main/java/com/hotels/styx/server/ServerEventLoopFactory.java index 9c2c9a2c1d..9c278719ef 100644 --- a/components/server/src/main/java/com/hotels/styx/server/ServerEventLoopFactory.java +++ b/components/server/src/main/java/com/hotels/styx/server/ServerEventLoopFactory.java @@ -20,12 +20,20 @@ /** * Factory for creating netty channel implementation based on the current system. - * */ public interface ServerEventLoopFactory { - + /** + * EventLoopGroup for establishing new channels. + * + * @return event loop group + */ EventLoopGroup newBossEventLoopGroup(); + /** + * EventLoopGroup for handling events on channels. + * + * @return event loop group + */ EventLoopGroup newWorkerEventLoopGroup(); Class serverChannelClass(); diff --git a/components/server/src/main/java/com/hotels/styx/server/netty/NettyServerConfig.java b/components/server/src/main/java/com/hotels/styx/server/netty/NettyServerConfig.java index dce1c0be51..9afa084de3 100644 --- a/components/server/src/main/java/com/hotels/styx/server/netty/NettyServerConfig.java +++ b/components/server/src/main/java/com/hotels/styx/server/netty/NettyServerConfig.java @@ -113,6 +113,11 @@ public Iterable connectors() { return connectors; } + /** + * Number of threads for establishing new channels. + * + * @return number of threads + */ public int bossThreadsCount() { return this.bossThreadsCount; } diff --git a/docs/user-guide/configure-overview.md b/docs/user-guide/configure-overview.md index 380b0cb351..4ae8ef7ef7 100644 --- a/docs/user-guide/configure-overview.md +++ b/docs/user-guide/configure-overview.md @@ -19,27 +19,34 @@ jvmRouteName: "${jvm.route:noJvmRouteSet}" proxy: connectors: http: - # Server port for Styx proxy. + # Port for accessing the proxy server over HTTP. port: 8080 https: + # Port for accessing the proxy server over HTTPS. port: 8443 + # Implementation of SSL functionality, can be JDK or OPENSSL. sslProvider: OPENSSL + # Timeout for the cached SSL session objects. sessionTimeoutMillis: 300000 + # Size of the cache used for storing SSL session objects. sessionCacheSize: 20000 + # The TLS protocol versions to enable. protocols: - TLSv1.2 + # The cipher suites to enable, in the order of preference. cipherSuites: - TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 - TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 - TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 - TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 - # 0 -> availableProcessors / 2 threads will be used + # Boss threads are those establishing new channels. + # If set to 0, availableProcessors / 2 threads will be used bossThreadsCount: 1 # styx client worker threads are those performing all the asynchronous I/O operation to the backend origins. - # 0 -> availableProcessors / 2 threads will be used + # If set to 0, availableProcessors / 2 threads will be used clientWorkerThreadsCount: 0 # Worker threads are those performing all the asynchronous I/O operation on the inbound channel. - # 0 -> availableProcessors / 2 threads will be used + # If set to 0, availableProcessors / 2 threads will be used workerThreadsCount: 0 tcpNoDelay: true nioReuseAddress: true @@ -142,9 +149,9 @@ styxHeaders: # each proxied request. Accepts a boolean value (true/false). requestTracking: false -# Allow and Encode the list of unwise chars. url: encoding: + # Determines which characters should be escaped if found in the URL. unwiseCharactersToEncode: "|,;,{,}" # Configure plugins that Styx will use From e96c1fe7a1d3d4008c758254762887c0919601e4 Mon Sep 17 00:00:00 2001 From: Kyle Vosper Date: Mon, 10 Jun 2019 15:50:23 +0100 Subject: [PATCH 08/13] Adding documentation --- .../styx/server/netty/NettyServerConfig.java | 49 ++++++++++++++++++- docs/user-guide/configure-overview.md | 8 +-- 2 files changed, 52 insertions(+), 5 deletions(-) diff --git a/components/server/src/main/java/com/hotels/styx/server/netty/NettyServerConfig.java b/components/server/src/main/java/com/hotels/styx/server/netty/NettyServerConfig.java index 9afa084de3..0cecd0f2f5 100644 --- a/components/server/src/main/java/com/hotels/styx/server/netty/NettyServerConfig.java +++ b/components/server/src/main/java/com/hotels/styx/server/netty/NettyServerConfig.java @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2018 Expedia Inc. + Copyright (C) 2013-2019 Expedia Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -122,6 +122,11 @@ public int bossThreadsCount() { return this.bossThreadsCount; } + /** + * Worker threads are those performing all the asynchronous I/O operation on the inbound channel. + * + * @return number of threads + */ public int workerThreadsCount() { return this.workerThreadsCount; } @@ -130,42 +135,84 @@ public int nioAcceptorBacklog() { return this.nioAcceptorBacklog; } + /* + TODO unused + */ public boolean tcpNoDelay() { return this.tcpNoDelay; } + /* + TODO unused + */ public boolean nioReuseAddress() { return this.nioReuseAddress; } + /** + * The maximum length in bytes of the initial line of an HTTP message, e.g. {@code GET http://example.org/ HTTP/1.1}. + * + * @return maximum length of initial line + */ public int maxInitialLineLength() { return this.maxInitialLineLength; } + /** + * The maximum combined size of the HTTP headers in bytes. + * + * @return maximum combined size of headers + */ public int maxHeaderSize() { return this.maxHeaderSize; } + /** + * The maximum size of an HTTP chunk in bytes. + * + * @return maximum chunk size + */ public int maxChunkSize() { return this.maxChunkSize; } + /* + TODO unused + */ public int maxContentLength() { return this.maxContentLength; } + /** + * Time in milliseconds Styx Proxy Service waits for an incoming request from client. + * + * @return time in millis + */ public int requestTimeoutMillis() { return this.requestTimeoutMs; } + /** + * A timeout for idle persistent connections, in milliseconds. + * + * @return time in millis + */ public int keepAliveTimeoutMillis() { return this.keepAliveTimeoutMillis; } + /** + * Max connections to server before we start rejecting them. + * + * @return max number of connections + */ public int maxConnectionsCount() { return this.maxConnectionsCount; } + /* + TODO unused + */ public boolean nioKeepAlive() { return this.nioKeepAlive; } diff --git a/docs/user-guide/configure-overview.md b/docs/user-guide/configure-overview.md index 4ae8ef7ef7..425146773f 100644 --- a/docs/user-guide/configure-overview.md +++ b/docs/user-guide/configure-overview.md @@ -48,18 +48,18 @@ proxy: # Worker threads are those performing all the asynchronous I/O operation on the inbound channel. # If set to 0, availableProcessors / 2 threads will be used workerThreadsCount: 0 - tcpNoDelay: true - nioReuseAddress: true - nioKeepAlive: true + # The maximum length in bytes of the initial line of an HTTP message, e.g. {@code GET http://example.org/ HTTP/1.1}. maxInitialLength: 4096 + # The maximum combined size of the HTTP headers in bytes. maxHeaderSize: 65536 + # The maximum size of an HTTP chunk in bytes. maxChunkSize: 8192 - maxContentLength: 65536 # Time in milliseconds Styx Proxy Service waits for an incoming request from client # before replying with 408 Request Timeout. requestTimeoutMillis: 12000 # A timeout for idle persistent connections, in milliseconds. keepAliveTimeoutMillis: 120000 + # Max connections to server before we start rejecting them. maxConnectionsCount: 4000 From 4a7825df45e4c309db12aa03279b2a5e9790ae9c Mon Sep 17 00:00:00 2001 From: Kyle Vosper Date: Mon, 10 Jun 2019 15:55:29 +0100 Subject: [PATCH 09/13] documentation for admin config --- docs/user-guide/configure-overview.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/docs/user-guide/configure-overview.md b/docs/user-guide/configure-overview.md index 425146773f..a8b965aa2c 100644 --- a/docs/user-guide/configure-overview.md +++ b/docs/user-guide/configure-overview.md @@ -66,21 +66,20 @@ proxy: admin: connectors: http: - # Server port for Styx admin interface. + # Port for accessing the admin server over HTTP. port: 9000 - # Number of threads for handling incoming connections on admin interface. 0 -> availableProcessors / 2 threads will be used. + # Number of threads for handling incoming connections on admin interface. If set to 0, availableProcessors / 2 threads will be used. bossThreadsCount: 1 # Number of worker threads for admin interface # Worker threads are those performing all the asynchronous I/O operation on the inbound channel. # 0 -> availableProcessors / 2 threads will be used workerThreadsCount: 2 - tcpNoDelay: true - nioReuseAddress: true - nioKeepAlive: true + # The maximum length in bytes of the initial line of an HTTP message, e.g. {@code GET http://example.org/ HTTP/1.1}. maxInitialLength: 4096 + # The maximum combined size of the HTTP headers in bytes. maxHeaderSize: 8192 + # The maximum size of an HTTP chunk in bytes. maxChunkSize: 8192 - maxContentLength: 65536 # Whether to cache the generated JSON for the /admin/metrics and /admin/jvm pages metricsCache: From 9139b5f543579f89ad3f20b495e2df214cc01fd4 Mon Sep 17 00:00:00 2001 From: Kyle Vosper Date: Mon, 10 Jun 2019 16:05:44 +0100 Subject: [PATCH 10/13] Remove unused files, references to adaptive strategy --- .../environment/styx-config-alternative.yml | 46 -------------- .../resources/conf/system-properties-test.yml | 59 ------------------ docs/user-guide/configure-load-balancing.md | 3 - .../src/main/resources/styx.yml | 60 ------------------- 4 files changed, 168 deletions(-) delete mode 100644 components/proxy/src/test/resources/conf/environment/styx-config-alternative.yml delete mode 100644 components/proxy/src/test/resources/conf/system-properties-test.yml delete mode 100644 system-tests/e2e-testsupport/src/main/resources/styx.yml diff --git a/components/proxy/src/test/resources/conf/environment/styx-config-alternative.yml b/components/proxy/src/test/resources/conf/environment/styx-config-alternative.yml deleted file mode 100644 index ac196603b1..0000000000 --- a/components/proxy/src/test/resources/conf/environment/styx-config-alternative.yml +++ /dev/null @@ -1,46 +0,0 @@ ---- - -jvmRouteName: "${jvm.route:noJvmRouteSet}" - -proxy: - connectors: - http: - port: 9001 - bossThreadsCount: 1 - clientWorkerThreadsCount: 0 - workerThreadsCount: 0 - tcpNoDelay: true - nioReuseAddress: true - nioKeepAlive: true - maxInitialLength: 4096 - maxHeaderSize: 8192 - maxChunkSize: 8192 - maxContentLength: 65536 - responseTimeoutMillis: 12000 - -admin: - connectors: - http: - port: 9000 - bossThreadsCount: 1 - workerThreadsCount: 1 - tcpNoDelay: true - nioReuseAddress: true - nioKeepAlive: true - maxInitialLength: 4096 - maxHeaderSize: 8192 - maxChunkSize: 8192 - maxContentLength: 65536 - -loadBalancing: - strategy: - factory: {class: "com.hotels.styx.client.loadbalancing.strategies.PowerOfTwoStrategy$Factory"} - -metrics: - graphite: - enabled: true - host: "graphite.lab.com" - port: 2003 - intervalMillis: 5000 - jmx: - enabled: true diff --git a/components/proxy/src/test/resources/conf/system-properties-test.yml b/components/proxy/src/test/resources/conf/system-properties-test.yml deleted file mode 100644 index b58e74546b..0000000000 --- a/components/proxy/src/test/resources/conf/system-properties-test.yml +++ /dev/null @@ -1,59 +0,0 @@ ---- - -#jvmRouteName: "${jvm.route.test.only:noJvmRouteSet}" -jvmRouteName: "${jvm.route.test.only}" - -proxy: - connectors: - http: - port: 8080 - bossThreadsCount: 1 - clientWorkerThreadsCount: 0 - workerThreadsCount: 0 - tcpNoDelay: true - nioReuseAddress: true - nioKeepAlive: true - maxInitialLength: 4096 - maxHeaderSize: 8192 - maxChunkSize: 8192 - maxContentLength: 65536 - requestTimeoutMillis: 12000 - -jvm: - route: - test: - only: - "weofnsofndskjfds" - -admin: - connectors: - http: - port: 9000 - bossThreadsCount: 1 - workerThreadsCount: 1 - tcpNoDelay: true - nioReuseAddress: true - nioKeepAlive: true - maxInitialLength: 4096 - maxHeaderSize: 8192 - maxChunkSize: 8192 - maxContentLength: 65536 - -loadBalancing: - strategy: adaptive - strategies: - adaptive: - factory: {class: "com.hotels.styx.client.loadbalancing.strategies.StrategyFactory"} - warmUpCount: 12345 - roundrobin: - factory: {class: "com.hotels.styx.client.loadbalancing.strategies.StrategyFactory"} - -metrics: - graphite: - enabled: true - host: "graphite.com" - port: 2003 - intervalMillis: 5000 - jmx: - enabled: true - reportingPrefix: test diff --git a/docs/user-guide/configure-load-balancing.md b/docs/user-guide/configure-load-balancing.md index c65fdaeba2..ea884e008e 100644 --- a/docs/user-guide/configure-load-balancing.md +++ b/docs/user-guide/configure-load-balancing.md @@ -72,7 +72,4 @@ To enable *Round Robin* load balancing strategy: strategy: factory: {class: "com.hotels.styx.client.loadbalancing.strategies.RoundRobinStrategy$Factory"} -The *requestCount* attribute determines how long the adaptive strategy -remains in the Round Robin phase before switching over to the *Busy* strategy. -Its value is the number of requests proxied *per origin*. diff --git a/system-tests/e2e-testsupport/src/main/resources/styx.yml b/system-tests/e2e-testsupport/src/main/resources/styx.yml deleted file mode 100644 index c0220ef21f..0000000000 --- a/system-tests/e2e-testsupport/src/main/resources/styx.yml +++ /dev/null @@ -1,60 +0,0 @@ ---- - -jvmRouteName: "${jvm.route:noJvmRouteSet}" - -proxy: - connectors: - - type: http - port: 8080 - bossThreadsCount: 1 - clientWorkerThreadsCount: 0 - workerThreadsCount: 0 - tcpNoDelay: true - nioReuseAddress: true - nioKeepAlive: true - maxInitialLength: 4096 - maxHeaderSize: 8192 - maxChunkSize: 8192 - maxContentLength: 65536 - responseTimeoutMillis: 12000 - -admin: - connectors: - - type: http - port: 9000 - bossThreadsCount: 1 - workerThreadsCount: 1 - tcpNoDelay: true - nioReuseAddress: true - nioKeepAlive: true - maxInitialLength: 4096 - maxHeaderSize: 8192 - maxChunkSize: 8192 - maxContentLength: 65536 - -retry: - policy: ntimes - policies: - ntimes: - factory: {class: "com.hotels.styx.client.retry.RetryPolicyFactory"} - count: 2 - -loadBalancing: - strategy: adaptive - strategies: - adaptive: - factory: {class: "com.hotels.styx.client.loadbalancing.strategies.AdaptiveStrategy$Factory"} - warmUpCount: 100 - rr: - factory: {class: "com.hotels.styx.client.loadbalancing.strategies.RoundRobinStrategy$Factory"} - -metrics: - graphite: - enabled: true - host: "graphite.lab.com" - port: 2003 - intervalMillis: 5000 - jmx: - enabled: true - - From 515a07a30a8ef02f8643f99e658f8aa15a8ac982 Mon Sep 17 00:00:00 2001 From: Kyle Vosper Date: Mon, 10 Jun 2019 17:17:20 +0100 Subject: [PATCH 11/13] Further cleanup --- docs/user-guide/configure-overview.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/user-guide/configure-overview.md b/docs/user-guide/configure-overview.md index a8b965aa2c..21279270b4 100644 --- a/docs/user-guide/configure-overview.md +++ b/docs/user-guide/configure-overview.md @@ -40,9 +40,8 @@ proxy: - TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 - TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 # Boss threads are those establishing new channels. - # If set to 0, availableProcessors / 2 threads will be used bossThreadsCount: 1 - # styx client worker threads are those performing all the asynchronous I/O operation to the backend origins. + # Styx client worker threads are those performing all the asynchronous I/O operation to the backend origins. # If set to 0, availableProcessors / 2 threads will be used clientWorkerThreadsCount: 0 # Worker threads are those performing all the asynchronous I/O operation on the inbound channel. @@ -68,7 +67,7 @@ admin: http: # Port for accessing the admin server over HTTP. port: 9000 - # Number of threads for handling incoming connections on admin interface. If set to 0, availableProcessors / 2 threads will be used. + # Number of threads for handling incoming connections on admin interface. bossThreadsCount: 1 # Number of worker threads for admin interface # Worker threads are those performing all the asynchronous I/O operation on the inbound channel. From 4897ec4f8628f5a851eefd165aec69191462b2ca Mon Sep 17 00:00:00 2001 From: Kyle Vosper Date: Mon, 10 Jun 2019 17:29:50 +0100 Subject: [PATCH 12/13] Clarify TODOs --- .../com/hotels/styx/server/netty/NettyServerConfig.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/server/src/main/java/com/hotels/styx/server/netty/NettyServerConfig.java b/components/server/src/main/java/com/hotels/styx/server/netty/NettyServerConfig.java index 0cecd0f2f5..019e02ac5d 100644 --- a/components/server/src/main/java/com/hotels/styx/server/netty/NettyServerConfig.java +++ b/components/server/src/main/java/com/hotels/styx/server/netty/NettyServerConfig.java @@ -136,14 +136,14 @@ public int nioAcceptorBacklog() { } /* - TODO unused + TODO unused: https://github.com/HotelsDotCom/styx/issues/428 */ public boolean tcpNoDelay() { return this.tcpNoDelay; } /* - TODO unused + TODO unused: https://github.com/HotelsDotCom/styx/issues/428 */ public boolean nioReuseAddress() { return this.nioReuseAddress; @@ -177,7 +177,7 @@ public int maxChunkSize() { } /* - TODO unused + TODO unused: https://github.com/HotelsDotCom/styx/issues/428 */ public int maxContentLength() { return this.maxContentLength; @@ -211,7 +211,7 @@ public int maxConnectionsCount() { } /* - TODO unused + TODO unused: https://github.com/HotelsDotCom/styx/issues/428 */ public boolean nioKeepAlive() { return this.nioKeepAlive; From 891bd9e7c3d142a2cbb3042a13b850990b714ca3 Mon Sep 17 00:00:00 2001 From: Kyle Vosper Date: Tue, 11 Jun 2019 13:50:51 +0100 Subject: [PATCH 13/13] Clarify --- .../java/com/hotels/styx/server/netty/NettyServerConfig.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/components/server/src/main/java/com/hotels/styx/server/netty/NettyServerConfig.java b/components/server/src/main/java/com/hotels/styx/server/netty/NettyServerConfig.java index 019e02ac5d..4f2ae5a56c 100644 --- a/components/server/src/main/java/com/hotels/styx/server/netty/NettyServerConfig.java +++ b/components/server/src/main/java/com/hotels/styx/server/netty/NettyServerConfig.java @@ -184,7 +184,9 @@ public int maxContentLength() { } /** - * Time in milliseconds Styx Proxy Service waits for an incoming request from client. + * This parameter controls the amount of tolerated inactivity while the request is being received. + * If a client started sending a request, and then suddenly cuts it off, Styx would detect this after this + * duration has elapsed. * * @return time in millis */