How suitable would Rama be as a replacement for Firestore realtime db

83 views
Skip to first unread message

Iman A

unread,
Aug 4, 2024, 8:53:46 PM8/4/24
to rama-user

I’m developing a real-time collaborative application that relies on real-time database functionality. I’m evaluating whether Rama would be a better fit than Firestore for this use case. Specifically:

  • Does Rama offer native support for CRDTs (Conflict-free Replicated Data Types) to manage concurrent data updates?
  • How does Rama’s PState management compare to Firestore’s real-time data synchronization capabilities?
Thanks

Nathan Marz

unread,
Aug 4, 2024, 11:30:07 PM8/4/24
to rama...@googlegroups.com
Since Rama colocates computation and storage, Rama doesn't need CRDTs for many use cases that otherwise require CRDTs when using databases. In other cases, you can just use whatever CRDT library you want and store those directly within Rama's PStates.

For example, counting is one use case which often needs CRDTs with databases. With Rama, you would structure a Rama module to run all events for an entity on the same partition, which eliminates any possible race condition. For example here's a simple module that supports many different users incrementing the count for an entity:

public class CollaborativeExampleModule implements RamaModule {
  @Override
  public void define(Setup setup, Topologies topologies) {
    setup.declareDepot("*incrementsDepot", Depot.hashBy(Ops.IDENTITY));

    StreamTopology s = topologies.stream("entity");
    s.pstate("$$entityCounts", PState.mapSchema(String.class, Integer.class));
    s.source("*incrementsDepot").out("*entityid")
     .compoundAgg("$$entityCounts", CompoundAgg.map("*entityId", Agg.count()));
  }
}

A user incrementing an count would simply be an append to that depot, like so:

incrementsDepot.append("someEntityId");

When that call returns, the user's increment has been applied to that entity (along with any others that were happening concurrently).

For document editing, you can just store the text CRDT from any JVM library directly in the PState and then update/query it directly. Rama modules are just running plain Java code after all.

Rama's reactive queries are the analogue of Firestore's real-time data synchronization capabilities. They allow you to subscribe to any query on any PState, and changes are reported to the client with minimal information (called "diffs"). You can read more about those here: https://redplanetlabs.com/docs/~/pstates.html#_reactive_queries

Some other differences between Rama and Firestore:
  • Rama allows any data structures and any types to be stored in PStates/depots, whereas Firestore is limited to documents, collections, and its primitive types
  • Firestore is a hosted cloud product, Rama clusters are operated in your own environment. We provide one-click deploys for AWS and Azure.

--
You received this message because you are subscribed to the Google Groups "rama-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rama-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rama-user/0dad314b-ce67-4256-a0b3-f886aa2b3895n%40googlegroups.com.

Iman A

unread,
Aug 5, 2024, 11:45:45 AM8/5/24
to rama-user
Got it, so in terms of latency times as it relates to reactive queries, is there any improvement in latency response times. Firestore guarantees 30ms (utilizes polling) while Firebase realtime db is 10ms (utilizes websockets). If so, how does Rama achieve faster latency times which may be beneficial for storing constant stream of data/events and fast updates to users UI.

Nathan Marz

unread,
Aug 5, 2024, 12:14:34 PM8/5/24
to rama...@googlegroups.com
Rama pushes the diff from the server directly to the client when the server detects a change that affects that client. So the latency will be significantly less than 10ms, usually less than 1ms.

Reply all
Reply to author
Forward
0 new messages