MongoDB Atlas Migration Guide
This page was last updated on 2024-10-16
MongoDB Atlas deprecation
In September 2024, MongoDB deprecated the following services:
- Atlas Device Sync
- Atlas Data API
- Atlas Device SDKs
If you have MongoDB Atlas Device Sync deployed today, at a high level your architecture probably looks something like this:
PowerSync alpha support for MongoDB
As of September 20, 2024, PowerSync has developed alpha support for MongoDB as a backend database source. PowerSync’s MongoDB module is not yet considered production-ready.
It is currently available for testing in hosted or self-hosted environments:
- Hosted by us: Refer to Database Connection
- Self-hosted using Docker Compose: An end-to-end demo app is available here. Please refer to its README for further instructions.
Migrating to PowerSync’s MongoDB module would take you to this: (new components in green)
As you can see, this is not a point-and-click migration, however it does enable you to stay on MongoDB and those are the customers we are primarily interested in working with and supporting.
Notable comments on the architecture
- PowerSync handles writes differently from reads. This is because developers typically want to have some business logic running on an authoritative server before allowing a client device to change data in the backend database.
- Reads are partitioned using Sync Rules
- Sync Rules are more flexible than MongoDB Realm Flexible Sync, but are defined server-side and not client-side.
- Writes are queued locally on the device and sent to the backend sequentially.
- The backend can be a very thin API layer or can contain significant amounts of logic — it is up to the developer
- Reads are partitioned using Sync Rules
- The PowerSync Service is generally available as a cloud-hosted service (PowerSync Cloud), or you can self-host using our Open Edition.
- The PowerSync Client SDKs use SQLite under the hood. While there is nothing on a protocol level preventing us from supporting Realm as a client-side database, we are waiting to see whether Realm becomes a community project or not before investing in it, since it would be a significant amount of work for us to support Realm on the client-side.
- The client-side will most likely be where the bulk of migration work takes place for customers migrating from Atlas Device Sync to PowerSync.
- Client-side queries are typically written in SQL. ORM support is available for our JavaScript (React Native and web) and Flutter/Dart Client SDKs.
- PowerSync piggybacks off your existing authentication, however, it uses JWTs. If you were using Atlas Device SDKs for authentication, you will need to implement an authentication provider.
Migration steps
- Connect your database to an instance of the PowerSync Service:
- Using PowerSync Cloud (hosted by us): See Database Connection
- Using PowerSync Open Edition (self-hosted): Refer to our end-to-end demo app available here
- Define Sync Rules in PowerSync — this enables dynamic partial replication so that you don’t need to sync your entire MongoDB database to devices.
- We recommend starting with one or two simple Global Data queries
- Generate a Development Token
- Use our Diagnostics App to validate that MongoDB is syncing into SQLite as expected.
- Implement an app using one of our Client SDKs
- You can continue using your Development Token for a start
- Implement a “Hello World” app to get a feel, or jump straight into pulling the Client SDK into your existing app.
- Verify that downloads from MongoDB are working.
- Implement authentication
- Implement your backend app to accept writes.
- We have Node.js, Django and Rails demos available here.
Implementation notes
PowerSync Service
The PowerSync Service can either be self-hosted or deployed using PowerSync Cloud.
To self-host, you need a Docker environment. Refer to our end-to-end demo app available here which uses Docker Compose.
PowerSync Client SDKs
We are constantly adding additional PowerSync Client SDKs and some of them are under very active development. Below are the release status for each language/platform:
Flavor | Status | ETA |
---|---|---|
JavaScript/Web | Stable | N/A |
React Native & Expo | Stable | N/A |
Flutter/Dart | Stable | N/A |
Kotlin Multiplatform | Beta | V1 ETA 2025Q1 |
Swift | Beta | V1 ETA 2025Q1 |
Node.js | PoC | Alpha ETA 2024Q4 |
.NET | Not Started | Alpha ETA 2025Q1 |
We’ve had customers inquire about the availability of a Rust/C++ SDK. The PowerSync core SQLite extension is implemented in Rust and we can work with customers to integrate PowerSync into their C++ applications. Please reach out to us at hello@powersync.com or schedule a call with us
App Backend
You will need to host a backend that can accept client writes if you do not already have one. The app backend needs to expose an API endpoint to write changes from the PowerSync client.
Additional implementation notes are available here.
Status of MongoDB support in PowerSync
In PowerSync nomenclature, Beta means the package is ready to be used for production given you have adequately tested your use case. We typically don’t make any breaking API changes when moving from Beta to V1. Alpha is a bit more unstable and could have breaking changes when moving to Beta, so we do not recommend using it in production.
Alpha (Completed)
Refer to the instructions above on how to use the current alpha support for MongoDB.
Known Issues (Alpha)
- FIXED: MongoDB -> PowerSync Service replication is not optimized for performance yet. We are targeting 2,000+ operations per second for the Beta.
- FIXED: Unhelpful “Something went wrong” error in the Dashboard when PowerSync IPs have not been allowed for Atlas users (Network Access -> IP Access List)
- FIXED: Unhelpful “Something went wrong” error in the Dashboard when
mongodb://
is used for the URI scheme;mongodb+srv://
must be used - FIXED: Consistency guarantees are currently eventually consistent — that is, operations can arrive out of order on the client. We are targeting to provide causal+ consistency using
changeStreamPreAndPostImages
. Update: Instances can now be configured to use Post Images to resolve consistency issues.
Beta (In Progress - ETA 2024Q4)
- Availability in PowerSync Cloud
- Fully functional diagnostics API
- Validate that TLS connections Just Work ™️ without any additional configuration
- Address all known issues in Known Issues
V1 (Not Started) — Estimated start 2025Q1
Was this page helpful?