Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse Server Benchmarking #185

Closed
gateway opened this issue Feb 2, 2016 · 29 comments
Closed

Parse Server Benchmarking #185

gateway opened this issue Feb 2, 2016 · 29 comments

Comments

@gateway
Copy link

gateway commented Feb 2, 2016

Hey Guys I did some simple benchmarking today with a Jmeter script , just does a POST and a GET of the object created and I also used apache benchmark... From the looks of the data I'm seeing pretty high response times from the results.. I'm not sure if its the connection between you guys and MongoLab or the small free dyno im running.. here are some of my findings.. Any thoughts?

https://groups.google.com/forum/#!topic/parse-developers/puldzNyFEGs

@doender
Copy link

doender commented Feb 2, 2016

If having multiple cores, you could use the cluster module to scale up the number of processes to the number of cores. Here is an easy example to do this for an express server like parse-server: http://www.sitepoint.com/how-to-create-a-node-js-cluster-for-speeding-up-your-apps/

I tested this snipped and it seems to work:

var cluster = require('cluster');
if (cluster.isMaster) {
    var numWorkers = require('os').cpus().length;
    for(var i = 0; i < numWorkers; i++) {
        cluster.fork();
    }
    cluster.on('online', function(worker) {
        console.log('Worker ' + worker.process.pid + ' is online');
    });
    cluster.on('exit', function(worker, code, signal) {
        console.log('Worker ' + worker.process.pid + ' died with code: ' + code + ', and signal: ' + signal);
        console.log('Starting a new worker');
        cluster.fork();
    });
}
else {
    var api = new ParseServer({
      databaseURI: process.env.DATABASE_URI || 'mongodb://localhost:27017/dev',
      cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
      appId: 'myAppId',
      masterKey: 'myMasterKey'
    });

    var app = express();
    // Serve the Parse API on the /parse URL prefix
    var mountPath = process.env.PARSE_MOUNT || '/parse';
    app.use(mountPath, api);

    // Parse Server plays nicely with the rest of your web routes
    app.get('/', function(req, res) {
      res.status(200).send('I dream of being a web site.');
    });

    var port = process.env.PORT || 1337;
    var httpServer = http.createServer(app);
    httpServer.listen(port, function() {
      console.log('parse-server-example running on port ' + port + '.' + process.pid);
    });
}

Does this help in your benchmark?

@codebreach
Copy link
Contributor

Very interesting data.
Newrelic (last screenshot in the linked google groups discussion) lets you break down requests into DB, Async, IO etc. I believe it is under transaction traces if you click into one of the paths.

Can you take a look at those metrics for a better understanding of what is the slow piece? Maybe you could share your findings so we can also learn from them.

@gateway
Copy link
Author

gateway commented Feb 2, 2016

@doender right now im just using a free dyno at Heroku which is prob a small container on some VM that they let you use. I just wanted to see how that preformed with the Free instance at MongoLabs as well.

@codebreach Thanks for reminding me here it is

image

I dont get the post value being 812ms.. thats crazy..

Next steps is to add some sort of profiling to the code, but I its been ages since I tried to profile node.js and not sure where to start again on a remote server.

@gateway
Copy link
Author

gateway commented Feb 2, 2016

Here is my jmeter script, its very simple but you need to change a few things which can be done via text editor if you do not have jmeter.

          <stringProp name="Header.name">X-Parse-Application-Id</stringProp>
          <stringProp name="Header.value">yourappid</stringProp>

add your appid you added for your parse server

line 55 add your domain in

      <stringProp name="HTTPSampler.domain">yourserver</stringProp>

no http.. just whateveryourdomain.com

line 85

change your domain as above

      <stringProp name="HTTPSampler.domain">yourserver</stringProp>

save that and sign up for a free account at blazemeter.. when you log in select jmeter and upload your script..

You can download the script from my server here

@francocorreasosa
Copy link

You can run parse-server with PM2 in cluster mode to solve this.

@gateway
Copy link
Author

gateway commented Feb 3, 2016

@francocorreasosa could you explain this a bit more , esp for people reading this thread.

@francocorreasosa
Copy link

Sure,
You can install pm2 from npm and run
"pm2 start server.js -i 3"
So pm2 will run a 3-node cluster for your server. I think this can be done
to load balance the traffic between parse-server instances plus a load
balancing server.

@jamiechapman
Copy link

If you're using Heroku and don't want the complexity of configuring pm2, you could also consider a plugin like Adept Scale to handle this for you: https://devcenter.heroku.com/articles/adept-scale

@gateway
Copy link
Author

gateway commented Feb 3, 2016

@francocorreasosa be nice to see if this works, im assuming this would be running on like AWS to scale your EC2 instances or?

@jamiechapman I read though the docs, seems like some of this is still in beta, it would be good to figure out if this could be used with parse-server because nobody is really talking about scaling or how to potentially scale a parse server.

@doender
Copy link

doender commented Feb 3, 2016

"pm2 start index.js -i 2" could also be used one a single instance with 2 cores to distribute the load. I tried it, works perfectly and no changes to the code needed like in the snippet I posted.

@gateway
Copy link
Author

gateway commented Feb 3, 2016

@doender If I have time this week Ill test this out and run some benchmarks.. what cloud provider are you using?

@doender
Copy link

doender commented Feb 3, 2016

DigitalOcean

@gateway
Copy link
Author

gateway commented Feb 3, 2016

@doender thanks for that. From building my own backend for a game called TouchFish as you scale you will need to eventually have load balancers in front of your parse servers that will then based upon the parse server health or requests send the data to x server. I have yet time to mess around with this and might try it in aws since they have already load balancers you can use with one of their many services.

@steven-supersolid
Copy link
Contributor

Here are a suggestions for a few other load tests that may be useful to do, in clustered and non-clustered configurations:

  1. Test HTTP request to non-Parse Heroku Node.js app, e.g. a simple hello world - this will give you the baseline speed
  2. Test empty Cloud Code function call - this won't hit the database, should be similar to baseline
  3. Your test original test - will include database latency overhead
  4. Test Cloud Code function that makes a database call - will test impact of additional resources used by Cloud Code when it makes an API call request

@gateway
Copy link
Author

gateway commented Feb 5, 2016

Ill be running tests on AWS , since they now have a set up to work with Parse server that uses their Elastic Beanstock system (manages load balancers, auto scaling etc).. More found here http://mobile.awsblog.com/post/TxCD57GZLM2JR/How-to-set-up-Parse-Server-on-AWS-using-AWS-Elastic-Beanstalk

@gateway
Copy link
Author

gateway commented Feb 5, 2016

Also above Ill be testing https://www.mongodb.com/migrate-from-parse-to-mongodb-cloud-manager-and-aws provisioning system in aws with beanstalk

@gfosco gfosco changed the title Parse Sever Benchmarking.. High response times? Parse Sever Benchmarking Feb 5, 2016
@nitrag
Copy link

nitrag commented Feb 8, 2016

Eagerly following...any updates?

@gateway
Copy link
Author

gateway commented Feb 8, 2016

Sorry I was side tracked this weekend with other stuff and am looking into seeing how to integrate PM2 depending on the AWS EC2 I use since you can run one instance of node.js on a core. I want to make sure the nodes also restart if they crash of fail, so a lot of reading up on Elastic Beanstalk.

@gfosco gfosco changed the title Parse Sever Benchmarking Parse Server Benchmarking Feb 20, 2016
@markuswinkler
Copy link

@gateway any updates?

@gateway
Copy link
Author

gateway commented Feb 22, 2016

@markuswinkler last week, got pulled into figuring out what hosting we will be doing and will do my first decent load test with mongo cloud (in aws) and elastic beanstalk with parse servers.. This will give me the ability to scale parse servers up or down based on load and use a nice interface for mondodb cloud manager to have 1 replica set of 3 servers to start with.

@markuswinkler
Copy link

@gateway Fantastic! I bet this kind of setup applies to a lot of people who want to migrate, looking forward to the results! Are you going with m3.medium instances?
Also, I hear a lot of different opinions on wether to use a service like MongoLab/Compose.io or manage the mongodb servers yourself. What is your stance on this?

@nitrag
Copy link

nitrag commented Feb 22, 2016

I think I've tentatively settled on AWS EB and Compose.io. I am very interested to see your results. Thanks!

@gateway
Copy link
Author

gateway commented Feb 22, 2016

@markuswinkler it will depend on what your skill level set is or how comfortable you are using other interfaces. For our Likemoji project we will be going the route of Elastic Beanstalk to handle load balancing, scaling of parse servers and connecting to a cluster of mondodb servers running in the same amazon region. We will also be using mondo cloud to admin the mondo databases which provides a nice interface, backup system and ability to fire up various replica sets in amazon east region but better yet in different data centers (to avoid a data center going down and your app to not work)..

Mongo just did a webinar on using their system with aws.. https://www.mongodb.com/presentations/webinar-step-by-step-parse-migration-plan.. anyhow rambling. Most people not really tech savvy can just use heroku and mongolab which works. Ill prob do a writeup on my personal blog about my experiences.

EDIT: btw your data set will grow by 2-4% when you move from Parse.com to a new mongo service due to the lack of compression. So anything you look at as far as a plan make sure you consider the db storage space because its not 1 for 1

@markuswinkler
Copy link

@gateway Interesting, thanks for sharing the link, looks very helpful should we go that route!
Btw, your estimated growth of the DB of 2-4% is a significantly lower than the official one from parse.com, stating your DB will need 10x (1000%!) more space as stated here: https://github.com/ParsePlatform/parse-server/wiki/Parse-Server-Guide

@gateway
Copy link
Author

gateway commented Feb 23, 2016

@markuswinkler yea, I was going off what the mondodb webinar was saying.. but you deff need lots more space. Its to bad that Parse does not support mondodb 3.2 because they have built in compression with WiredTiger options. Looking at mondo site it says its in 3.0 so maybe ill do some tests with that.

@nitrag
Copy link

nitrag commented Feb 23, 2016

What will it take to get Parse to support WireTiger MongoDB 3.2 (which I
know nothing about but have heard rumors of good things). Timeframe?

On Tue, Feb 23, 2016 at 1:59 PM, Gateway [email protected] wrote:

@markuswinkler https://github.com/markuswinkler yea, I was going off
what the mondodb webinar was saying.. but you deff need lots more space.
Its to bad that Parse does not support mondodb 3.2 because they have built
in compression with WiredTiger options. Looking at mondo site it says its
in 3.0 so maybe ill do some tests with that.


Reply to this email directly or view it on GitHub
#185 (comment)
.

@gateway
Copy link
Author

gateway commented Feb 23, 2016

@nitrag see #345

@gfosco
Copy link
Contributor

gfosco commented Feb 26, 2016

I believe one of the reasons 3.2 isn't supported is a change in how geopoints are stored, and we're using an older format which is incompatible. So that makes migration difficult unless you handle that on your own after moving to a supported version... and it would be problematic to change how geopoints are stored for any migrated app while old clients are still hitting api.parse.com. For an entirely new app, I think a modified database adapter could be used to work with 3.2.

@gfosco
Copy link
Contributor

gfosco commented Feb 26, 2016

I'd like to close this issue, not really seeing much benchmark discussion, and we're still in a state of flux getting closer and closer to production stability.. Seeing examples online for how to properly load-balance and monitor parse-server would be great, and we'd happily link to any good info / blog posts from the wiki.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants