Isolating noisy tenants with Loki shuffle sharding

Shuffle sharding gives each tenant a subset of queriers, rulers or index gateways so one tenant's heavy queries or failures stay contained. This page covers what it does, how to configure it per component, and what to confirm before rollout.

On this page

Why a noisy tenant slows Loki for everyone, and when shuffle sharding helps

Shuffle sharding limits each tenant to a subset of Loki components, so one tenant's heavy queries or failures stay contained. In a shared cluster serving several teams or customers, every tenant normally draws from the same pool of queriers, rulers and index gateways. A single tenant running wide, expensive LogQL queries can occupy most of that pool, and the other tenants wait behind it even though they did nothing unusual. Per-tenant limits cap how much one tenant may consume, but they do not decide which workers serve that tenant, so a noisy tenant can still touch every querier. Shuffle sharding assigns each tenant a deterministic subset of workers, so a problem in one tenant's subset leaves most of the others untouched.

Shuffle sharding can be enabled separately for three paths. The query path covers the queriers that execute reads for a tenant, controlled by a per-tenant shard size on the query side. The ruler covers the component that evaluates recording and alerting rules, which matters when a tenant runs many or expensive rules. The index gateway covers the component that serves index lookups, which matters when one tenant's queries drive heavy index reads. Each path is configured on its own, so you can isolate only the path where contention actually occurs. Confirm the exact configuration keys and component support for your Loki version in the Loki shuffle sharding documentation before you plan the change.

Teams usually need shuffle sharding when they run a shared cluster with several tenants of very different size or behavior, when a single tenant's queries have repeatedly slowed others, or when a customer contract requires that one customer's load cannot degrade another's service. Per-tenant limits are often enough when tenants are similar in load, when the main risk is ingestion volume rather than query contention, or when the cluster has enough headroom that a noisy tenant rarely saturates shared workers. Before you decide, measure which path is contended, using query latency and queue metrics per tenant, and check whether the problem is a sender or query pattern that a limit change or a query fix would solve more directly. Shuffle sharding also reduces the workers each tenant can reach, so size each subset with enough capacity for that tenant's peak load.

Shuffle sharding settings per component and when each fits

This table maps each Loki component that supports shuffle sharding to its setting, the workload it protects and the trade-off of a smaller subset. Read each row as a balance: a smaller shard limits how many instances a noisy tenant can touch, but it also gives that tenant less capacity. Confirm every key name and its behavior in the Loki shuffle sharding documentation for your version before changing production limits.

ComponentSetting to confirmWorkload it protectsTrade-off of a smaller subset
Query path (queriers)max_queriers_per_tenant in limits_config (confirm)Heavy or runaway LogQL queries from one tenant consuming querier time for everyoneA bad query reaches fewer queriers, but a tenant with large queries may queue or slow down
Rulerruler_tenant_shard_size in limits_config (confirm)Expensive alerting and recording rules from one tenant delaying evaluations for other tenantsFewer rulers per tenant limit blast radius, but that tenant's rule groups evaluate on fewer instances and may lag under load
Index gatewayindex_gateway_shard_size in limits_config (confirm)Index lookups from a tenant with many streams or wide time ranges saturating index servingContained index load, but the tenant sees slower lookups when its assigned gateways are busy
Full pool (no isolation)Shard size set to the full instance pool (confirm the exact value to use)Maximum capacity for a single tenant when it is the only heavy userNo blast radius limit, so one tenant's failure or heavy load can reach every instance

Setting up shuffle sharding without starving tenants

This sequence moves a shared Loki cluster from a single pool of queriers and rulers to per-tenant subsets, one component at a time, and proves with tenant-scoped tests that a heavy tenant no longer affects its neighbors.

  1. Confirm deployment mode and component layout

    Confirm which deployment mode the cluster uses (monolithic, simple scalable or microservices) and whether the components you plan to shard, the query path (querier and query-frontend), the ruler and the index gateway, run as separate targets. Shuffle sharding only has meaning where those components run as distinct pods or processes, so a single monolithic binary will not give you per-tenant subsets. Note that simple scalable mode is being deprecated and removed with Loki 4.0, so factor that into the layout decision. Done when you have a written list of which components are present, their replica counts and the Loki version in use, checked against the release listed on the official releases page.

  2. Enable multi-tenancy and tenant headers

    Set auth_enabled to true in the Loki configuration and confirm every client sends an X-Scope-OrgID header on push and query requests. Without this header, traffic lands in a default tenant and per-tenant isolation has nothing to act on. Because Loki has no built-in authentication layer, place an authenticating reverse proxy in front of it so the tenant header cannot be set freely by end users. Done when a test push with one tenant ID and a query with the same ID return the expected lines, and a query with a different ID returns no data from the first tenant.

  3. Record baseline per-tenant behavior

    Before changing any sharding setting, measure how the shared pool behaves today. Record query latency per tenant, query failures and timeouts, queue wait time in the query path and ruler evaluation delays for each tenant that matters. Use Loki's own metrics and your existing dashboards, and label results by tenant ID. Run a controlled heavy query from one tenant while a second tenant runs a light, routine query, and note whether the light query slows. This is the evidence you will compare against later. Done when you have a saved baseline with the heavy-tenant and light-tenant numbers side by side, and the test is repeatable.

  4. Set shuffle sharding for the query path

    Enable shuffle sharding for the query path first, because it usually delivers the most visible isolation for interactive users. Set the per-tenant shard size in the limits configuration for the noisy tenant only, starting with a small value and a conservative plan for how many queriers each tenant may use. Keep other tenants on the default behavior until the first component is verified. Confirm the exact configuration keys and their behavior in the shuffle sharding documentation for your Loki version before editing production files. Done when the configuration is applied, the query-frontend and queriers have restarted cleanly, and a query from the noisy tenant is served by its assigned queriers as shown in component logs or metrics.

  5. Verify query isolation with tenant-scoped tests

    Repeat the baseline test from the earlier step with the same heavy query from the noisy tenant and the same light query from the other tenant. Compare latency, error rates and queue wait against the baseline. The light tenant should show no meaningful degradation during the heavy run. Also test a failure case: if a noisy tenant's queries are forced to fail or time out, confirm the other tenant still returns results. If the light tenant still degrades, check whether the shard size is too large to isolate anything, or whether the noisy tenant shares the same queriers through another path. Done when the comparison shows the light tenant behaving as in the baseline and the results are written down for the change record.

  6. Extend shuffle sharding to the ruler

    Once the query path is verified, enable shuffle sharding for the ruler using the same per-tenant approach. Rule evaluation for a heavy tenant can otherwise delay alerting and recording rules belonging to other tenants. Apply the change to one tenant first, restart the ruler replicas as your deployment requires, and confirm the rule group for that tenant is assigned to its subset of rulers. Check that rule evaluation for other tenants keeps its normal timing and that alerts for those tenants still fire in a test rule. Done when rule evaluation durations for a neighboring tenant match the baseline and a test alert from that tenant fires as expected.

  7. Extend shuffle sharding to the index gateway

    If your deployment runs a separate index gateway, enable shuffle sharding there last, because index lookups are shared by all query paths and a misconfiguration affects everyone. Apply it to one tenant, confirm that tenant's index requests reach its assigned gateway replicas, and rerun the tenant-scoped comparison from the verification step. Watch for query slowdowns on tenants that were not changed, since an index gateway subset that is too small can increase lookup latency for all users. Done when the index gateway assignments are visible for the changed tenant, and the neighboring tenants' query latency has not moved from the verified baseline.

  8. Roll back and monitor the sharded setup

    Keep a rollback path ready at every stage. Store the prior configuration in version control, so reverting the shard settings for one tenant or one component is a single, reviewed change, followed by a restart of the affected component. After rollback, confirm the tenant returns to the shared pool and its latency matches the baseline. Then set ongoing monitoring of per-tenant query latency, failures and ruler delays, so a change in one tenant's behavior is visible early. Ask your platform team which alerts and dashboards they already use and confirm they can filter by tenant ID. Done when a rollback has been rehearsed in a test environment and the monitoring shows per-tenant views for each sharded component.

How tenant requests map to isolated component subsets

The diagram starts at the authenticating reverse proxy, which is the trust boundary where clients are checked before any request carries an X-Scope-OrgID header into Loki. From there, each tenant's requests are routed to its own shuffle-sharded subset of queriers, and a second tenant lands on a subset that overlaps only partly with the first. Check that the proxy sets or validates the tenant header itself, so clients cannot choose another tenant's ID. The ruler and index gateway follow the same pattern when shuffle sharding is enabled for them.

Two tenants share an overlapping but different querier subset behind one proxy.

Security and operational risks of tenant isolation

Shuffle sharding narrows which components serve each tenant, which helps isolation but adds failure modes of its own. The cards below cover the identity control that must sit in front of Loki, the header handling that can undo tenant boundaries, the capacity effects of small subsets, and the monitoring and change control that keep the layout safe over time.

Proxy is the tenant identity control

Loki has no built-in authentication layer, so the authenticating reverse proxy is the only place that decides who may act as which tenant. Shuffle sharding assumes the tenant ID is trustworthy. Confirm which proxy you run (nginx, HAProxy, OAuth2 Proxy or Pomerium), how it authenticates users, and that every route to Loki, including Grafana data source connections and direct API access, passes through it.

Loki authentication docs

Stripping spoofed tenant headers

Loki identifies tenants by the X-Scope-OrgID header. If the proxy forwards a client-supplied value unchanged, a user can ask for another tenant's data or write into another tenant's streams, and the shard assignment for that tenant is then wrong. Configure the proxy to overwrite or remove any incoming X-Scope-OrgID header and set it only from the verified identity. Test this with a request that carries a foreign tenant ID.

Loki multi-tenancy docs

Uneven capacity in small subsets

A small shard size gives each tenant fewer queriers, rulers or index gateways. Two heavy tenants can land on overlapping subsets, and a tenant with a small subset can saturate it while the rest of the pool sits idle. Before choosing sizes, model how many components each tenant gets, check overlap for your largest tenants, and confirm that the remaining components can absorb a failed subset.

Watching per-tenant hotspots

Isolation only holds if you can see when one tenant starts to dominate its subset. Track per-tenant query volume, query latency, rejected requests and ingestion errors so that a new heavy workload is noticed before it degrades a neighbor. Ask your team which dashboards and alerts will cover each component that uses shuffle sharding, and who responds when a tenant crosses a threshold.

Change control for limits and sharding

Shard sizes and per-tenant limits are runtime configuration, and a change can move a tenant onto different components or raise its share of the cluster. Keep these settings in version control, review each change with the tenant owner, and record which tenant was changed and why. Plan a rollback step and check the effect on existing tenants after every change, since a change for one tenant can alter the load seen by others.

Questions buyers ask about shuffle sharding cost, effort and scope

Can our own team set up shuffle sharding for Loki without a partner?

Yes, if your team already runs Loki in production and has the metrics to see which tenants load which components. The settings themselves are configuration changes in the Loki config, but getting them right depends on knowing your tenant mix, your query patterns and how each component behaves under load. Teams that have not yet handled a noisy-tenant incident often find the hard part is the baseline and the rollout plan, not the YAML. A partner is useful when you want the design reviewed, the change tested in a non-production cluster first, and the results documented for your operations team.

What drives the effort for shuffle sharding work?

The main drivers are the size of the cluster, the number of tenants, which components you enable shuffle sharding on, and how mature your observability is. Enabling it only on the query path is a smaller job than covering the query path, the ruler and the index gateway together, because each component has its own shard sizing and its own failure behavior to test. A cluster with dozens of tenants and clear per-tenant dashboards gives the design much to work from. A cluster with one shared tenant and thin metrics needs more discovery before any setting is chosen.

What do we need to provide before work starts on shuffle sharding?

Expect to provide four things: an inventory of tenants with their owners and expected query behavior, baseline metrics for query latency, errors and component load over a representative period, read access to the Loki configuration and deployment, and change windows in which settings can be applied and observed. Without the baseline, there is nothing to compare against after the change, so you cannot tell whether isolation improved. Change windows matter because shard assignments affect live query routing, and the rollout needs time to be watched before it is called complete.

How long does shuffle sharding take to deliver?

Duration depends on scope rather than on a fixed number. A query-path-only change on a small cluster with good metrics moves faster than a multi-component change on a large cluster where tenants have uneven load and few dashboards. Plan time for discovery, design review, a test in a non-production environment, a staged rollout and a period of observation after each change. The quote or the written scope should state the phases and the review points, so you can see where time is spent and where your team's input is needed.

What should a quote for shuffle sharding include?

A useful quote lists the components in scope (query path, ruler, index gateway or a subset), the cluster and tenants covered, the discovery and baseline work, the configuration changes and where they are applied, the test environment and load tests, the rollout plan with rollback steps, the documentation handed over, and any post-change observation period. It should also state what the client provides, what is excluded, and how changes after sign-off are handled. Ask whether the quote covers one-time configuration work only or also ongoing tuning as tenants grow.

Is a fixed-scope engagement or a retainer better for this work?

A fixed-scope engagement suits a defined change: one cluster, a named set of components and a clear finish point with written deliverables. A retainer suits cases where tenant counts and load patterns keep changing, so shard sizes need periodic review, upgrades need checking against the settings, and your team wants support on call. Many teams start with a fixed-scope design and rollout, then decide whether ongoing review is worth it once they see how often tenant mixes shift. DeployOpen offers both models, and the written scope determines which fits.

What goes wrong if shuffle sharding is configured without a baseline?

Without a baseline, teams often change shard sizes on a guess, then cannot tell whether a slow query came from the change, from a new tenant or from normal variation. Too small a shard can leave a tenant with too few queriers or index gateways, so its own queries slow down. Too large a shard gives little isolation, since heavy tenants still reach most of the pool. Confirm with your team which metrics will be recorded before and after each change, and agree the rollback steps in writing before the rollout begins.

Verifying isolation after rollout

This sequence shows whether shuffle sharding actually protects other tenants from one tenant's heavy queries or failures, component by component, before the setting goes to production.

  1. Record a baseline for every tenant

    Before changing anything, the platform team captures query latency, error rates and component queue behavior for each tenant in a non-production cluster that mirrors the production configuration. Use the same dashboards you will use after the test, so the numbers are comparable. Keep the query mix, time ranges and data volume as close to typical traffic as you can. The step is done when you have a written baseline per tenant and per component, with the time window it covers.

  2. Confirm the shuffle sharding settings in effect

    Someone who owns the Loki configuration checks which components have shuffle sharding enabled and the shard size applied to each tenant. Confirm the settings for the query path, the ruler and the index gateway separately, because each is configured on its own. Check the effective per-tenant limits on the running cluster, not only the files in your repository, since overrides can change what is applied. The step is done when the effective values match the design and the test plan lists them.

  3. Run a controlled heavy query for one tenant

    Choose a test tenant and run a deliberately expensive query, such as a wide time range with a broad line filter, from a client that represents that tenant. Run it while other tenants continue their normal baseline traffic. Record which queriers handle the heavy tenant's requests, since shuffle sharding should confine them to that tenant's subset. The step is done when the heavy run has finished or been stopped and its start and end times are logged.

  4. Measure latency and errors for other tenants

    During and after the heavy run, compare latency, error counts and query queue wait for the other tenants against the baseline captured earlier. Look at the tenants that share queriers or index gateways with the heavy tenant under the current shard size, not only at a random sample. Any change in latency or errors should be matched to a time window and a component in your logs and metrics. The step is done when each non-test tenant has a recorded comparison with the baseline and a clear yes or no on impact.

  5. Simulate a failure for one tenant

    Repeat the test with a failure instead of load, for example a tenant whose queries repeatedly return errors or time out, so you can see whether failing requests stay with that tenant's subset of components. Keep the failure contained to the test environment and document how it was induced so the test can be reproduced. Check that other tenants keep their query success rate and that ruler or index gateway errors do not spread across tenants that were placed on different shards. The step is done when the failure run and its effect on other tenants are recorded.

  6. Repeat the test for each enabled component

    Run the heavy-query and failure tests separately for the query path, the ruler and the index gateway, since each component has its own sharding configuration and can show different results. Restore the environment to the baseline state between runs and note any leftover effects. Where a component is not enabled, record that it was skipped rather than assuming it is protected. The step is done when each enabled component has its own result set and the skipped components are listed.

  7. Decide on shard size and document the result

    Review the results with the platform owners and decide whether the current shard size gives enough isolation, needs adjustment, or needs a separate test with a different tenant mix. Write down the settings tested, the workloads used, the measured differences and any remaining gaps. Keep the report with the configuration in version control so future changes can be checked against it. The step is done when a signed-off report exists and the production rollout decision references it.

  8. Repeat the test after scaling changes

    Rerun the sequence after significant changes to cluster size, shard size, tenant onboarding or Loki version, because each can change which tenants share components. The load patterns you use can come from the load testing approach covered in the sibling topic on load testing Loki with k6, which describes how to simulate realistic push and query traffic. The step is done when the post-change results are compared with the signed-off report and any new gap has an owner.

What DeployOpen delivers for shuffle sharding in your cluster

DeployOpen can implement shuffle sharding in a Loki cluster you run in your own infrastructure, starting with a review of the current topology. That review establishes which components are deployed, how they are scaled, whether auth_enabled is set, how tenants are identified through the X-Scope-OrgID header, and which query, ruler and index gateway paths carry the heaviest tenant traffic. The output is a written decision on which paths get shuffle sharding first, since the query path, the ruler and the index gateway are configured separately and each needs its own shard sizing. Confirm during scoping whether your Loki version and deployment mode support the settings you plan to use, and confirm the exact configuration keys against the Loki shuffle sharding documentation for the version you run.

DeployOpen then configures each component in turn: the per-tenant shard size settings on the query path, the ruler and the index gateway, the matching limits for each tenant, and the rollout order for changing them on a live cluster. Each change is recorded with the reason for the chosen shard size, so the operations team can see why a given tenant received the capacity it did. Testing covers the tenant-level checks: queries from one tenant are confirmed to land on its assigned subset of queriers, and a heavy or failing tenant is confirmed not to degrade the others. DeployOpen implements and documents this setup. It does not guarantee any particular performance, latency or isolation result, because outcomes depend on your tenant mix, query patterns, hardware and object storage. Load testing results, where agreed, are reported as measurements of your environment, not as promised targets.

Handover includes operator documentation covering the configuration as built, the verification steps, how to add a tenant, how to read the per-tenant usage signals that show whether a shard is too small or too large, and the procedure for changing shard sizes safely. Scope, deliverables and timelines are agreed in writing before work starts, and the effort depends on the number of components involved and how many tenants need individual treatment. Ask any provider to state in the quote which components are covered, whether tenant verification is included, what documentation is delivered and whether follow-up tuning is part of the fixed scope or a separate retainer.

How DeployOpen scopes and supports Loki tenant isolation

DeployOpen plans, implements and documents shuffle sharding for Loki inside your own infrastructure, starting from your tenant list and the failure modes you need to contain. The work covers the query path, the ruler and the index gateway, each configured to match how your teams and customers actually use the cluster.

How we scope

  • Inventory tenants, their query patterns and which components they share in your current Loki cluster.
  • Decide which of the query path, ruler and index gateway need shuffle sharding and which can stay shared.
  • Agree in writing the shard sizes, per-tenant settings, test cases and deliverables before work starts.
  • Confirm with your team which Loki version and deployment mode the scope applies to before design begins.

How we build

  • Set per-tenant shard sizes and enable shuffle sharding for each component in scope, in your staging environment first.
  • Test that a heavy or failing tenant stays confined to its assigned queriers, rulers or index gateways.
  • Run controlled load tests to confirm other tenants keep their query latency during a noisy-tenant event.
  • Record each configuration key, its default and the reason for the value chosen for your environment.

How we hand over

  • Deliver a runbook covering how to add a tenant, change its shard size and verify its assignment.
  • Document the trade-offs between smaller shards for isolation and larger shards for resilience and capacity.
  • Walk your platform and on-call teams through the dashboards and alerts used to spot tenant imbalance.
  • Provide a retest plan so your team can repeat the isolation checks after future upgrades or scaling changes.

How we support

  • Ongoing support, upgrades and continuous testing are available as a retainer after handover.
  • Re-check shard assignments and isolation behavior when Loki versions, tenant counts or components change.
  • Review the shuffle sharding configuration alongside query scheduling, limits and caching changes.
  • Quotes follow from the written scope, so ask for the scope, deliverables and retainer terms in one document.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.