How netflix/hystrix works
Hystrix is a fault-tolerance and latency-isolation library. A caller wraps remote work in a command and invokes it synchronously, asynchronously, or as an observable; the runtime applies isolation, circuit breaking, fallback, request caching, and optional batching. Runtime events feed metrics and operational streams, with adapters for several monitoring and web stacks. The README documents the main behavior; the sampled source/index supports selected wiring, but many runtime implementations were not excerpted, so uncertain connections are omitted or dashed.
Main entry points: HystrixCommandMetrics.java Command metrics · AbstractCommand.java Execution runtime · HystrixCommand.java Hystrix command · HystrixDashboardStream.java Dashboard stream
Components 20
Command execution
- Hystrix command
hystrix-core/src/main/java/com/netflix/hystrix/HystrixCommand.java - Execution runtime
hystrix-core/src/main/java/com/netflix/hystrix/AbstractCommand.java - Circuit breaker
hystrix-core/src/main/java/com/netflix/hystrix/HystrixCircuitBreaker.java - Thread pool
hystrix-core/src/main/java/com/netflix/hystrix/HystrixThreadPool.java - Fallback handling
hystrix-core/src/main/java/com/netflix/hystrix/AbstractCommand.java
Request features
- Request collapsing
hystrix-core/src/main/java/com/netflix/hystrix/collapser/RequestCollapser.java - Request context
hystrix-core/src/main/java/com/netflix/hystrix/strategy/concurrency/HystrixRequestContext.java - Request cache
hystrix-core/src/main/java/com/netflix/hystrix/HystrixRequestCache.java
Metrics and streams
- Command metrics
hystrix-core/src/main/java/com/netflix/hystrix/HystrixCommandMetrics.java - Event streams
hystrix-core/src/main/java/com/netflix/hystrix/metric/HystrixThreadEventStream.java - Dashboard stream
hystrix-core/src/main/java/com/netflix/hystrix/metric/consumer/HystrixDashboardStream.java - Dashboard serialization
hystrix-serialization/src/main/java/com/netflix/hystrix/serial/SerialHystrixDashboardData.java
Language and integrations
- Annotation API
hystrix-contrib/hystrix-javanica/src/main/java/com/netflix/hystrix/contrib/javanica/aop/aspectj/HystrixCommandAspect.java - Clojure API
hystrix-contrib/hystrix-clj/src/main/clojure/com/netflix/hystrix/core.clj - JAX-RS streams
hystrix-contrib/hystrix-metrics-event-stream-jaxrs/src/main/java/com/netflix/hystrix/contrib/metrics/controller/HystrixMetricsStreamController.java - Coda Hale publisher
hystrix-contrib/hystrix-codahale-metrics-publisher/src/main/java/com/netflix/hystrix/contrib/codahalemetricspublisher/HystrixCodaHaleMetricsPublisher.java - Servo publisher
hystrix-contrib/hystrix-servo-metrics-publisher/src/main/java/com/netflix/hystrix/contrib/servopublisher/HystrixServoMetricsPublisher.java - Yammer publisher
hystrix-contrib/hystrix-yammer-metrics-publisher/src/main/java/com/netflix/hystrix/contrib/yammermetricspublisher/HystrixYammerMetricsPublisher.java
Other components
- Application caller
- Monitoring client
Connections 19
- Application caller → Hystrix command: invokes
- Hystrix command → Execution runtime: executes through
- Execution runtime → Circuit breaker: checks circuit
hystrix-core/src/main/java/com/netflix/hystrix/AbstractCommand.java - Execution runtime → Thread pool: isolates work
hystrix-core/src/main/java/com/netflix/hystrix/AbstractCommand.java - Execution runtime → Fallback handling: runs fallback
hystrix-core/src/main/java/com/netflix/hystrix/AbstractCommand.java - Application caller → Request collapsing: may batch
- Request context → Request cache: scopes cache
hystrix-core/src/main/java/com/netflix/hystrix/strategy/concurrency/HystrixRequestContext.java - Hystrix command → Request cache: may cache
- Command metrics → Event streams: publishes events
hystrix-core/src/main/java/com/netflix/hystrix/HystrixCommandMetrics.java - Event streams → Dashboard stream: feeds metrics
- Dashboard stream → Dashboard serialization: serializes data
hystrix-serialization/src/main/java/com/netflix/hystrix/serial/SerialHystrixDashboardData.java - JAX-RS streams → Dashboard stream: reads stream
hystrix-contrib/hystrix-metrics-event-stream-jaxrs/src/main/java/com/netflix/hystrix/contrib/metrics/controller/HystrixMetricsStreamController.java - JAX-RS streams → Monitoring client: serves events
- Application caller → Annotation API: uses annotations
- Annotation API → Hystrix command: adapts methods
- Application caller → Clojure API: uses API
- Command metrics → Coda Hale publisher: publishes metrics
- Command metrics → Servo publisher: publishes metrics
- Command metrics → Yammer publisher: publishes metrics