Class TailChoppingRoutingLogic
- java.lang.Object
-
- akka.routing.TailChoppingRoutingLogic
-
- All Implemented Interfaces:
NoSerializationVerificationNeeded
,RoutingLogic
,java.io.Serializable
,scala.Equals
,scala.Product
,scala.Serializable
public final class TailChoppingRoutingLogic extends java.lang.Object implements RoutingLogic, scala.Product, scala.Serializable
As each message is sent to the router, the routees are randomly ordered. The message is sent to the first routee. If no response is received before theinterval
has passed, the same message is sent to the next routee. This process repeats until either a response is received from some routee, the routees in the pool are exhausted, or thewithin
duration has passed since the first send. If no routee sends a response in time, aStatus.Failure
wrapping aAskTimeoutException
is sent to the sender.The goal of this routing algorithm is to decrease tail latencies ("chop off the tail latency") in situations where multiple routees can perform the same piece of work, and where a routee may occasionally respond more slowly than expected. In this case, sending the same work request (also known as a "backup request") to another actor results in decreased response time - because it's less probable that multiple actors are under heavy load simultaneously. This technique is explained in depth in Jeff Dean's presentation on Achieving Rapid Response Times in Large Online Services.
param: scheduler schedules sending messages to routees
param: within expecting at least one reply within this duration, otherwise it will reply with
AskTimeoutException
in aStatus.Failure
param: interval duration after which the message will be sent to the next routee
param: context execution context used by scheduler
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description TailChoppingRoutingLogic(Scheduler scheduler, scala.concurrent.duration.FiniteDuration within, scala.concurrent.duration.FiniteDuration interval, scala.concurrent.ExecutionContext context)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static TailChoppingRoutingLogic
apply(Scheduler scheduler, scala.concurrent.duration.FiniteDuration within, scala.concurrent.duration.FiniteDuration interval, scala.concurrent.ExecutionContext context)
boolean
canEqual(java.lang.Object x$1)
scala.concurrent.ExecutionContext
context()
TailChoppingRoutingLogic
copy(Scheduler scheduler, scala.concurrent.duration.FiniteDuration within, scala.concurrent.duration.FiniteDuration interval, scala.concurrent.ExecutionContext context)
Scheduler
copy$default$1()
scala.concurrent.duration.FiniteDuration
copy$default$2()
scala.concurrent.duration.FiniteDuration
copy$default$3()
scala.concurrent.ExecutionContext
copy$default$4()
boolean
equals(java.lang.Object x$1)
int
hashCode()
scala.concurrent.duration.FiniteDuration
interval()
int
productArity()
java.lang.Object
productElement(int x$1)
scala.collection.Iterator<java.lang.Object>
productIterator()
java.lang.String
productPrefix()
Scheduler
scheduler()
Routee
select(java.lang.Object message, scala.collection.immutable.IndexedSeq<Routee> routees)
java.lang.String
toString()
static scala.Option<scala.Tuple4<Scheduler,scala.concurrent.duration.FiniteDuration,scala.concurrent.duration.FiniteDuration,scala.concurrent.ExecutionContext>>
unapply(TailChoppingRoutingLogic x$0)
scala.concurrent.duration.FiniteDuration
within()
-
-
-
Constructor Detail
-
TailChoppingRoutingLogic
public TailChoppingRoutingLogic(Scheduler scheduler, scala.concurrent.duration.FiniteDuration within, scala.concurrent.duration.FiniteDuration interval, scala.concurrent.ExecutionContext context)
-
-
Method Detail
-
apply
public static TailChoppingRoutingLogic apply(Scheduler scheduler, scala.concurrent.duration.FiniteDuration within, scala.concurrent.duration.FiniteDuration interval, scala.concurrent.ExecutionContext context)
-
unapply
public static scala.Option<scala.Tuple4<Scheduler,scala.concurrent.duration.FiniteDuration,scala.concurrent.duration.FiniteDuration,scala.concurrent.ExecutionContext>> unapply(TailChoppingRoutingLogic x$0)
-
scheduler
public Scheduler scheduler()
-
within
public scala.concurrent.duration.FiniteDuration within()
-
interval
public scala.concurrent.duration.FiniteDuration interval()
-
context
public scala.concurrent.ExecutionContext context()
-
select
public Routee select(java.lang.Object message, scala.collection.immutable.IndexedSeq<Routee> routees)
- Specified by:
select
in interfaceRoutingLogic
-
copy
public TailChoppingRoutingLogic copy(Scheduler scheduler, scala.concurrent.duration.FiniteDuration within, scala.concurrent.duration.FiniteDuration interval, scala.concurrent.ExecutionContext context)
-
copy$default$1
public Scheduler copy$default$1()
-
copy$default$2
public scala.concurrent.duration.FiniteDuration copy$default$2()
-
copy$default$3
public scala.concurrent.duration.FiniteDuration copy$default$3()
-
copy$default$4
public scala.concurrent.ExecutionContext copy$default$4()
-
productPrefix
public java.lang.String productPrefix()
- Specified by:
productPrefix
in interfacescala.Product
-
productArity
public int productArity()
- Specified by:
productArity
in interfacescala.Product
-
productElement
public java.lang.Object productElement(int x$1)
- Specified by:
productElement
in interfacescala.Product
-
productIterator
public scala.collection.Iterator<java.lang.Object> productIterator()
- Specified by:
productIterator
in interfacescala.Product
-
canEqual
public boolean canEqual(java.lang.Object x$1)
- Specified by:
canEqual
in interfacescala.Equals
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object x$1)
- Specified by:
equals
in interfacescala.Equals
- Overrides:
equals
in classjava.lang.Object
-
-