Comparing Realtime DBs
Published: 2024-02-22 22:43:27

Realtime databases are a popular choice for developers looking to build applications that require instant updates. They are particularly beneficial for applications that involve collaborative features, messaging systems, live tracking, and real-time analytics. To contextualize this, here are a bunch of examples of applications that greatly benefit from a realtime backend layer:

1. Chat and Messaging Applications: Realtime databases are ideal for chat and messaging applications where instant message delivery and synchronization are crucial. Users can see messages in real time, enabling seamless and interactive conversations.
2. Collaborative Tools: Applications that involve real-time collaboration, such as project management tools, document editing platforms, or whiteboarding applications, can greatly benefit from a realtime database. It allows multiple users to work together simultaneously, seeing each other's changes in real time.
3. Live Tracking and Location-Based Services: Applications that require live tracking, such as ride-sharing services, delivery tracking, or asset management systems, rely on realtime databases to provide accurate and up-to-date location information to users.
4. Real-Time Analytics and Dashboards: Applications that require real-time data visualization and analytics, such as financial platforms, monitoring systems, or IoT (Internet of Things) applications, can leverage realtime databases to display live data and generate real-time insights.
5. Multiplayer Games: Realtime databases are essential for multiplayer games, enabling real-time interactions between players, synchronization of game states, and instant updates of scores and achievements.
6. Auction and Bidding Platforms: Applications that involve auctions, bidding, or real-time bidding systems benefit from realtime databases to ensure that bids are instantly reflected, providing a seamless and fair experience for users.
7. Social Media Feeds: Social media platforms heavily rely on realtime databases to deliver real-time updates of posts, comments, likes, and notifications to users, creating an engaging and interactive user experience.

Three tools that often appear in the conversation of realtime databases are Convex, Supabase, and Firebase. Here, we'll look past the surface level details and go over the actual developer experience when trying to implement realtime on each of these platforms.

### Convex

Convex stands out by providing realtime capabilities out of the box. With Convex, developers get reliable realtime updates without the need for additional configuration or manual intervention. This is achieved through Convex's intelligent query dependency tracking system. When a dependency in a query changes, Convex automatically updates all relevant queries, ensuring that the data remains up to date in real time.

In addition to its built-in realtime capabilities, Convex also offers excellent integration with React. Developers can leverage Convex's React support to seamlessly incorporate realtime updates into their React applications. This abstraction of the realtime functionality simplifies the development process and allows developers to focus on building their applications rather than dealing with the intricacies of realtime data synchronization.

### Supabase

Supabase does technically offer realtime capabilities. However, it requires developers to manually handle refetching data when a row changes. On the other hand, Convex automates this process by updating all queries when a dependency changes.

Some developers also mention that Postgres has realtime capabilities, but it can be challenging to set up and manage. Supabase's realtime feature is built on top of Postgres and Phoenix PubSub, but it still requires effort to configure. However, there are frameworks emerging that simplify the process and offer similar functionality to what Convex provides.

### Firebase

Firebase also provides realtime updates, but it follows a similar approach to Supabase, where developers need to handle row-oriented updates.

When comparing Convex and Firebase, Convex offers better integration with React and abstracts the realtime updates in a more efficient manner. Firebase, on the other hand, pushes the subscription predicate logic to the client, which may not be ideal for all applications. It is worth noting that Convex recommends putting this logic on the server for better security and easier authorization management.

### Wrap-up

Essentially, consider factors such as ease of setup, automatic updates, integration with React, and the level of control over subscription logic. Supabase, Convex, and Firebase each have their strengths and weaknesses in these area. We're biased, but we believe that Convex offering this out of the box is ultimately a superior approach.