Class HybridSelector

  • All Implemented Interfaces:
    AdaptiveServerSelector

    public class HybridSelector
    extends Object
    implements AdaptiveServerSelector
    The HybridSelector is an AdaptiveServerSelector implementation that picks the best server based on the following parameters: 1. Num of in-flight requests (A) 2. EMA of in-flight requests (B) 3. EMA of latencies (C) This selector implementation is based on the ideas suggested in the paper - https://www.usenix.org/system/files/conference/nsdi15/nsdi15-paper-suresh.pdf The Hybrid score for each server is calculated as follows. The server with the lowest Hybrid score is picked. HybridScore = Math.pow(A+B, N) * C N -> Configurable exponent with default value of 3.
    • Method Detail

      • select

        public String select​(List<String> serverCandidates)
        Description copied from interface: AdaptiveServerSelector
        Picks the best server to route a query from the list of candidate servers.
        Specified by:
        select in interface AdaptiveServerSelector
        Parameters:
        serverCandidates - Candidate servers from which the best server should be chosen.
        Returns:
        server identifier
      • fetchAllServerRankingsWithScores

        public List<org.apache.commons.lang3.tuple.Pair<String,​Double>> fetchAllServerRankingsWithScores()
        Description copied from interface: AdaptiveServerSelector
        Returns the ranking of servers ordered from best to worst along with the absolute scores based on which the servers are ranked. Based on the implementation of the interface, the score could refer to different things. For NumInFlightReqSelector, score is the number of inflight requests. For LatencySelector, score is the EMA latency. For HybridSelector, score is the hybridScore which is computed by combining latency and # inflight requests.
        Specified by:
        fetchAllServerRankingsWithScores in interface AdaptiveServerSelector
        Returns:
        List of servers along with their values ranked from best to worst.
      • fetchServerRankingsWithScores

        public List<org.apache.commons.lang3.tuple.Pair<String,​Double>> fetchServerRankingsWithScores​(List<String> serverCandidates)
        Description copied from interface: AdaptiveServerSelector
        Same as above but fetches ranking only for the list of serverCandidates provided in the parameter. If a server doesn't have an entry, it's ranked better than other serverCandidates and a value of -1.0 is returned. With the above "fetchAllServerRankingsWithScores" API, ranking for all the servers are fetched. This can become problematic if a broker is routing to multiple server tenants but a query needs to touch only a single server tenant. This API helps fetch ranking only for a subset of servers.
        Specified by:
        fetchServerRankingsWithScores in interface AdaptiveServerSelector
        Returns:
        List of servers along with their values ranked from best to worst.