Load balancing Meteor Up vs NgInx


Currently I host my Meteor App on one docker + another docker for MongoDB on DigitalOcean Droplet 2 Gb RAM. I used NGINX to manage my web apps (4 web app running on Docker).

I planned to use load balancer to load balancing one of my web app. I see that I can use NgInx or Meteor Up for load balancing of my web app.

What is the Pros and Cons of each option ?

Thank You

H @adalidda

How is your hosting envirtonment at the moment?

Did you setup load balancing? And did you find out the pros and cons?

If you mean with mup that you have to use meteor-cluster I’ve to say that this is a bad idea. I’ve used it in a chat application and the whole server crashed very often (I’ve added 3 VPS systems). There is a issue open about it, @arunoda seems to have no time to maintain it anymore if you see how many issues are still opened.

I’m using meteor-cluster now only for multi cpu usage on one system, that’s seems to work without problems (https://meteorhacks.com/introducing-multi-core-support-for-meteor.html).

Okay I see. But what about using 3x single core instances and use nginx load balancers?

I thing using NGINX as a load balancer is a common setup, but you have to configure it right, f.e. activate STICKY_SESSIONS or IP_FORWARDING, otherwise your application wouldn’t work properly.

Awesome! Thanks for the information about STICKY_SESSIONS and IP_FORWARDING.

I only configured reverse proxy and just deployed on 2 servers.

Do you have any example nginx config using STICKY_SESSIONS and IP_FORWARDING?

This one? https://gist.github.com/dnprock/53fa74153d29557aa699

I’ve to say that I only did read about it yet, I’ll use nginx for my next configuration as proxy, you I can’t tell you which configs is the best.

Hi Krizzii,

We use NgInx for load balancing between our 2 droplets. It seems to work fine.
We have one Digital Ocean’s Droplet with 4 CPU and 8 Gb RAM for 1 NgInx, 2 keystone App, 2 TelescopeJS Apps, 1 Odoo ERP, 1 postgresql. All are running in their own docker containers.

We have one Digital Ocean’s Droplet with 2 CPU and 4 Gb RAM for our MongoDB Server with 4 oplog. Each run on their own Docker container.

Sorry for late reply.


Can you post your Nginx conf?

Here is mine which may help:

The hash $remote_addr is for sticky sessions and the (4) ip address are the four meteor instances.

map $http_upgrade $connection_upgrade {
        default upgrade;
        ''      close;
proxy_cache_path /etc/nginx/proxyCache levels=1:2 keys_zone=my_cache:10m max_size=10g
                 inactive=60m use_temp_path=off;
upstream myApp {
  hash $remote_addr;
server {
	listen 443 ssl http2;
	listen [::]:443 ssl http2;
	ssl_certificate /home/xxxx/cert_chain.crt;
	ssl_certificate_key /home/xxxx/cert.key;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_prefer_server_ciphers on;
        ssl on;
        ssl_stapling on;
        ssl_session_cache shared:SSL:10m;
        ssl_session_timeout 5m;
	root /var/www/html;

	server_name domain.com;

	location / {
            proxy_pass http://myApp;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade; #for websockets
            proxy_set_header Connection $connection_upgrade;
            proxy_set_header X-Forwarded-For $remote_addr;
            proxy_set_header Host $host;
            proxy_cache my_cache;
            proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504;
            if ($uri != '/') {
               expires 30d;
1 Like

Thank you so much! What’s the difference between what I see other people saying to do and what you did regarding hash? I see in many places people just write:

upstream myApp {

I see someone asked this question (https://serverfault.com/questions/839148/nginx-ip-hash-does-not-load-balance-connections-to-meteor-backend/839175) and an answer was given but I did not understand it - do you?

Sure. From Nginx:

If, however, the majority of the traffic to your site is coming from clients on the same /24 network, IP Hash doesn’t make sense because it maps all clients to the same server. In that case (or if you want to hash on all four octets for another reason), instead use the Hash method with the $remote_addr variable.

ip_hash only looks at the first three octets of the address. Say for instance a large corporation or university accesses your site. They will all be on the same instance. With remote_addr, they can get spread around more.

1 Like

Very very cool, thank you.

1 Like