Building a New Parse Server & MongoDB Atlas-Based Application

Share this article

Building a New Parse Server & MongoDB Atlas-Based Application

This article was originally published on mongoDB. Thank you for supporting the partners who make SitePoint possible.

Whether you’re migrating from the deprecated Parse.com (api.parse.com) or building a new application, the Parse Server community is alive and strong, and since Parse Server version 2.1.11, there is support for MongoDB 3.2 which makes MongoDB Atlas an ideal back-end for Parse Server based applications.

Existing hosted Parse / api.parse.com users can migrate their back-end using Parse’s Database Migration tool directly to MongoDB Atlas using a connection string like the following (with bold items replaced with your details):

mongodb://username:password@node1.mongodb.net:27017,node2.mongodb.net:27017,node3.mongodb.net:27017/applicationDbName?replicaSet=clusterName-shard-0&ssl=true&authSource=admin

We will learn in this blog post:

  • How to deploy a MongoDB Atlas cluster
  • How to deploy the Parse Server (in our case we will show how to do so using AWS Elastic Beanstalk quick start, but updated to use the newest version of Parse Server)
  • How to configure Parse Server to connect to MongoDB Atlas
  • How to confirm connectivity

How to Set Up A New Sample Parse Server Application with A MongoDB Atlas Back End

  1. Deploy MongoDB Atlas cluster
  2. Consider sizing options but start small for a hello world style application. You can always scale later (MongoDB Atlas allows you to migrate to larger instances with no downtime to your database).
  3. Register for MongoDB Atlas at mongodb.com/atlas
  4. Build and deploy your first cluster (we’ll use a small M10 instance-sized replica set for our example, and deploy it into the US East region) Parse Server Clusters
  5. MongoDB Atlas Cluster
  6. We’ll Create a user with at least readWrite on the applicationDbName database (or the user with readWriteAnyDatabase@admin which gets created automatically will do) Parse Server Mongo DB Atlas
  7. For testing purposes, we will open IP address to all IP addresses initially (0.0.0.0/0): Later we should leave only open to our application servers’ public IP addresses. Parse Server MongoDB Atlas
  8. Choose where and how you want to deploy the Parse Server:
  9. Many options are described here, some of which provide easier set-ups than others. AWS Elastic Beanstalk and Heroku are easy options.

For purposes of this blog post, we will go with AWS Elastic Beanstalk for the Parse Server quick start, by following the URL below (requires AWS account):

  1. Click for AWS Elastic Beanstalk for the Parse Server quick start deployment example.
  2. But we will make sure we install Parse Server 2.1.12 or higher, e.g. in parse-server-example, ensure that the package.json file includes “parse-server”: “~2.2.16” (where 2.2.16 is the current latest at time of this writing).
  3. The Parse Server Example can be downloaded from github: GitHub Parse Server Example Repo
  4. If we extract the Zip file, we can edit the version in package.json Parse Server Example GitHub Download Button
  5. We’ll set the Parse Server version to 2.2.16 (latest at time of writing) Package.json with Parse Server Installation Info
  6. We’ll select the files in the directory and re-compress them into a new Zip file Files compression
  7. We’ll upload our new zip file so that it can be deployed Uploading new zip file
  8. Configure Parse Server to connect to MongoDB Atlas
  9. Inside the AWS Elastic Beanstalk UI AWS Elastic Beanstalk UI
  10. We’ll navigate to the “Configuration” section on the left-hand menu Parse Server
  11. Then we’ll navigate to the “Software Configuration” section by clicking the gear icon, and scroll down to the “Environment Properties” section Environment Properties
  12. In the environment properties, we’ll use any myAppId, myFileKey, mySecretMasterKey we want (since this is a new application, we set these).
  13. We’ll set the to that which shows near the top of our AWS Elastic Beanstalk application UI to the right of “URL: …“ Setting the SERVER_URL
  14. We’ll set the DATABASE_URI as follows (replacing the bold text with our specific cluster’s details)
  15. mongodb://username:password@node1.mongodb.net:27017,node2.mongodb.net:27017,node3.mongodb.net:27017/applicationDbName?replicaSet=clusterName-shard-0&ssl=true&authSource=admin
  16. We can see that the appropriate MongoDB URI should be inside of MongoDB Atlas’s “Connect” UI for the cluster, under the Driver connections section Location of appropriate MongoDB URI
  17. Test to confirm connectivity of our example application to Parse Server and the MongoDB Atlas backend:
$ curl -X POST \
> -H "X-Parse-Application-Id: newParseTest" \
> -H "Content-Type: application/json" \
> -d '{"score":1337,"playerName":"John Doe","cheatMode":false}' \
> http://parseserver-365pk-env.us-east-1.elasticbeanstalk.com/parse/classes/GameScore
Returns:
{
  "objectId": "YMgGV6kVTP",
  "createdAt": "2016-08-26T14:54:26.580Z"
}
$ curl -X GET \
> -H "X-Parse-Application-Id: newParseTest" \
> -H "X-Parse-Master-Key: MASTER_KEY" \
> http://parseserver-365pk-env.us-east-1.elasticbeanstalk.com/parse/classes/GameScore
Returns:
{
  "results": [
    {
      "objectId": "YMgGV6kVTP",
      "score": 1337,
      "playerName": "John Doe",
      "cheatMode": false,
      "createdAt": "2016-08-26T14:54:26.580Z",
      "updatedAt": "2016-08-26T14:54:26.580Z"
    }
  ]
}

Now you can use the SDK to build a new application pointing to your instance of Parse Server + MongoDB Atlas!

Frequently Asked Questions on Building a New Parse Server MongoDB Atlas-Based Application

What are the benefits of migrating from Parse to MongoDB Atlas?

Migrating from Parse to MongoDB Atlas offers several benefits. Firstly, MongoDB Atlas is a fully-managed cloud database developed by the same people that build MongoDB. It automates time-consuming administration tasks such as infrastructure provisioning, database setup, ensuring availability, global distribution, backups, and more. Secondly, MongoDB Atlas provides robust security features including IP whitelisting, automated patching, and encryption at rest. Lastly, it offers built-in operational and security best practices, providing detailed insights into database performance and query optimization.

How can I ensure a smooth migration from Parse to MongoDB Atlas?

To ensure a smooth migration, it’s crucial to plan ahead. Start by understanding the structure of your Parse application and how it interacts with your database. Then, create a migration plan that includes a timeline, resources needed, and potential risks. Test the migration process in a non-production environment before moving to production. Also, consider using MongoDB’s migration tools and services to assist with the process.

What are the key differences between Parse and MongoDB Atlas?

Parse is a Backend as a Service (BaaS) platform that provides developers with a suite of tools for building mobile apps. On the other hand, MongoDB Atlas is a Database as a Service (DBaaS) platform that provides a fully-managed MongoDB database in the cloud. While Parse includes features for user management, push notifications, and social integration, MongoDB Atlas focuses on providing a robust, scalable, and secure database solution.

How does MongoDB Atlas ensure data security?

MongoDB Atlas provides several security features to protect your data. These include network isolation using Amazon VPC, encryption at rest using your own key management system, encryption in transit with TLS, role-based access control, IP whitelisting, and automated patches.

Can I use MongoDB Atlas with my existing Parse application?

Yes, you can use MongoDB Atlas with your existing Parse application. You’ll need to migrate your data from Parse to MongoDB Atlas, and update your application to use the MongoDB Atlas connection string. This process may require some code changes, so it’s important to test thoroughly before deploying to production.

What tools and services does MongoDB offer to assist with migration?

MongoDB offers a variety of tools and services to assist with migration. These include the MongoDB Atlas Live Migration service, which can help you migrate your data from Parse to MongoDB Atlas with minimal downtime. They also offer consulting services to assist with planning and executing your migration.

How does MongoDB Atlas handle scalability?

MongoDB Atlas provides automatic scaling of your database infrastructure. This means it can adjust to changes in workload and traffic patterns, ensuring your application remains performant and responsive. You can also manually scale your clusters at any time.

What support options are available with MongoDB Atlas?

MongoDB Atlas offers 24/7 support, with a team of experts available to assist with any issues. They also provide a comprehensive set of documentation, tutorials, and guides to help you get the most out of the platform.

How does MongoDB Atlas compare to other cloud database solutions?

MongoDB Atlas stands out for its robust feature set, scalability, and security features. It’s a fully-managed solution, meaning it takes care of infrastructure provisioning, database setup, backups, and more. It also offers global distribution, allowing you to deploy your data across multiple regions for improved performance and availability.

What are the costs associated with using MongoDB Atlas?

The cost of using MongoDB Atlas depends on several factors, including the size of your database, the number of requests your application makes, and the regions in which your data is deployed. They offer a variety of pricing plans to suit different needs, including a free tier for small projects.

Andrew DavidsonAndrew Davidson
View Author

Andrew is a product manager at MongoDB responsible for MongoDB's suite of cloud products including MongoDB Atlas and Cloud Manager. Andrew played a major role in the success of MongoDB's on-prem management tool, Ops Manager. Before joining MongoDB, Andrew worked with Google for 3 years after earning his physics degree at UC Berkeley.

atlasmariapmongodbparse serversponsored
Share this article
Read Next
Get the freshest news and resources for developers, designers and digital creators in your inbox each week
Loading form