Home > Technology peripherals > It Industry > Building a New Parse Server & MongoDB Atlas-Based Application

Building a New Parse Server & MongoDB Atlas-Based Application

Lisa Kudrow
Release: 2025-02-16 11:41:12
Original
263 people have browsed it

Building a New Parse Server & MongoDB Atlas-Based Application

Key Points

  • The Parse Server community continues to thrive and now supports MongoDB 3.2, making MongoDB Atlas an ideal backend for Parse Server-based applications. Existing users can use Parse's database migration tool to migrate directly to MongoDB Atlas.
  • To set up a new Parse Server application using the MongoDB Atlas backend, you need to deploy the MongoDB Atlas cluster, deploy Parse Server, configure Parse Server to connect to MongoDB Atlas, and confirm connectivity. AWS Elastic Beanstalk and Heroku are easy options for deploying Parse Server.
  • Migrating from Parse to MongoDB Atlas offers many advantages such as automated management tasks, powerful security features, and detailed insights into database performance and query optimization. MongoDB Atlas also provides automatic scaling of the database infrastructure to ensure your applications remain high performance and responsive.

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

Whether you are migrating from a deprecated Parse.com (api.parse.com) or building new applications, the Parse Server community is full of vitality and has supported MongoDB since Parse Server 2.1.11 3.2, which makes MongoDB Atlas an ideal backend for Parse Server-based applications.

Existing managed Parse/api.parse.com users can use Parse's database migration tool to migrate their backend directly using the following connection string (replace bold items with your details):

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

We will learn from this blog post:

  • How to deploy MongoDB Atlas cluster
  • How to deploy Parse Server (In this case, we will show how to deploy using AWS Elastic Beanstalk Quick Start, but has been updated to use the latest version of Parse Server)
  • How to configure Parse Server to connect to MongoDB Atlas
  • How to confirm connectivity

How to set up a new example of how to use MongoDB Atlas backend Parse Server application

  1. Deploy MongoDB Atlas Cluster
  2. Consider the size option, but for hello world-style applications, start at a small scale. You can scale at any time (MongoDB Atlas allows you to migrate to larger instances without interrupting your database).
  3. Register MongoDB Atlas
  4. Build and deploy your first cluster (we will use a small M10 instance-sized replica set as an example and deploy it to the Eastern U.S. region) Building a New Parse Server & MongoDB Atlas-Based Application
  5. Building a New Parse Server & MongoDB Atlas-Based Application
  6. We will create a user with at least read and write permissions to the applicationDbName database (or automatically created users with readWriteAnyDatabase@admin permissions can also be) Building a New Parse Server & MongoDB Atlas-Based Application
  7. For testing purposes, we initially open the IP address to all IP addresses (0.0.0.0/0): later, we should only open it to the public IP address of our application server. Building a New Parse Server & MongoDB Atlas-Based Application
  8. Select where and how you want to deploy Parse Server:
  9. Many options are described here, some of which offer simpler settings than others. AWS Elastic Beanstalk and Heroku are simple options.

For the purposes of this post, we will use AWS Elastic Beanstalk for a quick start deployment of Parse Server by following the following URL (an AWS account required):

  1. Click here to view an example of a quick start deployment of AWS Elastic Beanstalk Parse Server.
  2. But we will make sure that Parse Server 2.1.12 or later is installed, for example, in parse-server-example, make sure that the package.json file contains "parse-server": "~2.2.16" (where 2.2.2. 16 is the latest version at the time of writing).
  3. Parse Server example can be downloaded from github: Building a New Parse Server & MongoDB Atlas-Based Application
  4. If we extract the Zip file, we can edit the version in package.jsonBuilding a New Parse Server & MongoDB Atlas-Based Application
  5. We set the Parse Server version to 2.2.16 (the latest version at the time of writing) Building a New Parse Server & MongoDB Atlas-Based Application
  6. We will select files in the directory and recompress them into a new Zip fileBuilding a New Parse Server & MongoDB Atlas-Based Application
  7. We will upload a new zip file so that it can be deployedBuilding a New Parse Server & MongoDB Atlas-Based Application
  8. Configure Parse Server to connect to MongoDB Atlas
  9. Inside the AWS Elastic Beanstalk UIBuilding a New Parse Server & MongoDB Atlas-Based Application
  10. We will navigate to the "Configuration" section in the menu on the leftBuilding a New Parse Server & MongoDB Atlas-Based Application
  11. We will then navigate to the "Software Configuration" section by clicking the gear icon and scroll down to the "Environmental Properties" section Building a New Parse Server & MongoDB Atlas-Based Application
  12. In the environment properties, we will use any myAppId, myFileKey, mySecretMasterKey we want (because this is a new application, so we set these).
  13. We will set up content to display near the top of our AWS Elastic Beanstalk application UI, located to the right of "URL:..."Building a New Parse Server & MongoDB Atlas-Based Application
  14. We set DATABASE_URI as follows (replace bold text with details for our specific cluster)
  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 located in the cluster "connection" UI of MongoDB Atlas, under the driver connection section Building a New Parse Server & MongoDB Atlas-Based Application
  17. Test to confirm the connectivity of our sample application to Parse Server and MongoDB Atlas backend:
<code>mongodb://username:password@node1.mongodb.net:27017,node2.mongodb.net:27017,node3.mongodb.net:27017/applicationDbName?replicaSet=clusterName-shard-0&ssl=true&authSource=admin</code>
Copy after login
Copy after login
<code>$ 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</code>
Copy after login
<code>返回:
{
  "objectId": "YMgGV6kVTP",
  "createdAt": "2016-08-26T14:54:26.580Z"
}</code>
Copy after login
<code>$ 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</code>
Copy after login

You can now use the SDK to build a new application pointing to your Parse Server MongoDB Atlas instance!

Frequently Asked Questions about Building New Parse Server MongoDB Atlas-based Applications

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

Migrating from Parse to MongoDB Atlas offers several benefits. First, MongoDB Atlas is a fully managed cloud database developed by the same person who built MongoDB. It automates time-consuming management tasks such as infrastructure configuration, database setup, ensuring availability, global distribution, backup, and more. Second, MongoDB Atlas provides powerful security features including IP whitelisting, automated patching, and encryption at rest. Finally, it provides built-in operational and security best practices, providing detailed insights into database performance and query optimization.

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

To ensure a smooth migration, planning ahead is crucial. First understand the structure of the Parse application and how it interacts with the database. Then, create a migration plan that includes a schedule, resources required, and potential risks. Test the migration process in a non-production environment before migrating to a production environment. Also, consider using MongoDB's migration tools and services to assist in this process.

What are the main 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 applications. MongoDB Atlas, on the other hand, is a database-as-a-service (DBaaS) platform that provides fully managed MongoDB databases in the cloud. While Parse includes features such as user management, push notifications, and social integration, MongoDB Atlas focuses on providing powerful, scalable, and secure database solutions.

How to ensure data security with MongoDB Atlas?

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

Can I use MongoDB Atlas with my existing Parse application?

Yes, you can use MongoDB Atlas with your existing Parse application. You need to migrate your data from Parse to MongoDB Atlas and update your application to connect strings using MongoDB Atlas. This process may require some code changes, so it is important to thoroughly test before deploying to a production environment.

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

MongoDB provides a variety of tools and services to assist with migration. These tools include the MongoDB Atlas Live Migration Service, which helps you migrate data from Parse to MongoDB Atlas with minimal downtime. They also provide consulting services to assist in planning and performing your migration.

How does MongoDB Atlas handle scalability?

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

What support options do MongoDB Atlas provide?

MongoDB Atlas provides 24/7 support, with a team of experts ready to assist with any issues. They also provide comprehensive documentation, tutorials, and guides to help you make the most of the platform.

How does MongoDB Atlas compare to other cloud database solutions?

MongoDB Atlas stands out for its powerful feature set, scalability and security features. It is a fully managed solution, which means it is responsible for infrastructure configuration, database setup, backup and more. It also offers global distribution, allowing you to deploy data across multiple regions for improved performance and availability.

How much does it cost to use MongoDB Atlas?

The cost of using MongoDB Atlas depends on a number of factors, including the size of the database, the number of requests issued by the application, and the area where the data is deployed. They offer a variety of pricing plans to meet different needs, including a free tier for small projects.

All image links are retained in original format.

The above is the detailed content of Building a New Parse Server & MongoDB Atlas-Based Application. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template