Telerik blogs

Which cloud databases will let you work with real-time features? Let’s take a look.

When we build an application, we often need real-time features. We may want notifications, chat features, real-time views, likes or live data displayed.

Building these features from scratch would require complex polling or change data capture techniques on the server, and filtering them would be even more complex. You would then need to setup up your own GraphQL, Rest API or gRPC microservice that supports some kind of Streaming or WebSocket, and it needs to include security. That is just the server end.

Finally, you need to build a client API that connects to this backend, is secure with authentication and authorization controls, and is safe to use in the browser. Luckily, some modern-day cloud database platforms include real-time capabilities out of the box.

Note: This article only mentions real-time features, not all database features.

Firebase

Database (Connection limit): Cloud Firestore (1,000,000+), Real-time Database (200,000+)

Type: gRPC and WebChannels (polling for unsupported browsers), Client SDK

Cloud Firestore from Google Firebase is probably the first fully featured database platform with real time built-in. It is invariably the easiest to use and get started with.

Pros

  • It works immediately with little to no config.
  • Secure with Firestore Rules, RTDB Rules.
  • The real-time capabilities are exactly the same as the querying capabilities.
  • Caching and optimistic updates work well with real time.

Cons

  • Querying is extremely limited. You need to use hard-to-set-up aggregations with Firebase Functions or extraneous reads on the client, and some scenarios are nearly impossible like a scalable follower feed.
  • Client-side SDK may be slower than other products due to its complexity of features.

Supabase

Database (Connection Limit): Postgres (200, 500, or unlimited depending on plan)

Supabase is perhaps the second most popular database platform with real-time capabilities. They have added a bunch of new features in the last year alone.

Type: Postgres Replication, Client SDK

Pros

  • It works immediately with little configuration.
  • Secure with Postgres Policies.
  • Uses SQL instead of noSQL

Cons

  • Extremely limited queries with only one possible filter. You would need to hack the postgres policies or create custom trigger functions to get the desired results in some scenarios.
  • Not easy to use or understand. I created j-supabase to make this work as easy as Firebase does.

Hasura

Database (Connection Limit): Postgres—and meta-postgres compliant databases—Microsoft SQL, Google Big Query, and has plans for many other databases built to scale (10, 100, or unlimited depending on plan).

Hasura is built to scale from small Postgres to large Yugabyte databases.

Type: Polling for live queries, Replication for Subscriptions, GraphQL Subscriptions Client

Pros

  • Uses GraphQL for querying flexibility for real-time subscriptions
  • Secure with Hasura Row Level and Column Level Policies
  • Has both @live queries and Subscriptions

Cons

  • GraphQL can be difficult to set up, particularly with WebSockets
  • Needs an external Auth Provider for setup like Auth.js, Firebase Auth, or NHost for more complex features.

Dgraph

Database: Dgraph

Dgraph is a unique Graph Database that currently is working on releasing a new version in early 2023 after getting a new team of engineers and new funding.

Type: Polling (no connection limits), GraphQL Subscriptions Client

Pros

  • Complex querying capabilities for Subscriptions
  • Works out-of-the-box
  • Secure with GraphQL @auth rules

Cons

  • @auth rules are basic, no complex constraints or equivalent rules for both sql’s “using” and “with check”
  • GraphQL can be difficult to set up, particularly with WebSockets. I created j-dgraph to help with this.
  • Needs an external Auth provider like Auth.js or Firebase Auth.

Fauna

Database: FaunaDB

Fauna is a mixture of a noSQL Document Database and a Graph Database.

Type: Streaming (unlimited but charged by connections), Client SDK

Pros

  • Works out of the box.
  • Streaming querying is limited compared to FQL queries.
  • Can create security rules internally.

Cons

  • Hard to set up queries, must create complex indexes for queries, not very intuitive.
  • Needs an external Auth provider like Auth.js.

Appwrite

Database: Appwrite (built on top of MariaDB)

Appwrite is a noSQL Document Database that can be self-hosted like Supabase. The Cloud version is available in beta (I have access), so I am including it in this list. It most likely will be available for everyone in the next few months.

Type: Event Streaming

Pros

  • Works out of the box.
  • Very easy to subscribe to a stream using client SDK.
  • Built-in Authentication and Permissions.

Cons

  • Database has barely any querying capabilities.

8base

Database: mySQL (no access)

8base is a GraphQL first database platform. You don’t have access to the core mySQL, which makes it interesting.

Type: Event Streaming, GraphQL Subscription

Pros

  • Works out of the box.
  • Uses 8base Authorization and Authentication Workspace.

Cons

  • Must set up external Auth provider, although has built-in auth module to make this easier.
  • Limited queries compared to Hasura, although pretty powerful.

Grafbase

Database: DynamoDB (no access)

Grafbase is meant to be GraphQL first so you don’t think about anything database related.

Type: Event Streaming, GraphQL Subscription

Pros

  • Works out of the box.
  • Secure with GraphQL @auth rules.

Cons

  • Must configure external Auth provider like Auth.js.
  • Limited querying capabilities.

These are the only databases I know of that currently work for real-time data without having to deploy custom middleware. Hopefully we get to see the them mature with the features we need!

Databases to Watch

  • EdgeDB – Built on Postgres, will have GraphQL Subscriptions.
  • SurrealDB – SQL-like database with WebSockets.

About the Author

Jonathan Gamble

Jonathan Gamble has been an avid web programmer for more than 20 years. He has been building web applications as a hobby since he was 16 years old, and he received a post-bachelor’s in Computer Science from Oregon State. His real passions are language learning and playing rock piano, but he never gets away from coding. Read more from him at https://code.build/.

 

 

Comments

Comments are disabled in preview mode.