Create a gist now

Instantly share code, notes, and snippets.

Deploying Parse Server on AWS (WIP)

Deploying Parse Server on AWS

Note: this is a work-in-progress and will be updated with more information over the next few days.

Intro

This guide will walk you through deploying your own instance of the open-source Parse Server. This would be a good starting point for testing your existing application to see if the functionality provided by the server is enough for your application, and to potentially plan your migration off the Parse Platform.

This guide will walk you through using Elastic Beanstalk (EB), which is an AWS service similar to Heroku. Why use EB rather than Heroku? Elastic Beanstalk does not lock you into Heroku-specific ways of doing things, is likely cheaper to run your backend on than Heroku, and it integrates with other services that AWS offer (and they offer almost everything one needs to run an application these days).

Why AWS? It's an enterprise-grade cloud platform which is miles ahead of competitors when it comes to features, price, and support. IMO if you're not using Heroku (good for when you don't want to manage anything) or bare metal (good for when you want to manage everything), you should be on AWS.

This guide presumes you are using Mac or Linux. Let's get this set up! πŸ’₯

Set up a local Node.js environment

First, we'll set up a local Node.js dev environment. Skip this if you have one set up already.

Install Node.js

I recommend using nvm to install Node.js. It's an easy way to install Node and to manage multiple versions of it on the same machine. Install nvm with:

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.30.2/install.sh | bash

And then install Node.js v4 with:

nvm install 4

Install Mongodb

brew install mongodb

(On Linux: install Mongo with your distro's package manager)

Run Parse Server locally

Clone parse-server-example, which is a barebones example of running the Parse Server with Express.

git clone https://github.com/hassy/parse-server-example

Install dependencies and start the server with:

  • cd parse-server-example
  • npm install
  • npm start

Open http://localhost:1337 in your browser to verify that it's running.

Set up Elastic Beanstalk

Once we have the server running locally, let's deploy it to the cloud.

Get an AWS account

Sign up for an AWS account if you don't have one at https://aws.amazon.com/free

We will need an Access Key Id and a Secret Access Key - you can create them in the AWS Dashboard as described in http://docs.aws.amazon.com/general/latest/gr/getting-aws-sec-creds.html

Install the CLI

First, we need to install Elastic Beanstalk command-line tools (EB CLI):

Install with Homebrew on a Mac:

brew install awsebcli

Or with pip on Linux:

pip install awsebcli

(This command should be all you need - however if you're having troubles, refer to the official installation guide: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb-cli3-install.html)

Configure Elastic Beanstalk

In the directory where you have cloned parse-server-example, run:

eb init

This will ask you a few questions to get set up. The important ones are:

  • Access Key Id and a Secret Access Key set up in the dashboard (as above)
  • Geographical region closest to you
  • Node.js specified as the environment we want

Once the init process is completed, we will create an EB environment for our deployment with:

eb create

At this stage, we can accept the default values for everything and just Enter through the questions.

To check that everything has been set up properly, run:

eb status

If we see "Green" in the output, we're good. βœ…

To see what's happening with EB itself and our application we'd use:

  • eb events to see a log of EB events
  • eb logs to see the logs

Deploy the Parse Server with Elastic Beanstalk

We're ready to get something running in the cloud now. Deploy the application with:

eb use my-parse-server-dev # specify the default environment eb deploy

Once that completes, check that the application is running with:

eb open

And you should see the message from the server in your browser.

You'll notice that we haven't configured Mongo to be used by the server deployed to Elastic Beanstalk. The easiest option is to use compose.io - provision a trial database from them and add the Mongo URL to index.js in parse-server-example and redeploy. πŸ‘Œ

Next Steps

This guide is enough to set up a minimalistic deployment. There's a lot more to a real production deployment, e.g.:

  • managing your server's configuration for different environments
  • setting up a production-like dev and staging environment
  • monitoring and alerting
  • configuring TLS - critical for production applications πŸ”‘
  • setting up DNS with Route53
  • hooking up push notifications with AWS Push Notification Service
  • multi-region setup for speed (important for applications with users in mulitple geographies) and resiliency
  • performance and scale testing of your backend (important for popular applications)
  • keeping Parse Server up-to-date (it's likely to be actively updated by the community to develop missing features)

I intend to cover these topics over the course of the next few weeks. Follow me @hveldstra for updates. Feel free to @-message me with any questions you have too. You can also email me on h@veldstra.org

@nitrag
nitrag commented Feb 1, 2016

Following! Exactly what I am looking for. Very curious how EB can handle ParseServer. I am also hopeful that with AWS you can solve all the issues with "single point of failure"

Also Next Steps:

  • Create a AWS (hosted) MongoDB, that scales/replication. In AWS terms I think this is "Amazon RDS Master" + "Amazon RDS Multi A-Z Standby".
  • What if one EB fails?
  • Multi-Availability Zones with failover?
  • Automatic nearest user routing with Route53

I will contribute to this as much as I can!

EDIT: DBaaS (MongoLab) might be the better option. Seems like a lot of work to manage the scale and reliability. Comments? Thoughts?
EDIT2: Compose.io looks very cool. You are basically charged per GB ($18/GB).
EDIT3: Add support for how to setup an S3 to support ParseFile storage. Issue #113 on Parse-Server

@nitrag
nitrag commented Feb 2, 2016

I am having a helluva time getting beanstalk to configure the load balancer (nginx) and nodeJS port. Nginx ELB looks like it can only do port 80 or 443. I can't startup NodeJS running on a port that low so I've left it at 1337. I also have a security group which opens 80, 443, 1337 ports for testing. I am getting 502 Gateway Error and logs confirm that Parse is up and running on port 1337. Halp!

@hassy
Owner
hassy commented Feb 2, 2016

@nitrag what does the relevant part of the nginx config look like? You also shouldn't need 1337 to be open to the outside, just the port that nginx is listening on. Good suggestions above πŸ‘ Hoping to have some more time to work on this later this week.

@nitrag
nitrag commented Feb 2, 2016

Err, how do I config nginx? I only see the "Load Balancing" section in AWS EB Dashboard.

Edit: Like this? I don't see this file in your repo.

@nitrag
nitrag commented Feb 2, 2016

@hassy....still stuck....there has to be an easy way to do this

@StuartMorris0

Hey @nitrag - I would try the following:

  1. Using the AWS console, Configuration/Software has the "Node command" option - just set that to npm start.
  2. Update the parse server index.js file. If you are trying to use the default (example project) the port part is different from the README on the github. This works for me:
var port = process.env.PORT || 1337;
app.listen(port, function() {
  console.log('parse-server-example running on port ' + port + '.');
});
@bradycoye

Great guide. I look forward to future updates. Do you have any other resources you recommend? I'm new to Node.js/managing my own backend and am eager to learn!

@Bashta
Bashta commented Feb 9, 2016

Hey @StuartMorris0, @nitrag, after checking out the logs it turns out nginx is set up to listen on port 8081. The parse server example has it set to something else. Just change it to 8081. Cheers

@topwork7

eb init
when I run this, I get ERROR: AttributeError :: 'NoneType' object has no attribute 'get_frozen_credentials'
Please see http://stackoverflow.com/questions/35462346/setting-up-the-eb-cli-error-nonetype-get-frozen-credentials

I hope you can help me!

Thanks

@nitrag
nitrag commented Feb 18, 2016

Thanks, guys. I got it running. Working on getting it configured correctly. Will update this guide with my experiences once I have it running like I want.

@mitchellporter

@nitrag thank you for doing this and keeping us updated.

@goldendousa

i got the same error by @otto1020

@sainathg1245

i had deployed my parse server to aws, it was successful but when i hit my server it is saying "DNS server could not be found (URL : http://testingParseServer.elasticbeanstalk.com/parse)
screen shot 2016-04-05 at 11 07 08 am
"

@kalitas
kalitas commented Oct 20, 2016 edited

what should I use in the server url key ? (local host is working good but after deploy to aws i need to put my server url, but is there an option to put a general key like: "serverURL": "http://localhost:1337/parse" || "process.myurl/parse" ?
ar dashboardApps = new ParseDashboard({
"apps": [
{
"serverURL": "http://localhost:1337/parse",
"appId": "",
"masterKey": "",
"appName": "",
"javascriptKey": "",
"restKey": "",
"production": false
}
]
});

@kanersan

@kalitas I think serverUrl should be something like: https://api.parse.com/1
instead of localhost.

@soniurvashi11

am getting several errors in my parse-php-sdk ,mainly in Parse/ParseQuery.php ,after migration,aws elastic bean setup and everything,u hv any idea why?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment