How much cost Parse self-hosting ?


In this article, we are comparing expenses required to host the complete Parse solution (Parse Server + Database) in two different configurations. The first configuration covers small apps and the second covers scaling / large apps.
Small Apps – Will detail the structure required for starting apps with less than ten requests/second and minimum server-side processing.
Large and Scaling Apps – Will detail the structure required for scaling and large apps with more than 10 API requests per second.

Building a new API and running it on production environment demands not only dedicated developers but also adequate infrastructure. Parse.com is a BaaS – Backend as a Service provider (Infrastructure + Backend) and hosts the infrastructure at Amazon Web Services cloud. The open source version of Parse.com (Parse Server) can be hosted on various types of infrastructure.
Parse Server is developed in NodeJS using the Express framework. Parse server uses MongoDB with the Mongo Rocks, a proprietary improvement developed by Parse Team to optimize compression and performance of MongoDB.

Small Apps < 10 requests / second

Minimum infrastructure

The minimum recommended infrastructure to install a Parse app is based on two different servers. One server to run Parse Server + Parse Dashboard and another server to run the MongoDB (without Mongo Rocks).
This article talks about the minimum infrastructure necessary to run Parse Open source solution. With minimum infrastructure, you can have the servers up and running, but quality parameters such as performance and availability (also factors such as backups, redundancy, and recovery) are not considered. The infrastructure recommended by Parse.com team is also included at the end of this article.

DescriptionServer QuantityServer Purpose
Parse Server1 Compute Optimization
Mongo DB1 I/O Optimization

Deploying a Small Parse App on Amazon AWS Infrastructure

AWS is a secure cloud services platform providing a broad set of infrastructure products, ranging from bare metal instances to fully managed solutions. Parse.com is hosted on AWS North Virginia. Parse team recommends you to use AWS Elastic Beanstalk to host Parse Server applications. With AWS you can not only handle the deployment but also manage vertical scaling and monitor the usage of the applications developed with Node.JS.
You retain full control over the AWS resources powering your application and access the underlying resources at any time. There is no additional charge for AWS Elastic Beanstalk and you pay only for the AWS resources needed to store and run your applications.
You can launch the AWS Elastic Beanstalk deployment flow. There are different pricing for various EC2 instances. Amazon offers a free tier (t1.micro instances), but this instance does not support Parse Server.
The default instance type will be a t2.small as this is the minimum instance type determined to run Parse Server, but this instance is more indicated for testing environments. A ‘c4.large’ instance is ideal for the production environment. You can quickly change the instance type by going to the ‘Configuration’ tab, clicking on the ‘Instances’ card, changing the instance type to ‘c4.large’, and clicking on ‘Apply’.
Aws-Pricing
On-Demand Instances let you pay for computing capacity by the hour with no long-term commitments. This kind of service frees you from the costs and complexities of planning, purchasing, and maintaining hardware and transforms what are commonly large fixed costs into much smaller variable costs. For a c4.large, it may typically cost $0.105 per hour.
Reserved Instances provide you with a significant discount (up to 75%) compared to On-Demand Instance pricing. You can purchase Standard Reserved Instances that are available on an ‘always-on’ (24 x 7) basis, or you can buy Scheduled Reserved Instances to use on a recurring scheduled basis. You can choose between three payment options when you purchase a Standard Reserved Instance – All Upfront, Partial Upfront, and No Upfront.
The total cost for one month is the sum of the expense of the running instances, overall AWS data transfer, Elastic Load Balancers, and the data processed by the Elastic Load Balancers.
Amazon EC2 Instance Cost = Instance cost per hour X Number of instances X Uptime in hours
Instance cost per hour = $0.105
AWS Data Transfer Cost = (Data in (GB) X Data in Rate) + (Data out (GB) X Data out Rate)
Data out Rate (100GB) = $ 8.91
Total Parse Server monthly cost: $ 76.86
For the Parse Server database, you need a service that frees you from managing the underlying infrastructure for your MongoDB instances. At this minimum option, we are going to use one only MongoDB instance.
On AWS we have several EC2 options to host MongoDB going from t1.Micro to c3.large. Additionally, we also have the i2 instances that are the Parse recommended servers to Mongo Rocks performance, but we also will talk about that on the next topic.
  1. t1.Micro and t1.Small(low memory) – are most used for development and testing environments, so I don’t recommend.
  2. m3.Medium and m3.XLarge(general purpose) – Ideal to start your app database. If you need to improve performance you can upgrade memory or high I/O. We are going to use this option on our self-hosting Option.
  3. r3.Large and r3.8xLarge (high Memory)- These instances are the sweet spot for your MongoDB instances. They have the right balance of memory and compute power. They are good candidates to run your larger MongoDB server.
  4. I2.xlarge – I2.8xLarge, HS1(high I/O) – These are the “Cadillacs” of the EC2 world and you can run your most demanding MongoDB servers on these instances. These instances provide a high amount memory and fast local SSDs.
  5. c3.large-c38xlarge(high computing) – These instances provide the best CPU performance for the price point. However MongoDB does not need a lot of CPU and we have rarely found these to be useful. We prefer the high memory and high IO instances to run our MongoDB databases.
m3.Large Instance cost per hour = $0.133
Total MongoDB monthly cost: $ 95.13 

Small App Total Server Cost (Parse Server + MongoDB)

The total cost equals to the sum of one Parse Server c4.large instance plus the cost of the MongoDB m3.Medium instance.
Parse Server c4.large + Data Transfer = USD 76.86
MongoDB m3.medium = USD 97.36
Data Transfer = USD 8.91
Total Cost(AWS discount applied) = USD 181.87
Please note this cost does not cover S3 backups neither a redundant server structure.

Large scaling Apps

The recommended infrastructure

Parse.com suggests infrastructure based on replication of Parse Server and MongoDB. The replication consists of two Parse Servers instances and three MongoDB instances implementing the replicaSet (if you want to build a scalable structure of MongoDB, you‘ll need to implement charging as well but that probably needs a new Post to explain more ).
Replication is the process of synchronizing data across multiple servers. Replication provides redundancy and increases data availability with multiple copies of data on different database servers. Replication protects a database from the loss of a single server. It also allows you to recover from hardware failure and service interruptions. With additional copies of the data, you can dedicate one to disaster recovery, reporting, or backup.
For Parse Server, the replication process is very simple and consists of two simple servers that mirror each other. They are typically the same and are synchronized to have the same data always. In case one of them fails, the other is still there to support the app’s requests.
MongoDB achieves replication by the use of replica set. A replica set is a group of MongoDB instances that host the same data set. In a replica one primary node receives all write operations and the other two instances which are secondary apply operations from the primary so that they have the same data set. Replica set can have only one primary node.

MongoDB Replicaset

These deployments provide two complete copies of the data set at all times in addition to the primary. These replica sets provide additional fault tolerance and high availability. If the primary is unavailable, the replica set elects a secondary to be primary and continues normal operation. The old primary rejoins the set when available.
DescriptionServer QuantityServer Purpose
Parse Server1Compute Optimization
MongoDB-Primary1I/O Optimization – Read and Write
MongoDB-Secondary2I/O Optimization – Read

Start now a free Parse App at back4app.

Deploying Large Parse App on AWS – Recommended Infrastructure

On Parse Server side we keep using c4.Large but now with 2 servers in order to provide mirroring between the application servers.
Amazon EC2 Instance Cost = Instance cost per hour X Number of instances X Uptime in hours
Instance cost per hour = $0.105
AWS Data Transfer Cost = (Data in (GB) X Data in Rate) + (Data out (GB) X Data out Rate)
Data out Rate (1TB) = $ 183.24
Total Parse Server monthly cost: $ 336.96
On the database side we use the MongoRocks required the infrastructure(suggested by Parse Team). Parse runs its MongoDB databases in replica sets that include one primary and two secondary databases. Parse uses Amazon Elastic Block Store (Amazon EBS) to create snapshots frequently for each MongoDB shard, which is then uploaded to an Amazon Simple Storage Service (Amazon S3) bucket. If necessary, Parse can bring up a new node in a matter of minutes using Amazon S3 and join it to a cluster. They also recommend the i2 instances to deploy the MongoDb and a S3 instance to store the backups.
So we will have 3 i2 instances running the MongoRocksDB. The total cost is shown bellow:
i2.Large Instance cost per hour = $0.853
s3 Instance(1TB) = $0.0125/GB
Total MongoDB monthly cost: $ 1979.70 

Large App Total Server Cost (Parse Server + MongoDB)

The total cost equals to the sum of one Parse Server c4.large instance plus the cost of the MongoDB i2.Large instance plus S3 storage(1TB).
Parse Server c4.large + Data Transfer = USD 336.96
MongoDB i2.Large + S3 Storage = USD 1979.70

Total Cost(AWS discount applied) = USD 2355.02
Please note this cost cover S3 backups and a redundant server structure.


Share on Google Plus

About Salman Ahmed Rajput

Hi I am Salman Ahmed, nicknamed as "Sam". I am a technology lover and also a Web Developer. My favorite programming language is PHP which means I usually develop web apps in PHP. Wanna Follow ? Yes? You can follow me at https://facebook.com/Sam.programer
https://twitter.com/SalmanRajz.
    Blogger Comment

0 comments:

Post a Comment

Don't Forget to Share and Comment