Skip to content

Latest commit

 

History

History
27 lines (17 loc) · 5.75 KB

HostAvailabilityStrategy.md

File metadata and controls

27 lines (17 loc) · 5.75 KB

Host Availability Strategy

What is Host Availability Strategy

The AWS Advanced NodeJS Wrapper keeps track of the availability of database hosts. A host's availability status can be either AVAILABLE or NOT_AVAILABLE. This information is used by the driver when deciding which hosts to connect to.

When database hosts fail, they are marked as NOT_AVAILABLE and will not be checked again to see if they have recovered. Host Availability Strategies can help the driver keep host health statuses up to date by checking whether unavailable hosts have become available. For example, the Exponential Backoff strategy will let the wrapper retry hosts that have had their availability set to NOT_AVAILABLE by setting the host availability to AVAILABLE after a backoff period.

Different strategies can be swapped out for different behaviors. The default Host Availability Strategy the wrapper uses can be configured as specified in the configuration parameters table.

Configuration Parameters

Parameter Value Required Description Default Value
defaultHostAvailabilityStrategy String No This overrides the driver's default host availability strategy. Possible values are listed in the Host Availability Strategy Options section. null
hostAvailabilityStrategyMaxRetries Number No Maximum number of times a host availability strategy will retry a host that is not available. 5
hostAvailabilityStrategyInitialBackoffTimeSec Number No The initial wait time in seconds. This parameter is only applicable for host availability strategies employing a time-based backoff. 30

Host Availability Strategies

These are different host availability strategies to choose from when specifying the defaultHostAvailabilityStrategy parameter value.

Name Value Description
Exponential Backoff Host Availability Strategy exponentialBackoff This strategy does not actively health check hosts and instead allows host availability consumers to perform health checks.

If a host is marked NOT_AVAILABLE, there is a backoff time period where the host's availability will be NOT_AVAILABLE. After the backoff period, the host's availability will be AVAILABLE so that host availability consumers can attempt to connect to the host.

Each subsequent time the host fails a health check, the host is set to NOT_AVAILABLE and another backoff period twice the duration of the last will occur before the host availability is set to AVAILABLE again. However, if the host passes the health check, consumers will set the host availability to AVAILABLE with no backoff period. The next backoff period that occurs will be reset to the initial backoff time.

The backoff time period can be set in seconds using the hostAvailabilityStrategyInitialBackoffTimeSec configuration parameter.

If defaultHostAvailabilityStrategy is not specified, the default strategy will be a simple pass through strategy. No extra logic or functionality will be added when host availability is set or fetched.