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 97b27ee386..0000000000 --- a/components/proxy/src/test/resources/conf/environment/styx-config-alternative.yml +++ /dev/null @@ -1,51 +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: 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 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: 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/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..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 @@ -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. @@ -113,10 +113,20 @@ public Iterable connectors() { return connectors; } + /** + * Number of threads for establishing new channels. + * + * @return number of threads + */ 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; } @@ -125,42 +135,86 @@ public int nioAcceptorBacklog() { return this.nioAcceptorBacklog; } + /* + TODO unused: https://github.com/HotelsDotCom/styx/issues/428 + */ public boolean tcpNoDelay() { return this.tcpNoDelay; } + /* + TODO unused: https://github.com/HotelsDotCom/styx/issues/428 + */ 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: https://github.com/HotelsDotCom/styx/issues/428 + */ public int maxContentLength() { return this.maxContentLength; } + /** + * 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 + */ 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: https://github.com/HotelsDotCom/styx/issues/428 + */ public boolean nioKeepAlive() { return this.nioKeepAlive; } diff --git a/docs/user-guide/configure-load-balancing.md b/docs/user-guide/configure-load-balancing.md index b612e00d3a..ea884e008e 100644 --- a/docs/user-guide/configure-load-balancing.md +++ b/docs/user-guide/configure-load-balancing.md @@ -2,7 +2,8 @@ Styx supports three load balancing strategies: - - Round robin + - Power of two + - Round-robin - Busy Styx also provides a mechanism to bypass the load balancer and force @@ -71,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/docs/user-guide/configure-overview.md b/docs/user-guide/configure-overview.md index afee692b26..21279270b4 100644 --- a/docs/user-guide/configure-overview.md +++ b/docs/user-guide/configure-overview.md @@ -12,192 +12,166 @@ 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: + # 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 + # Boss threads are those establishing new channels. + bossThreadsCount: 1 + # 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. + # If set to 0, availableProcessors / 2 threads will be used + workerThreadsCount: 0 + # 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 + # 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 + + +admin: + connectors: + http: + # Port for accessing the admin server over HTTP. + port: 9000 + # 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. + # 0 -> availableProcessors / 2 threads will be used + workerThreadsCount: 2 + # 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 + + # Whether to cache the generated JSON for the /admin/metrics and /admin/jvm pages + metricsCache: + 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: + 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 + +url: + encoding: + # Determines which characters should be escaped if found in the URL. + 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" + 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 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 - -