Meteor deployment, how many apps per server? Sharing with non-Meteor websites?


#1

This may be a bit subjective, but I have a decision to make as far as setting up a home for some smallish Meteor apps. I have another website too, which is a pretty hefty WordPress/WooCommerce site running on nginx. My options are:

  • A single 2-core/2GB RAM VPS hosting the WordPress site and a few Meteor apps
  • One 1-core/1GB machine for WordPress, one 1-core/1GB machine for a few Meteor apps

The WordPress site requires nginx, php-fpm, and MariaDB. The Meteor apps would be using MongoDB, and nginx can just use proxy_pass and vhosts to handle multiple domains pointing to different ports on the server.


#2

You can combine them into a single server and increase density to utilize your full server capacity.

You can always monitor your apps and if one seems to become a bottleneck, you can separate it into its own server later on.


#3

I’d also say go for putting all of those onto a single host. Some more thoughts:

  • You’ll have to monitor memory usage, at least casually. If you don’t have a tool for that yet check out Sysdig Cloud. Their free level should suffice and it’s really easy to set up and get going and it’ll show you what you need to know.
  • You may want to consider using HHVM instead of Zend PHP to run your WP/WC site. As far as I know HHVM is pretty much fully compatible by now with “standard PHP”, and the speedup should be in the 5x range for pure computation, so likely at least 2x overall, with all IO included and evening out the performance numbers a bit.

The reason to consider actively monitoring memory usage is because you’ll have 2 DBs (Maria, Mongo) running alongside 2 Meteor apps that also take up memory permanently (not like PHP which frees up memory whenever the worker processes exit) and if the configuration is not right they could start fighting for memory, then swapping happens, and then performance and user experience die a horrible death very quickly :wink:

EDIT: And just to add this more clearly: YES, put as much stuff as possible on a single server, doesn’t matter if it’s Meteor/non-Meteor.(*) Initially your apps will see little traffic and resource consumption and whenever there is a small spike, the bigger-than-necessary-for-this-app server will happily provide more than enough resources. This setup will be cheaper and easier to manage. Over time, as usage on one app or the other grows, you’ll see it and respond in time by either allocating more resources overall, for all apps combined, and/or by beginning to cluster (which is a good idea for availability anyway), or by pulling individual apps or services onto their own server, if that’s what makes most sense for the situation.

(*: Just make sure you have a bit of monitoring in place in case one of the things running is a) using too many resources or b) causing instability, so you can fix or mitigate that and so the other services/apps are not affected long-term.)

But fundamentally the current leading-edge thinking on getting the most out of computing hardware is to put as much stuff as possible onto every single host, have some kind of resource management bring those apps and services together that complement each other best in terms of resource usage, establish a baseline of isolation between apps/services (like with Linux containers) and then grow the whole thing by just adding more servers to the cluster and having the scheduling/management service use the added capacity in the same way.
Systems like Kubernetes, which is an evolution of Google’s internal “cluster manager” Borg, implement a lot of this stuff and do it automatically, but they’re not usually quite ready to be used by you and me for our side projects where we can’t invest lots of time and effort into getting these kinds of automated systems running. BUT what we can do for now is to emulate some of the learnings that went into those systems and act as if we were just as smart… which we might or might not be :wink:


#4

@seeekr Whoa, thanks for the wealth of information there! Very cool.

I’ve not heard of HHVM, but just did a quick search. So it looks like you run HHVM as a service, and tell nginx to use that for PHP processing via fastcgi? I’ll have to spin up a virtual machine to test out WP/WC of course. Should be interesting.

As far as monitoring, I’ve been using M/Monit which does the trick, though I’m not blown away by it. I’ll definitely check out Sysdig Cloud.


#5

Exactly! Test it out and if you find that most regular functionality of your site shows no weird symptoms you should be safe to try things in production. But ultimately you have to judge how thoroughly you need to test it before you put it in production.
As far as I can tell the HHVM folks have put tons of effort into Zend PHP compatibility throughout the past year at least and since now they’ve begun focusing back on performance again I think they’re fairly satisfied with the compatibility, and so would be the community, then. There seem to be a couple of threads on the web about WooCommerce and HHVM (WP is well-supported anyway) and it does look like there’s only very few issues left, if any at all, and all with easy workarounds.