Configuration - Netflix/dyno GitHub Wiki
Dyno client's configuration settings can be used to modify its runtime behavior for things such as:
- Connection Pooling
- Load Balancing
- Error Handling (retries etc)
For configuration changes to take effect you must restart the client.
Below is a list of configuration options available in Dyno. These can be set either programmatically via a ConnectionPoolConfigurationImpl
instance passed to the client when constructing it or via Archaius properties.
Note that the value of {APP}
below is the value passed to DynoJedisBuilder.withApplicationName()
.
Config table
Configuration Option | Default Value | Archaius Property Name |
---|---|---|
CompressionStrategy | NONE | dyno.{APP}.compressionStrategy |
CompressionThreshold | 5120 | dyno.{APP}.config.compressionThreshold |
ConnectionPort | 8102 | dyno.{APP}.connection.port |
ConnectTimeout | 3000 | dyno.{APP}.connection.connectTimeout |
ErrorMonitorFactory | SimpleErrorMonitorFactory | N/A, can only be set programmatically |
HostSupplier | EurekaHostsSupplier | N/A, set when constructing client instance |
LoadBalancingStrategy | TokenAware | dyno.{APP}.lbStrategy |
MaxConnsPerHost | 3 | dyno.{APP}.connection.maxConnsPerHost |
MaxFailoverCount | 3 | dyno.{APP}.connection.maxFailoverCount |
MaxTimeoutWhenExhausted | 2000 | dyno.{APP}.connection.maxTimeoutWhenExhausted |
RetryPolicyFactory | RunOnce | dyno.{APP}.retryPolicy |
SocketTimeout | 12000 | dyno.{APP}.connection.socketTimeout |
TokenMapSupplier | localhost:22222/cluster_describe | N/A, can only be set programmatically |
CompressionStrategy
Specifies what type of strategy to use when determining if data should be compressed prior to sending to Dynomite. This is expressed in bytes and by default is off.
ConnectionPoolConfigurationImpl config = new ConnectionPoolConfigurationImpl()
.setCompressionStrategy(CompressionStrategy.THRESHOLD)
.setCompressionThreshold(1000) // specified in bytes
Use this with care since, once compression is turned on you cannot simply switch it off (unless all of your data has TTL'd out or has been removed). To turn compression off change the threshold the a value higher than your max payload size to effectively disable it and once your compressed data TTLs out or has been removed you can then switch it off.
CompressionThreshold
Specifies the threshold in bytes upon which a payload will be compressed. See example above.
ConnectionPort
Port that dyno client communicates with Dynomite server nodes.
config = new ConnectionPoolConfigurationImpl().setPort(8080)
ConnectTimeout
Specifies the number of milliseconds allowable to establish a connection to a Dynomite server node.
config = new ConnectionPoolConfigurationImpl().setConnectTimeout(5000)
ErrorMonitorFactory
Tracks connection errors. A simple implementation is used by default, which is threshold based. After 10 connection errors, the host connection pool is recycled. You can plug in a more sophisticated implementation by injecting it into the configuration prior to startup.
ConnectionPoolConfigurationImpl config = new ConnectionPoolConfigurationImpl().withErrorMonitorFactory(new ErrorMonitorFactory() {
@Override
public ErrorMonitor createErrorMonitor(<your error monitor implementation>);
});
HostSupplier
Supplier that provides a collection of Host objects so that Dyno client can resolve Dynomite server node locations. See EurekaHostSupplier and Netflix / eureka for more information as well as DynoDemo for example code.
LoadBalancingStrategy
Specifies the load balancing strategy for the client. By default the client is Token Aware with rack affinity. Valid values are TokenAware
or RoundRobin
.
config = new ConnectionPoolConfigurationImpl().setLoadBalancingStrategy(LoadBalancingStrategy.RoundRobin)
MaxConnsPerHost
The number of connections to each Dynomite server node that are maintained. Note that there is no setting for the minimum number of connections, only a max which the client will keep alive and persistent at all times.
config = new ConnectionPoolConfigurationImpl().setMaxConnsPerHost(25)
MaxFailoverCount
Specifies the number of failover attempts when getting a fallback connection.
config = new ConnectionPoolConfigurationImpl().setMaxFailoverCount(2)
MaxTimeoutWhenExhausted
Max time to wait for a connection from a host connection pool. This is specified in milliseconds.
RetryPolicyFactory
Factory for vending a RetryPolicyFactory. Dyno client comes with two implementations:
- RunOnce - no retries
- RetryNTimes - retry N times, where N is specified during construction of the instance. Another attribute of the this policy is whether to allow cross-zone (rack) fallback.
To set a retry for two retries (up to 3 total attempts) with cross-zone failover enabled:
dyno.{APP}.retryPolicy=RetryNTimes:2:true
SocketTimeout
Expressed in milliseconds, this specifies the amount of time to wait after which an exception will be thrown.
config = new ConnectionPoolConfigurationImpl().setSocketTimeout(12000)
TokenMapSupplier
Supplies the Dynomite server topology to Dyno client.