Skip to content

Commit

Permalink
pkg/receive: optimize when replication factor is 1 (#1279)
Browse files Browse the repository at this point in the history
If the replication factor is 1, we can skip the replicate() function
call and directly forward the requests. Replicating to 1 endpoint
still exhibits correct behavior but requires another func call and mem.
Additionally, doing this cleanup means that when a node fails to
store a time series locally, the returned error message is about the
local store rather than about failing to replicate to 1 endpoint.
  • Loading branch information
squat authored and brancz committed Jun 26, 2019
1 parent 2431318 commit 11d7798
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/receive/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,9 @@ func (h *Handler) parallelizeRequests(ctx context.Context, tenant string, replic
for endpoint := range wreqs {
n++
// If the request is not yet replicated, let's replicate it.
if !replicas[endpoint].replicated {
// If the replication factor isn't greater than 1, let's
// just forward the requests.
if !replicas[endpoint].replicated && h.options.ReplicationFactor > 1 {
go func(endpoint string) {
ec <- h.replicate(ctx, tenant, wreqs[endpoint])
}(endpoint)
Expand Down

0 comments on commit 11d7798

Please sign in to comment.