I installed dgraph + prometheus + grafana in a docker-compose stack and posted a schema. The “processed queries” metrics is constantly increasing (see picture below) without doing anything (I do no queries and no mutations). Is that a normal behavior? If yes, what is it doing in the background?
I am using 20.11.2. I am doing nothing with the setup above (no queries / mutations initiated by me). There are some custom queries and mutations in the schema connecting to another graphql server.
@chewxy any chance that GraphQL subscriptions are translated into DQL polling?
When I think about a chat application with 10k users and everyone is subscribing to a chat, this would mean that the advertised 10k QPS of Dgraph is maxed out easily. Probably with a lot less users, when “standard” queries and mutations are added to that.
If that is indeed true (DQL polling), are event-driven subscriptions on the roadmap yet? This would be very important for medium- to large-scale applications in my opinion.
Yes, that is expected behavior for subscriptions. We also have event-driven lambda webhooks that you can set up. These get triggered anytime there is an add/update or delete mutation that happens. Have you had a look at https://dgraph.io/docs/graphql/lambda/webhook/ yet?
I think @marcown was talking about DQL polling - if that is exposed as an API to the end user. It’d be very useful for “subscriptions” in the DQL world, and I recalled you were working on something like that
As the number of subscriptions is increasing the number of internal DQL Polling requests per second are increasing. It would be better to have subscriptions only event driven, this would significantly reduce the total number of queries per second → less overhead as @maaft wrote
I understand, that’s not on the roadmap for now. You could also look into increasing the polling interval if the number of queries per second is a concern or use the lambda webhook which are event driven.
When I think about a chat application with 10k users and everyone is subscribing to a chat, this would mean that the advertised 10k QPS of Dgraph is maxed out easily. Probably with a lot less users, when “standard” queries and mutations are added to that.
Out of curiosity: What happens when this happens in-between the DQL polling interval? The initial state is: Foo.name = “Bob”
---- polling paused ----
Set Foo.name = “Alice”
Set Foo.name = “Bob”
---- polling continued ----
Are you using a diff to check if you need to trigger a subscription event? If yes, one need to be very careful setting the DQL pollling interval to large values.
The way subscriptions are working right now – they’d run the query, and compare the results with a cached version (or a hash I think) of the previous result. If there’s a difference, that result would be sent out. Otherwise, nothing gets sent.
Okay, thanks for clarification. We definitely need event driven subscriptions then or dgraph users will run into performance issues when they scale their apps.