I think the reason is the following: we use a lot of subscriptions
e.g. we use dgraph like this
docker-compose.yml
version: '3.7'
volumes:
dgraph_data:
prometheus_data:
grafana_data:
services:
zero:
image: dgraph/dgraph:v20.11.2
volumes:
- dgraph_data:/dgraph
ports:
- 5080:5080
- 6080:6080
restart: on-failure
command: dgraph zero --my=zero:5080
alpha:
image: dgraph/dgraph:v20.11.2
volumes:
- dgraph_data:/dgraph
ports:
- 8080:8080
- 9080:9080
restart: on-failure
command: dgraph alpha --whitelist 0.0.0.0/0 --my=alpha:7080 --zero=zero:5080
dgraph.graphql
type Product @withSubscription {
productID: ID!
name: String @search(by: [term])
reviews: [Review] @hasInverse(field: about)
}
type Customer @withSubscription {
username: String! @id @search(by: [hash, regexp])
reviews: [Review] @hasInverse(field: by)
}
type Review @withSubscription {
id: ID!
about: Product!
by: Customer!
comment: String @search(by: [fulltext])
rating: Int @search
}
post with
curl -X POST localhost:8080/admin/schema --data-binary '@dgraph.graphql'
subscribe to ws://localhost:8080/graphql (e.g. using altair client):
subscription {
queryProduct {
name
}
}
and check total queries:
watch -n 1 curl 'localhost:8080/debug/prometheus_metrics |grep "dgraph_num_queries_total"'
example grafana graph:
shouldn’t subscriptions do the opposite? less queries and only push changes? For big databases this is really bad
