# Live Sync (subscriptions)

Date: 2018-10-23

# Scope

Update data in every browser client connected

# Context

We need to synchronize some data between browser clients in order to keep views updated to the latest data changes. Some of this data are simple entities from the database. Others are "virtual" entities that are not backed in DB like temporary photos, routes, etc.

# Decision

We use GraphQL subscriptions to publish notifications to every connected client. It can be filtered via channelId variable provided at the time of subscribing.

# Consequences

At the beginning, each of our our apps live in one single instance, making subscriptions possible and easy. When these apps need to be horizontally scaled (spawning extra instances), we will need a PubSub or MessageQueue system to keep instances in sync. Pure GraphQL subscriptions can use Google PubSub easily (or RabbitMQ), but there seem to be some bugs (memory leaks) related to graphql-subscription package.

Last updated: 4/6/2020, 12:00:27 PM