Meteor Scaling Microservices and Request Redirection

Hey guys, I’ve asked two questions on StackOverflow and got no responses after a few days, so I’m posting them here in hope they’ll get a response! Links to both question can be found in the first reply to this post.

First Question

I’ve created a Node.js (Meteor) application and I’m looking at
strategies to handle scaling in the future. I’ve designed my application
as a set of microservices, and I’m now considering implementing this in
production.

What I’d like to do however is have many microservices running on one
server instance to maximise resource usage whilst they are using a
small number of resources. I know containers are useful for this, but
I’m curious if there’s a way to create a dynamically scaling set of
containers where I can:

  • Write commands such as “provision another app container on this
    server if the containers running this app reach > 80% CPU/other
    limiting metrics”,
  • Provision and prepare other servers if needed for extra containers,
  • Load balance connections between these containers (and does this
    affect server load balancing, e.g., send less connections to servers
    with fewer containers?)

I’ve looked into AWS EC2, Docker Compose and nginx, but I’m uncertain if I’m going in the right direction.

Second Question

Note that URLs are appended only with :// instead of http:// because of a link limit for new users on this forum.

Say I had three applications, app-mobile, app-tablet and app-desktop. Now let’s imagine that each of these has its own unique page for creating a post, located at ://anapp.com/create-post.

Is it possible to create another Meteor application that performs some if (checkPasses) and routes to the appropriate app and specified route? Something like

if (isMobile)      redirectTo('://localhost:3100/create-page');
else if (isTablet) redirectTo('://localhost:3200/create-page');
else               redirectTo('://localhost:3000/create-page');

but each request still is shown at ://myapp.com/create-page.

Please note that the device query is just an example - I don’t care
what is the best way for cross-device. This is more about querying a
parameter before request and redirecting accordingly to another
application depending on the result. I’m also not sure if this is a
Meteor specific question, but I’d like to do things such as authenticate
a user, so it’d be handy to use Meteor for its functionality for this
"redirection" application.

1 Like

Questions can be found at http://stackoverflow.com/questions/36144330/scaling-microservices-using-docker and http://stackoverflow.com/questions/36202393/meteor-route-request-for-same-url-across-many-apps respectively (posted as reply due to link limit)

Perhaps you could take a look at Google Cloud Platform and it’s Container Engine solution (provided with kubernetes) the latest kubernetes has full support of meteor, sticky session, load balancing configuration, auto-scaling, roolback, traffic routing to microservice version and so on. They also have a great tooling to manage monitoring, database, inter service communication (Google Pub/Sub)