Are you happy with your logging solution? Would you help us out by taking a 30-second survey? Click here

Hystrix

Hystrix is a latency and fault tolerance library designed to isolate points of access to remote systems, services and 3rd party libraries, stop cascading failure and enable resilience in complex distributed systems where failure is inevitable.

Subscribe to updates I use Hystrix


Statistics on Hystrix

Number of watchers on Github 12811
Number of open issues 203
Average time to close an issue 14 days
Main language Java
Average time to merge a PR 1 day
Open pull requests 43+
Closed pull requests 20+
Last commit almost 2 years ago
Repo Created almost 7 years ago
Repo Last Updated over 1 year ago
Size 9.36 MB
Organization / Authornetflix
Latest Releasev1.5.13
Contributors64
Page Updated
Do you use Hystrix? Leave a review!
View open issues (203)
View Hystrix activity
View on github
Fresh, new opensource launches πŸš€πŸš€πŸš€
Trendy new open source projects in your inbox! View examples

Subscribe to our mailing list

Evaluating Hystrix for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)

Hystrix: Latency and Fault Tolerance for Distributed Systems

NetflixOSS Lifecycle

Hystrix is a latency and fault tolerance library designed to isolate points of access to remote systems, services and 3rd party libraries, stop cascading failure and enable resilience in complex distributed systems where failure is inevitable.

Full Documentation

See the Wiki for full documentation, examples, operational details and other information.

See the Javadoc for the API.

Communication

What does it do?

1) Latency and Fault Tolerance

Stop cascading failures. Fallbacks and graceful degradation. Fail fast and rapid recovery.

Thread and semaphore isolation with circuit breakers.

2) Realtime Operations

Realtime monitoring and configuration changes. Watch service and property changes take effect immediately as they spread across a fleet.

Be alerted, make decisions, affect change and see results in seconds.

3) Concurrency

Parallel execution. Concurrency aware request caching. Automated batching through request collapsing.

Hello World!

Code to be isolated is wrapped inside the run() method of a HystrixCommand similar to the following:

public class CommandHelloWorld extends HystrixCommand<String> {

    private final String name;

    public CommandHelloWorld(String name) {
        super(HystrixCommandGroupKey.Factory.asKey("ExampleGroup"));
        this.name = name;
    }

    @Override
    protected String run() {
        return "Hello " + name + "!";
    }
}

This command could be used like this:

String s = new CommandHelloWorld("Bob").execute();
Future<String> s = new CommandHelloWorld("Bob").queue();
Observable<String> s = new CommandHelloWorld("Bob").observe();

More examples and information can be found in the How To Use section.

Example source code can be found in the hystrix-examples module.

Binaries

Binaries and dependency information for Maven, Ivy, Gradle and others can be found at http://search.maven.org.

Change history and version numbers => CHANGELOG.md

Example for Maven:

<dependency>
    <groupId>com.netflix.hystrix</groupId>
    <artifactId>hystrix-core</artifactId>
    <version>x.y.z</version>
</dependency>

and for Ivy:

<dependency org="com.netflix.hystrix" name="hystrix-core" rev="x.y.z" />

If you need to download the jars instead of using a build system, create a Maven pom file like this with the desired version:

<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.netflix.hystrix.download</groupId>
    <artifactId>hystrix-download</artifactId>
    <version>1.0-SNAPSHOT</version>
    <name>Simple POM to download hystrix-core and dependencies</name>
    <url>http://github.com/Netflix/Hystrix</url>
    <dependencies>
        <dependency>
            <groupId>com.netflix.hystrix</groupId>
            <artifactId>hystrix-core</artifactId>
            <version>x.y.z</version>
            <scope/>
        </dependency>
    </dependencies>
</project>

Then execute:

mvn -f download-hystrix-pom.xml dependency:copy-dependencies

It will download hystrix-core-*.jar and its dependencies into ./target/dependency/.

You need Java 6 or later.

Build

To build:

$ git clone git@github.com:Netflix/Hystrix.git
$ cd Hystrix/
$ ./gradlew build

Futher details on building can be found on the Getting Started page of the wiki.

Run Demo

To run a demo app do the following:

$ git clone git@github.com:Netflix/Hystrix.git
$ cd Hystrix/
./gradlew runDemo

You will see output similar to the following:

Request => GetUserAccountCommand[SUCCESS][8ms], GetPaymentInformationCommand[SUCCESS][20ms], GetUserAccountCommand[SUCCESS, RESPONSE_FROM_CACHE][0ms]x2, GetOrderCommand[SUCCESS][101ms], CreditCardCommand[SUCCESS][1075ms]
Request => GetUserAccountCommand[FAILURE, FALLBACK_SUCCESS][2ms], GetPaymentInformationCommand[SUCCESS][22ms], GetUserAccountCommand[FAILURE, FALLBACK_SUCCESS, RESPONSE_FROM_CACHE][0ms]x2, GetOrderCommand[SUCCESS][130ms], CreditCardCommand[SUCCESS][1050ms]
Request => GetUserAccountCommand[FAILURE, FALLBACK_SUCCESS][4ms], GetPaymentInformationCommand[SUCCESS][19ms], GetUserAccountCommand[FAILURE, FALLBACK_SUCCESS, RESPONSE_FROM_CACHE][0ms]x2, GetOrderCommand[SUCCESS][145ms], CreditCardCommand[SUCCESS][1301ms]
Request => GetUserAccountCommand[SUCCESS][4ms], GetPaymentInformationCommand[SUCCESS][11ms], GetUserAccountCommand[SUCCESS, RESPONSE_FROM_CACHE][0ms]x2, GetOrderCommand[SUCCESS][93ms], CreditCardCommand[SUCCESS][1409ms]

#####################################################################################
# CreditCardCommand: Requests: 17 Errors: 0 (0%)   Mean: 1171 75th: 1391 90th: 1470 99th: 1486 
# GetOrderCommand: Requests: 21 Errors: 0 (0%)   Mean: 100 75th: 144 90th: 207 99th: 230 
# GetUserAccountCommand: Requests: 21 Errors: 4 (19%)   Mean: 8 75th: 11 90th: 46 99th: 51 
# GetPaymentInformationCommand: Requests: 21 Errors: 0 (0%)   Mean: 18 75th: 21 90th: 24 99th: 25 
#####################################################################################

Request => GetUserAccountCommand[SUCCESS][10ms], GetPaymentInformationCommand[SUCCESS][16ms], GetUserAccountCommand[SUCCESS, RESPONSE_FROM_CACHE][0ms]x2, GetOrderCommand[SUCCESS][51ms], CreditCardCommand[SUCCESS][922ms]
Request => GetUserAccountCommand[SUCCESS][12ms], GetPaymentInformationCommand[SUCCESS][12ms], GetUserAccountCommand[SUCCESS, RESPONSE_FROM_CACHE][0ms]x2, GetOrderCommand[SUCCESS][68ms], CreditCardCommand[SUCCESS][1257ms]
Request => GetUserAccountCommand[SUCCESS][10ms], GetPaymentInformationCommand[SUCCESS][11ms], GetUserAccountCommand[SUCCESS, RESPONSE_FROM_CACHE][0ms]x2, GetOrderCommand[SUCCESS][78ms], CreditCardCommand[SUCCESS][1295ms]
Request => GetUserAccountCommand[FAILURE, FALLBACK_SUCCESS][6ms], GetPaymentInformationCommand[SUCCESS][11ms], GetUserAccountCommand[FAILURE, FALLBACK_SUCCESS, RESPONSE_FROM_CACHE][0ms]x2, GetOrderCommand[SUCCESS][153ms], CreditCardCommand[SUCCESS][1321ms]

This demo simulates 4 different HystrixCommand implementations with failures, latency, timeouts and duplicate calls in a multi-threaded environment.

It logs the results of HystrixRequestLog and metrics from HystrixCommandMetrics.

Dashboard

The hystrix-dashboard component of this project has been deprecated and moved to Netflix-Skunkworks/hystrix-dashboard. Please see the README there for more details including important security considerations.

Bugs and Feedback

For bugs, questions and discussions please use the GitHub Issues.

LICENSE

Copyright 2013 Netflix, Inc.

Licensed under the Apache License, Version 2.0 (the License); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Hystrix open issues Ask a question     (View All Issues)
  • about 3 years Access HystrixRequestVariable from HystrixRequestContext???
  • about 3 years I'm writing a test cases by mocking the Hystrix call
  • about 3 years Hystrix is creating additional threadpool when used
  • about 3 years Turbine Stream aggregation slows down after few minutes
  • about 3 years Hystrix dashboard Eureka integration not working when authentication is required
  • about 3 years Failed to processed fallback error
  • about 3 years Problems with turbine (Pull Model not suitable for containers): Our own model for metrics tapping (Push model)
  • about 3 years Support @HystrixCommand for rx.Single and rx.Completable similar to rx.Observable
  • about 3 years Hystrix Dashboard Keeps Loading
  • about 3 years Thread may be hung, creating javacore files in Websphere.
  • about 3 years Could the documentation for HystrixServletFilter also include how to deal with async servlets?
  • about 3 years HystrixCommandExecutionHook not working properly after hystrix version upgrade
  • about 3 years Does execution.isolation.strategy really default to THREAD as stated in the docs?
  • about 3 years HEAD request on hystrix.stream is not handled correctly
  • about 3 years Cleaner error propagation in hystrix core
  • about 3 years Create new Repo or Gradle build for Hystrix-ReactiveSocket integration
  • over 3 years More beginner-friendly discussion of metrics
  • over 3 years HystrixCommand.getFallbackMethodName hard coded to return "getFallback"
  • over 3 years Configuration is on commands but really applies to keys
  • over 3 years Hystrix Javanica not wrapping any exceptions
  • over 3 years Allow (selected) exception to propagate unwrapped
  • over 3 years Hystrix Timeouts with Apache Http Client
  • over 3 years HystrixPropertiesFactory cache silently obviates dynamic properties
  • over 3 years Support for archaius2
  • over 3 years Publish Hystrix BOM POM
  • over 3 years Eliminate thread-isolated HystrixObservableCommands
  • over 3 years HystrixEventType.CANCELLED
  • over 3 years More composable Hystrix execution model
  • over 3 years Add async 3.x metric servlets
  • over 3 years Dashboard: unable to connect before first Hystrix request is handled (on Cloud Foundry)
Hystrix open pull requests (View All Pulls)
  • #1109 Make queue size of MetricJsonListener configurable
  • Allow Hystrix to be used as lambda
  • Upgrade to Java8
  • Proposal: HystrixRequestContext junit rule
  • New Feature -- Eureka Integration to Hystrix Dashbaord
  • Added AbstractCollapser
  • Failing test case when two requests with the same request argument are collapsed
  • remove dead allocation of unused thunk
  • Interrupt execution thread on HystrixCommand#queue()#cancel(true)
  • Allow to configure threadPoolKey through HystrixObservableCommand.Setter
  • iss993: added DefaultProperties annotation [initial commit]
  • Allow scalar commands (HystrixCommand) to set completion state on an onNext
  • Javanica: basic Observable Collapser support
  • Hystrix Dashboard Eureka integration improvements
  • Cleaner error propagation in hystrix core.
  • Allow exceptions without HystrixRuntimeException wrapper
  • Javanica/Support raiseHystrixExceptions for Observables
  • Manual merge of #1544
  • AOP Alliance support for Hystrix-Javanica
  • iss1403: Support @HystrixCommand for rx.Single and rx.Completable sim…
  • Possibility to add custom root node for command and thread pool metrics
  • throw IllegalStateException if request cache is not available when clearing
  • issue #1760: Added CORS related headers (configurable by properties) and tests to …
  • Fix HealthCounts creating new instances needlessly
  • Fix race condition in HystrixSampleSseServlet for response writes
  • [HYSTRIX-1721] - Fixes normal-case unsubscribes
  • bug fix
  • Removed unused import statements
  • Code changes to fix TPS calculation issue with hystrix thread pool in dashboard
  • Add hystrix-junit5 module
  • Remove duplicated code
  • Nonintuitive and dangerous behavior of MaximumSize+MaxQueueSize
  • (refactor) some opportunities to use lambda functions
  • Publish the value of the currentPoolSize property
  • [WIP] Add OnCancel method to handle cleanup of blocking libs
  • Fix circuitBreaker may stay closed forever
  • SLF4J-related fixes
  • [HYSTRIX-1634] deprecate trivial/duplicated configuration entry metri…
  • bug fix for issue https://github.com/Netflix/Hystrix/issues/1631
  • [HYSTRIX-1625] HystrixCollapserKey, HystrixCommandGroupKey, HystrixCo…
  • Hystrix code corrections
  • Fix metrics ignoring CommandGroup.
  • Create a simple interface for the Hystrix aspects to allow JDK proxying
Hystrix questions on Stackoverflow (View All Questions)
  • How to exclude Hystrix Metrics from the Actuator /metrics endpoint?
  • Using Hystrix Stream in Zuul with Eureka First to find Config server
  • Delay in command metrics getting updated in Hystrix?
  • Hystrix: Upping the maxSemaphoreCount for a Command?
  • Hystrix Javanica Timeouts taking longer than expected
  • Does Spring Cloud Feign client call execute inside hystrix command?
  • Zuul defaulting hystrix isolation strategy to SEMAPHORE
  • Hystrix Dashboard with Turbine issue
  • spring-cloud/spring-cloud-netflix, setting the hystrix origin id
  • Netflix hystrix shared request caching
  • Is Hystrix able to open a circuit depending on method parameters?
  • Unable to apply "sleepWindowInMilliseconds" property in Hystrix
  • spring cloud side car hystrix timeout not fire
  • Getting Issue while building hystrix
  • Hystrix circuit breaker with business exceptions
  • Spring Cloud: How to define default fallback for Hystrix in Zuul gateway?
  • Unable to handle request-promise-json error in hystrix module
  • Why is ZUUL forcing a SEMAPHORE isolation to execute its Hystrix commands?
  • Hystrix command fails with "timed-out and no fallback available"
  • Spring Cloud Netflix Hystrix Turbine not getting info from services on the same host
  • Hystrix Threadpool Queue not working properly
  • Get hystrix timeout exception
  • Web service with spring boot and hystrix often unresponsive
  • Questions about combining Hystrix with Feign
  • Setting request timeout with Netflix Feign and Hystrix
  • Can Hystrix be used without Eureka/ Ribbon or other Netflix OSS modules
  • Hystrix configuration for circuit breaker in java
  • Hystrix - stopping requests at top level if one of a sequential set of external requests fail
  • Hystrix Dashboard: How to use
  • maven: setup Turbine for hystrix
Hystrix list of languages used
Hystrix latest release notes
v1.5.13 Version 1.5.13
  • Pull 1621 Fixed bug where an unsubscription of a command in half-open state leaves circuit permanently open
  • Pull 1605 Change return value on unsubscribe to Observable.empty(). Thanks @atoulme !
  • Pull 1615 Updated Gradle to version 4.0. Thanks @wlsc !
  • Pull 1616 Javanica: Wrong hystrix event type for fallback missing. Thanks @dmgcodevil !
  • Pull 1606 Escape user entered input to avoid HTML injection. This fixes #1456. Thanks @atoulme !
  • Pull 1595 Possibility to add custom root node for command and thread pool metrics. Thanks @dstoklosa !
  • Pull 1587 Throw IllegalStateException if request cache is not available when clearing. Thanks @jack-kerouac !

Artifacts: Maven Central, Bintray

v1.5.12 Version 1.5.12
  • Pull 1586 Start streams for CodaHale metric consumer, ot get it actually working
  • Pull 1584 Javanica: Wire up allowMaximumSizeToDivergeFromCoreSize thread-pool property
  • Pull 1585 Fix actualMaximumSize Codahale threadpool metric calculation
  • Pull 1567 Fix interaction between ExceptionNotWrappedInHystrix and HystrixBadRequestException. Thanks @gagoman !
  • Pull 1576 Fix permyriad calculation for 99.9p latency
  • Pull 1524 Javanica: Support rx.Single or rx.Completable types. Thanks @dmgcodevil !
  • Pull 1574 Add unit-test for using a Completable in a HystrixObservableCommand
  • Pull 1572 Javanica: Wire up maximumSize thread-pool property. Thanks @dmgcodevil !
  • Pull 1573 Javanica: Don't get cause from HystrixBadRequestException if null. Thanks @dmgcodevil !
  • Pull 1570 Only create HystrixContextRunnable in timeout case lazily, when timeout is fired
  • Pull 1568 Made circuit-opening happen in background thread, powered by metric streams
  • Pull 1561 Add error-handling for unexpected errors to servlet writes in metric sample servlet
  • Pull 1556 Typo fix in Javanica fallback log. Thanks @Thunderforge !
  • Pull 1551 Match colors in multiple circuit-breaker status case. Thanks @eunmin !
  • Pull 1547 Support multiple circuit-breaker statuses in dashboard against aggregated data. Thanks @eunmin !
  • Pull 1539 Fix unintentionally shared variable in hystrix-metrics-event-stream-jaxrs. Thanks @justinjose28 !
  • Pull 1535 Move markCommandExecution after markEvent SUCCESS to allow eventNotifier to have full context of execution. Thanks @bltb!

Artifacts: Maven Central, Bintray

v1.5.11 Version 1.5.11
  • Pull 1531 Add assertion to dashboard receiving metrics data. Thanks @lholmquist !
  • Pull 1529 Remove commons-collection as dependency of hystrix-javanica. Thanks @Psynbiotik !
  • Pull 1532 Move metrics subscription out of synchronized block in HealthCountsStream to limit time spent holding a lock.
  • Pull 1513 Fixed COMMAND_MAX_ACTIVE metrics for Coda Hale metrics. Thanks @chrisgray !
  • Pull 1515 Fixed comment typo in HystrixCommand. Thanks @kmkr !
  • Pull 1512 Upgrade codahale metrics-core to 3.2.2. Thanks @chrisgray !
  • Pull 1507 README typo fix. Thanks @PiperChester !
  • Pull 1503 Allow BadRequest exceptions to not be attached if user explicitly wants unwrapped exceptions. Thanks @mNantern !
  • Pull 1502 Remove useless code in HystrixConcurrencyStrategy. Thanks @zzzvvvxxxd !
  • Pull 1495 Add hystrix-metrics-event-stream-jaxrs. Thanks @justinjose28 !
  • Pull 1498 Upgrade Servo to 0.10.1 in hystrix-servo-metrics-publisher

Artifacts: Maven Central, Bintray

Other projects in Java