I’ve released the first version of avariodev:galaxy-autoscale which allows a Meteor app to read current stats from Meteor Galaxy and adjust the number of running containers up or down based on loading.
Since there is no API to use, it relies on phantomjs and webdriverio to connect to Meteor Galaxy, which is far from an ideal solution, but AFAIK it’s the only one available currently.
I’m running it in production and it’s been great so far, my app has been going up and down between 1-4 containers based on the number of connections.
Putting in your project is as simple as adding the package and including this in a server only file:
import { GalaxyAutoScale } from 'meteor/avariodev:galaxy-autoscale';
Meteor.startup(() => {
GalaxyAutoScale.config({
appName: Meteor.settings.galaxy.appName,
username: Meteor.settings.galaxy.username,
password: Meteor.settings.galaxy.password,
scalingRules: {
containersMin: 1,
containersMax: 3,
connectionsPerContainerMax: 80,
connectionsPerContainerMin: 40,
},
});
GalaxyAutoScale.addSyncedCronJob();
GalaxyAutoScale.start();
});
Screenshot of auto-scaler in action:
I currently support a course tutoring site, and I was getting frustrated that the day before an exam my traffic would jump 300% and the only way I would find out is a text message from my client that the site was running slowly. And all of that so I could pull up my phone, click a link, and hit a single button. It was so easy that I figured a script could do it, so why not write one?
Since this package is based on interacting with the Galaxy UI, it’s rather brittle, but if there is enough interest in using this I will add some alert functionality so at least some notifications can go out if things go wrong.
License is MIT. Enjoy!