Uploaded 18 meteor apps to single VPS - and it works! :)

While talking about number of apps… I got 4412 apps at the moment built by meteor-kitchen users - I wish if I can run all on single $5 VPS :smiley: :smiley: :smiley:

1 Like

Cool idea and experiment!

As @perak said docker might use more ram. Can anyone confirm it?

@lcpubs must be: it’s half-virtual machine (but all containers share the same host’s kernel, so they are much more efficient). Even if they don’t use (much) more RAM and CPU, they use more disk - unnecessary in our (or at least in my) case.

1 Like

By the way, as you can see - all 18 apps are working, but too slow.

So I don’t suggest more than 5-10 apps / per cheapest VPS (of course, it can work properly only if you don’t have a lot of traffic).

Here is my server’s top

Memory usage is high even with a low traffic. Swap is busy all the time.

3 Likes

It would be super-cool if someone can help me implement similar what meteor’s hosting had: if application is iddle, it shuts down after some time, and it starts on demand. That configuration will use server resources much more efficiently.

Anybody?

1 Like

That wouldn’t be a good user experience.

It’s a good experiment that you have done. I think the focus should be on running always-on full large production apps that can easily scale to extreme demand with very low cost.

I’d suggest trying phusion passenger because it has the ability to scale number of instances per application between a predefined minimum (0 or more) and maximum (multiple instances per cpu core!) instances, stopping unused ones, increasing instance count for popular ones, all the while using sticky sessions and even ssl per host if you like.

You can even mix php and rails apps as well as static web sites into the same config. I am using it to achieve very high densities!

Update

Moved to 2-core/2GB RAM (+8GB swap) server - and now all 18 apps works like a charm :wink:

5 Likes

Looks like something is wrong with my nginx setup related to websockets, I got this message in browser console for all 18 apps:

WebSocket connection to 'ws://example-minimal.meteorfarm.com/sockjs/153/ebdm0g04/websocket' failed: Error during WebSocket handshake: Unexpected response code: 400

Does anybody know what I am doing wrong?

Here is sample from nginx config:

server {
 listen 80;

 server_name example-minimal.meteorfarm.com;

location / {
 proxy_pass http://localhost:3002;
 proxy_http_version 1.1;
 proxy_set_header Upgrade $http_upgrade;
 proxy_set_header Connection ?^?^?upgrade?^?^?;
 proxy_set_header Host $host;
 proxy_cache_bypass $http_upgrade;
 }
}

?

OK fixed: somewhere in copy&paste between worlds, quote characters are lost, correct setting is:

server {
 listen 80;

 server_name example-minimal.meteorfarm.com;

location / {
 proxy_pass http://localhost:3002;
 proxy_http_version 1.1;
 proxy_set_header Upgrade $http_upgrade;
 proxy_set_header Connection "upgrade";
 proxy_set_header Host $host;
 proxy_cache_bypass $http_upgrade;
 }
}

Thanks! :slight_smile:

Did you consider switching to phusion passenger?

Your set up requires all 18 apps to be running, but if you use passenger, you can set the minimum number of instances per app (as well as max instances) such that some always stay on and other unused ones can be turned off and back on when requested.

Phusion passenger: interesting… but I am not sure do I need it.

BTW, I didn’t found pricing table on their site (or my tired dev eyes cannot see it? :slight_smile: ).

Current server (VPS, 2-core/2GB RAM, 50GB SSD) costs me ~10 USD/month https://www.hetzner.de/gb/hosting/produkte_vserver/cx20 and works fine with 18 example apps.

Problem is that same server also builds android .apk for http://www.meteorkitchen.com and http://example-human2machine.meteorfarm.com and when running that android build tools uses too much resources and slows down the server.

Without android build thing, $10 USD VPS works perfectly with 18 apps (I don’t have a lot of trafic there).

It is free. There is an enterprise version which you wont need.

The point is, it helps you with server utilization and density. You can get a smaller server or more visitors on this one. You could decrease your swap usage, perhaps even eliminate it.

As such, you could be less affected by those builds and the builds could complete in less amount of time. You could deploy 28 apps and still use less ram.

You get sticky sessions for free. If one app suddenly gets high traffic, it autoscales that app to multiple instances.

Of one app crashes, it intelligently restarts that single app and not take down the whole server

It uses te nginx config files (it is tightly integrated into your nginx) so your configurations are reused

And the list goes on and on.

I’ve done something very similar

  • Ubuntu 14.04 on Digital Ocean
  • HAProxy (instead of nginx)
  • nvm & pm2 (instead of mupx & docker)

Currently running 6 Meteor sites and 4 vanilla node workers on a 512mb (with 4gb swap) with no issues yet.

4 Likes

where was the hosting done? Digital Ocean?

Hosting: Hetzner.

This server: https://www.hetzner.de/gb/hosting/produkte_vserver/cx20 (btw, currently I’m running 20 apps).

They are concurrent with the price, but from other people’s experience serious backup is a must.

Thank you! Where /how do you back up?

Nothing important there - just a hobby project, so I actually don’t have a backup. If something bad happens, I can setup server and deploy apps again in 2-3 hours.

I told you for backup just in case you’ll use it for something more important - be careful.

BTW, they offer backup space too for few bucks.