github.com/yankunsam/loki/v2@v2.6.3-0.20220817130409-389df5235c27/docs/sources/fundamentals/architecture/rings.md (about)

     1  ---
     2  title: Consistent Hash Rings
     3  weight: 40
     4  ---
     5  # Consistent Hash Rings
     6  
     7  [Consistent hash rings](https://en.wikipedia.org/wiki/Consistent_hashing)
     8  are incorporated into Loki cluster architectures to
     9  
    10  - aid in the sharding of log lines
    11  - implement high availability
    12  - ease the horizontal scale up and scale down of clusters.
    13  There is less of a performance hit for operations that must rebalance data.
    14  
    15  Hash rings connect instances of a single type of component when
    16  
    17  - there are a set of Loki instances in monolithic deployment mode
    18  - there are multiple read components or multiple write components in
    19  simple scalable deployment mode
    20  - there are multiple instances of one type of component in microservices mode
    21  
    22  Not all Loki components are connected by hash rings.
    23  These components need to be connected into a hash ring:
    24  
    25  - distributors
    26  - ingesters
    27  - query schedulers
    28  - compactors
    29  - rulers
    30  
    31  These components can optionally be connected into a hash ring:
    32  - index gateway
    33  
    34  In an architecture that has three distributors and three ingestors defined,
    35  the hash rings for these components connect the instances of same-type components.
    36  
    37  ![distributor and ingester rings](../ring-overview.png)
    38  
    39  Each node in the ring represents an instance of a component.
    40  Each node has a key-value store that holds communication information
    41  for each of the nodes in that ring.
    42  Nodes update the key-value store periodically to keep the contents consistent
    43  across all nodes.
    44  For each node, the key-value store holds:
    45  
    46  - an ID of the component node
    47  - component address, used by other nodes as a communication channel
    48  - an indication of the component node's health
    49  
    50  ## Configuring rings
    51  
    52  Define [ring configuration](../../../configuration/#ring_config) within the `common.ring_config` block.
    53  
    54  Use the default `memberlist` key-value store type unless there is
    55  a compelling reason to use a different key-value store type.
    56  `memberlist` uses a [gossip protocol](https://en.wikipedia.org/wiki/Gossip_protocol)
    57  to propagate information to all the nodes
    58  to guarantee the eventual consistency of the key-value store contents.
    59  
    60  There are additional configuration options for distributor rings,
    61  ingester rings, and ruler rings.
    62  These options are for advanced, specialized use only.
    63  These options are defined within the `distributor.ring` block for distributors,
    64  the `ingester.lifecycler.ring` block for ingesters,
    65  and the `ruler.ring` block for rulers.
    66  
    67  ## About the distributor ring
    68  
    69  Distributors use the information in their key-value store
    70  to keep a count of the quantity of distributors in the distributor ring.
    71  The count further informs cluster limits.
    72  
    73  ## About the ingester ring
    74  
    75  Ingester ring information in the key-value stores is used by distributors.
    76  The information lets the distributors shard log lines,
    77  determining which ingester or set of ingesters a distributor sends log lines to.
    78  
    79  ## About the query scheduler ring
    80  
    81  Query schedulers use the information in their key-value store
    82  for service discovery of the schedulers.
    83  This allows queriers to connect to all available schedulers,
    84  and it allows schedulers to connect to all available query frontends,
    85  effectively creating a single queue that aids in balancing the query load.
    86  
    87  ## About the compactor ring
    88  
    89  Compactors use the information in the key-value store to identify
    90  a single compactor instance that will be responsible for compaction.
    91  The compactor is only enabled on the responsible instance,
    92  despite the compactor target being on multiple instances.
    93  
    94  ## About the ruler ring
    95  
    96  The ruler ring is used to determine which rulers evaluate which rule groups.
    97  
    98  ## About the index gateway ring
    99  
   100  The index gateway ring is used to determine which gateway is responsible for which tenant's indexes when queried by rulers or queriers.