Hello everyone,
I got an issue related to the graphQL subscriptions, the issue occurs whenever I’m updating single/multiple nodes multiple times in a second (100 updates/second). The problem is that subscription doesn’t catch all updates/events related to the node that it is subscribed to.
I’ve deployed dGraph cluster on my laptop, the cluster is consisted of a single alpha & zero instance. Additionally, I’ve created two Python scripts, one is used to update the nodes, and the other one is used to subscribe to the dGraph and print out the changes.
For example, I’ve tried to update a value of a single node with range of values [1,2,3,…100] in a single second, and subscribe script catches approximately every 15-20 event, like [1, 17, 35, 50…]. When the time interval is increased to 1 update per second, subscription catches all the events.
Here is the schema:
type Sensor @withSubscription {
id: ID!
name: String! @id @search(by: [exact, regexp])
value: Float @search
timestamp: DateTime
}
Subscribe script:
from graphql_client import GraphQLClient
ws = GraphQLClient('ws://localhost:8080/graphql')
def callback(_id, data):
print("got new data..")
print(f"msg id: {_id}. data: {data}")
query = """
subscription {
getSensor(name: "temperatureSensor") {
name
value
timestamp
}
}
"""
sub_id = ws.subscribe(query, callback=callback)
...
What causes this kind of behavior? Is there some kind of limitation regarding the subscriptions related with node updates? According to this topic (Performance of GraphQL Subscriptions), subscription should preform as they are based on queries.
Is there any other approach to “catch event” whenever something gets updated in dGraph.
Thanks in advance!