Google Cloud offers two modes for its serverless NoSQL database: Firestore Native Mode and Datastore Mode. While Firestore Native mode provides real-time updates and client SDKs, it enforces a lock limit of 1 write per second per document. For telemetry systems updating status records frequently, this can cause transaction aborts.
Analyzing database capabilities reveals that for backend-heavy, high-throughput query applications, Datastore Mode remains the optimal choice.
1. Evaluating Write Locks
In native Firestore, updating a single document more than once per second triggers write contention. In Datastore mode, document updates are distributed across physical entity groups, bypassing this lock boundary for isolated entries.
2. Query Compatibility Issues
Datastore mode supports key projections and ancestor queries, which allow you to query data hierarchies efficiently. Migrating to native Firestore requires rewriting the query architecture to use subcollections and query indexes:
# Example of structured ancestor query in Python GAE
from google.cloud import ndb
class DeviceTelemetry(ndb.Model):
status = ndb.StringProperty()
timestamp = ndb.DateTimeProperty(auto_now_add=True)
def get_device_logs(device_key):
# Query ancestor groups efficiently in Datastore mode
return DeviceTelemetry.query(ancestor=device_key).order(-DeviceTelemetry.timestamp).fetch(50)
Keeping Datastore mode avoids rewrite risks and offers high transaction throughput for device-level updates.