Parse Server Migration on AWS

Parse Server Migration on AWS: With the upcoming Parse shutdown on January 28, 2017, you’re probably already thinking about what to do next. Luckily, Parse developers left its Parse Server as open source and have made it possible to migrate it to another platform. In this post, we’ll guide you through a seamless and cost effective Parse database migration on AWS and MongoDB.

About Parse

Parse was founded in 2011 by Tikhon Bernstam, Ilya Sukhar, James Yu, and Kevin Lacker. Parse is a SaaS (Software as a Service) backend provider for mobile and web applications. They offer services that help mobile developers store data in the cloud, manage identity log-ins, handle push notifications, and run custom code in the cloud. Parse was acquired by Facebook in the spring of 2013.
Parse allows you to easily build applications without building your own backend. It comes with out-of-the-box features such as:

  • Data storage in a document-oriented database
  • Files storage
  • User password and third-party authentication (for example with Facebook)
  • Push notifications
  • Apple In-App Purchases validation

Parse Database Migration Overview

The Parse Server migration on AWS process follows these 3 steps:

  1. Database migration
  2. Files migration
  3. Parse Server migration/deployment

Requirements:

  • AWS Account
  • MongoDB Cloud Manager Account
Migrate Parse DB to Self-Hosted MongoDB
Migrate Parse DB to Self-Hosted MongoDB

Database Migration on AWS

Parse Server uses MongoDB, so you will need to set-up your own MongoDB database to perform the migration. While there are several methods available, Parse developers recommend using mLAb for migration.
mLab is a fully managed cloud database service featuring automated provisioning and scaling of MongoDB databases, backup and recovery, 24/7 monitoring and alerting, web-based management tools, and expert support. mLab’s Database-as-a-Service platform powers hundreds of thousands of databases across AWS, Azure, and Google. It allows developers to focus their attention on product development instead of operations.
Nevertheless, if we observe mLab’s pricing, it may not be the most cost effective option. Instead, we’ll use MongoDB Cloud Manager to create three replica sets on our AWS account.
MongoDB Cloud Manager is a service for managing, monitoring, and backing up a MongoDB infrastructure. In addition, Cloud Manager allows Administrators to maintain a server pool to facilitate the deployment of MongoDB.
To start the process of database migration, we need to create a Deploy MongoDB three replica set on AWS using MongoDB Cloud Manager. For migrating Parse DB, official documentation advises us to keep in mind that the size of our MongoDB database must be at least three times the size of our current amount of data stored using Parse.
Replica set refers to a group of MongoDB instances that hold the same data. The purpose of replication is to ensure high availability in case one of the servers goes down. This reference deployment supports one or three replica sets. In the case of three replica sets, the reference deployment launches three servers in three different Availability Zones (if the region supports it). In production clusters, Amazon Web Services recommends using three replica sets (Primary, Secondary0, Secondary1). All clients typically interact with the primary node for read and write operations.

MongoDB Cluster on AWS with Three Replica Sets
MongoDB Cluster on AWS with Three Replica Sets

 

Low Data Transfer Rate High Data Transfer Rate
Parse Data Storage < 4GB m4.large, 40GB m4.xlarge, 80GB
Parse Data Storage > 4GB m4.large, 80GB m4.xlarge, 80GB

 Instance size recommendation

Deploy MongoDB replica set on AWS using MongoDB Cloud Manager

  1. Login to your MongoDB Cloud Manager account
  2. Click “Build New” and chose Amazon Web Services under New Cloud Servers
  3. Chose “us-east-1” region and provide Access Key Id and Secret Access Key for your AWS account
  4. Click “Create Replica Set”, enter replica set name and click Continue
  5. Use Cloud Manager to back up your data, click Yes
  6. Configure your EC2 Instances (see Instance size recommendation table)
  7. Click “Provision Servers” and wait. Once three server automation agents are visible, click “Continue”
  8. Click “Advanced Setup” in the top right. Then click the wrench icon on the top right of the Replica Set topology view to open the Replica Set editor
  9. Modify the version to 3.0.x latest and click “Apply”
  10. Click “Review & Deploy”, then “Confirm & Deploy”
  11. Expand “Advanced Options”, and click the “Add Option” button (Add the option Startup Option: “failIndexKeyTooLong”; Value: false)
  12. Click “Apply”, and again “Review and Deploy” your changes
  13. Click “Add user” and create a new user with the specs below

database: “admin”
username: “<yourusername>”
roles: root@admin

Connect MongoDB Cloud manager with your AWS account
Connect MongoDB Cloud Manager with your AWS account

Now you can test the connection to your MongoDB Replica Set.
MongoDB_ReplicaSet_URI:

mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]]

Once we’re connected to our MongoDB three replica set, we need to create a user that will be utilized for migrating our data from Parse to our MongoDB. We can create the user with the following commands, and it’s mandatory for the user to have these exact roles enabled.

use database_name
db.createUser({ user: "parse", pwd: "password", roles: [ "readWrite", "dbAdmin" ] })

After we’ve created the MongoDB three replica set and our user, we need to export our data from Parse into the MongoDB replica set.

Export Data from Parse into MongoDB

Parse App Management
Parse App Management

 

  1. Go to the new Parse dashboard > “App Settings” and click on “Migrate to external database”
  2. Provide the MongoDB_ReplicaSet_URI
  3. Click the “Begin the migration” button
  4. Ensure that the data is written to your MongoDB Replica Set.
  5. Once you’re satisfied with the database migration on AWS, you can finalize the transfer in the migration UI
Database migration finished
Database migration finished

NOTE: It is important to note that the Finalize action is irreversible. You will not be able to switch back to the Parse managed database. You will be responsible for any backups and recovery of your data. Only proceed once you have backed up your new database.

Files Migration

Parse Objects can have File fields that allow you to store files such as those for images or pdf documents. Parse keeps files in its own AWS S3 Bucket and Mongo database only stores references (URLs) to them. Migrating a database as described above copies only database data and file references, but not the files themselves. You must move the files to your storage before January 28, 2017 or they will be deleted.
We recommend storing files on S3 bucket in your AWS account.

Parse Server Migration on AWS/Deployment

If we consider that Elastic Beanstalk supports Node.js and enables automatic infrastructure scaling, we see it as the best choice for Parse Server migration on AWS.

To launch Parse Server on AWS Elastic Beanstalk click the following link. This will launch the AWS Elastic Beanstalk deployment flow.

AWS Elastic Beanstalk deployment flow
AWS Elastic Beanstalk deployment flow

Once we’ve created the Elastic Beanstalk environment, we need to deploy our application on it. We’ll do it using eb deploy from the root folder of our application. In order to use the eb deploy command, we need to have ebs cli (elastic beanstalk command line interface) installed on our local machine.
When ebs cli install is complete, in case we didn’t have it installed, we’ll enter the eb init command and select the us-east -1 (N Virginia) region. After that, we will proceed by choosing the name of our application (the name we used for creating the Elastic Beanstalk environment).
Before deploying, we need to create the .ebextesnions folder. In this folder, we’ll create a 01app.config file that will pass the following configuration commands to our Elastic Beanstalk:

option_settings:
 aws:elasticbeanstalk:application:environment:
    PARSE_MOUNT: "/parse"
    APP_ID: <your app id>
    MASTER_KEY: <your master key>
    DATABASE_URI: <your database uri>
    NODE_ENV: "production"
    SERVER_URL: <your server url>
  aws:elasticbeanstalk:container:nodejs:
    NodeCommand: "npm start"
Elastic Beanstalk Container Options
Elastic Beanstalk Container Options
Elastic Beanstalk Environment Properties
Elastic Beanstalk Environment Properties

By using the 01app.config file, we passed the necessary ENVIRONMENT variables and “npm  start” command to our Elastic Beanstalk environment.
If you want to learn more about configuration files for Elastic Beanstalk, please check the following link.
Another way to deploy our application is to take its source code, pack it into a .zip file, and upload it to the S3 on our Elastic Beanstalk environment.

Parse Dashboard

After Parse Server became open source, it was unclear how to manage an application running on your own system. This is where we introduce Parse Dashboard. It will help you manage the apps that you have already moved to Parse Server, your apps that are still on Parse.com, and the apps that are still in development and running on Parse Server on your development machine. You can even manage them all from the same dashboard.
Once the Parse Server migration on AWS is complete, it’s necessary to deploy Parse Dashboard on Elastic Beanstalk.
To deploy Parse Dashboard on Elastic Beanstalk, we need to download Parse Dashboard application code, then initialize the Elastic Beanstalk environment. Then, we will execute the deploy using the eb deploy command. We’ll use the config file inside the .ebexstensions to start the Parse Dashboard and push the necessary data for communicating with our application.
To securely deploy the dashboard without leaking your app’s master key, you will need to use HTTPS and Basic Authentication. You can configure your dashboard for Basic Authentication by adding usernames and passwords to your parse-dashboard-config.json configuration file.

option_settings:
  aws:elasticbeanstalk:application:environment:
    APP_ID: <your app id>
    MASTER_KEY: <your master key>
    APP_NAME: "<your app name>"
    NODE_ENV: "production"
    SERVER_URL: <www.yourparseapp.com>/parse
  aws:elasticbeanstalk:container:nodejs:
    NodeCommand: "npm start dashboard"
Parse Dashboard
Parse Dashboard

Wrap Up

The Parse shut down doesn’t mean the extinction of the apps that were using it. Even Facebook said that they wouldn’t necessarily call it a “shut down”. Instead, they see it as a way of entrusting Parse to the community in the form of an open source Parse Server.
Surely, some time will pass before we see the community fully included in the development of Parse Server, especially when it comes to developing certain functionalities that will be missed after its shut down.
Nevertheless, it’s quite certain that we will still be using Parse Server even after its official “shut down” and in the years to come.
Naturally, the shut down isn’t painless and will create some short term issues due to necessary migrations. However, the availability of the Parse Server code to the community can benefit us in the future.

So, goodbye Parse, and Hello Parse Server.

 

Avatar

Written by

Dzenan Dzevlan

Certified AWS Solutions Architect Associate and SysOps, highly experienced at producing multi-tier, high-availability infrastructure architectures in an enterprise & AWS cloud environment adhering to DR, Business Continuity, availability and security best practice. Founder and co-organizer of the first AWS User Group in Bosnia and Herzegovina .

Related Posts

Alisha Reyes
Alisha Reyes
— July 22, 2019

Cloud Academy’s Blog Digest: July 2019

July has been a very exciting month for us at Cloud Academy. On July 10, we officially joined forces with QA, the UK’s largest B2B skills provider (read the announcement). Over the coming weeks, you will see additions from QA’s massive catalog of 500+ certification courses and 1500+ ins...

Read more
  • AWS
  • Azure
  • Cloud Academy
  • Cybersecurity
  • DevOps
  • Kubernetes
Avatar
Stuart Scott
— July 18, 2019

AWS Fundamentals: Understanding Compute, Storage, Database, Networking & Security

If you are just starting out on your journey toward mastering AWS cloud computing, then your first stop should be to understand the AWS fundamentals. This will enable you to get a solid foundation to then expand your knowledge across the entire AWS service catalog.   It can be both d...

Read more
  • AWS
  • Compute
  • Database
  • fundamentals
  • networking
  • Security
  • Storage
Avatar
Adam Hawkins
— July 17, 2019

How to Become a DevOps Engineer

The DevOps Handbook introduces DevOps as a framework for improving the process for converting a business hypothesis into a technology-enabled service that delivers value to the customer. This process is called the value stream. Accelerate finds that applying DevOps principles of flow, f...

Read more
  • AWS
  • AWS Certifications
  • DevOps
  • DevOps Foundation Certification
  • Engineer
  • Kubernetes
Avatar
Stuart Scott
— July 2, 2019

AWS Machine Learning Services

The speed at which machine learning (ML) is evolving within the cloud industry is exponentially growing, and public cloud providers such as AWS are releasing more and more services and feature updates to run in parallel with the trend and demand of this technology within organizations t...

Read more
  • Amazon Machine Learning
  • AWS
  • AWS re:Invent
  • Machine Learning
Avatar
Stuart Scott
— June 27, 2019

AWS Control Tower & VPC Traffic Mirroring

AWS re:Inforce 2019 is a two-day conference for security, identity, and compliance learning and community building. This year's keynote, presented by AWS Vice President and CIO, Stephen Schmidt, announced the general availability of AWS Control Tower and the new VPC Traffic Mirroring fe...

Read more
  • AWS
  • re:Inforce 2019
  • traffic mirroring
  • VPC
Avatar
Stuart Scott
— June 20, 2019

Working with AWS Networking & Amazon VPC

Being able to architect your own isolated segment of AWS is a simple process using VPCs; understanding how to architect its related networking components and connectivity architecture is key to making it a powerful service. Many services within Amazon Web Services (AWS) require you t...

Read more
  • AWS
  • VPC
Avatar
Stuart Scott
— June 19, 2019

AWS Compute Fundamentals Update

AWS is renowned for the rate at which it reinvents, revolutionizes, and meets customer demands and expectations through its continuous cycle of feature and service updates. With hundreds of updates a month, it can be difficult to stay on top of all the changes made available.   Here ...

Read more
  • AWS
Jeff Hyatt
Jeff Hyatt
— June 18, 2019

10 Steps for an Effective Reserved Instances Strategy

Amazon Web Services (AWS) offers three different ways to pay for EC2 Instances: On-Demand, Reserved Instances, and Spot Instances. This article will focus on effective strategies for purchasing Reserved Instances. While most of the major cloud platforms offer pre-pay and reservation dis...

Read more
  • AWS
  • EC2
Joe Nemer
Joe Nemer
— June 18, 2019

AWS Certification Practice Exam: What to Expect from Test Questions

If you’re building applications on the AWS cloud or looking to get started in cloud computing, certification is a way to build deep knowledge in key services unique to the AWS platform. AWS currently offers 11 certifications that cover major cloud roles including Solutions Architect, De...

Read more
  • AWS
  • AWS Certifications
Avatar
John Chell
— June 13, 2019

AWS Certified Solutions Architect Associate: A Study Guide

The AWS Solutions Architect - Associate Certification (or Sol Arch Associate for short) offers some clear benefits: Increases marketability to employers Provides solid credentials in a growing industry (with projected growth of as much as 70 percent in five years) Market anal...

Read more
  • AWS
  • AWS Certifications
Chris Gambino and Joe Niemiec
Chris Gambino and Joe Niemiec
— June 11, 2019

Moving Data to S3 with Apache NiFi

Moving data to the cloud is one of the cornerstones of any cloud migration. Apache NiFi is an open source tool that enables you to easily move and process data using a graphical user interface (GUI).  In this blog post, we will examine a simple way to move data to the cloud using NiFi c...

Read more
  • AWS
  • S3
Avatar
Chandan Patra
— June 11, 2019

Amazon DynamoDB: 10 Things You Should Know

Amazon DynamoDB is a managed NoSQL service with strong consistency and predictable performance that shields users from the complexities of manual setup. Whether or not you've actually used a NoSQL data store yourself, it's probably a good idea to make sure you fully understand the key ...

Read more
  • AWS
  • DynamoDB