Skip to content

Commit

Permalink
Add store-gateway components (grafana/phlare#701)
Browse files Browse the repository at this point in the history
This PR adds a store-gateway component similar to what exists in Mimir. https://github.com/grafana/mimir/blob/main/pkg/storegateway/gateway.go

This is still very early, so far I've decided to depends on Mimir to benefits from the shuffle sharding and replication strategy.

I'm not planning to provide any block persistence for now only in-memory. In the future we should use memcached for symbols and tsdb index. The store gateway open block for each tenant within 24h - (now -2h).

Since we don't have a compactor a single gateway can download data duplicated by the replication factor of ingesters. This means we need to deduplicate blocks data while streaming now. To speed this up I've implemented a BufferedIterator that helps merging multiple iterator in parallel. In the future we should probably only download compacted blocks.

For now we always deduplicate even in the ingester code even though no duplication happens there, the PR was big enough and I don't think it's a big concern right now.

The store-gateway also replicate data for high availability which means more duplicates are sent to queriers. We should consider sending block ULID and request querier to select the one to consider.

To keep thing simple for the query path right now, we split the queries using the queryStoreAfter configuration. Ultimately if we dedupe by blocks we should be able to remove that configuration and select blocks that needs to be querier from the querier directly.

---------

Co-authored-by: Christian Simon <simon@swine.de>
  • Loading branch information
cyriltovena and simonswine committed Jun 1, 2023
1 parent 4787ad4 commit acbd4f5
Show file tree
Hide file tree
Showing 99 changed files with 8,512 additions and 1,940 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -8,6 +8,7 @@ bin
*.out

/cmd/phlare/data
pyroscope-sync/
data/
.DS_Store
**/dist
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Expand Up @@ -222,7 +222,7 @@ reference-help: build

$(BIN)/buf: Makefile
@mkdir -p $(@D)
GOBIN=$(abspath $(@D)) $(GO) install github.com/bufbuild/buf/cmd/buf@v1.5.0
GOBIN=$(abspath $(@D)) $(GO) install github.com/bufbuild/buf/cmd/buf@v1.20.0

$(BIN)/golangci-lint: Makefile
@mkdir -p $(@D)
Expand All @@ -242,7 +242,7 @@ $(BIN)/protoc-gen-connect-go-mux: Makefile go.mod

$(BIN)/protoc-gen-go-vtproto: Makefile go.mod
@mkdir -p $(@D)
GOBIN=$(abspath $(@D)) $(GO) install github.com/planetscale/vtprotobuf/cmd/protoc-gen-go-vtproto@v0.3.0
GOBIN=$(abspath $(@D)) $(GO) install github.com/planetscale/vtprotobuf/cmd/protoc-gen-go-vtproto@v0.4.0

$(BIN)/protoc-gen-openapiv2: Makefile go.mod
@mkdir -p $(@D)
Expand Down Expand Up @@ -348,7 +348,7 @@ deploy: $(BIN)/kind $(BIN)/helm docker-image/phlare/build

.PHONY: deploy-micro-services
deploy-micro-services: $(BIN)/kind $(BIN)/helm docker-image/phlare/build
$(call deploy,phlare-micro-services,--values=operations/phlare/helm/phlare/values-micro-services.yaml --set phlare.components.querier.resources=null --set phlare.components.distributor.resources=null --set phlare.components.ingester.resources=null)
$(call deploy,phlare-micro-services,--values=operations/phlare/helm/phlare/values-micro-services.yaml --set phlare.components.querier.resources=null --set phlare.components.distributor.resources=null --set phlare.components.ingester.resources=null --set phlare.components.store-gateway.resources=null)

.PHONY: deploy-monitoring
deploy-monitoring: $(BIN)/tk $(BIN)/kind tools/monitoring/environments/default/spec.json
Expand Down
4 changes: 1 addition & 3 deletions api/agent/v1/agent.proto
Expand Up @@ -10,9 +10,7 @@ import "google/protobuf/timestamp.proto";
service AgentService {
// Retrieve information about targets.
rpc GetTargets(GetTargetsRequest) returns (GetTargetsResponse) {
option (google.api.http) = {
get: "/api/v1/targets"
};
option (google.api.http) = {get: "/api/v1/targets"};
}
}

Expand Down
2 changes: 1 addition & 1 deletion api/buf.gen.yaml
Expand Up @@ -15,7 +15,7 @@ plugins:
out: gen/proto/go
opt:
- paths=source_relative
- features=marshal+unmarshal+size+pool+grpc+pool
- features=marshal+unmarshal+size+pool+grpc+pool+clone
- pool=github.com/grafana/phlare/api/gen/proto/go/google/v1.Profile
- pool=github.com/grafana/phlare/api/gen/proto/go/google/v1.Sample

Expand Down
142 changes: 124 additions & 18 deletions api/gen/proto/go/agent/v1/agent_vtproto.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit acbd4f5

Please sign in to comment.