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


#1

Maybe useful to someone:

I just uploaded 18 meteor applications to cheapest USD $5 VPS - and it works! :slight_smile:

http://www.meteorkitchen.com examples previously hosted at *.meteor.com are now here:

http://example-dataview.meteorfarm.com
http://example-subpages.meteorfarm.com
http://example-minimal.meteorfarm.com
http://example-plugins.meteorfarm.com
http://example-accounts.meteorfarm.com
http://example-onepage.meteorfarm.com
http://example-invoices.meteorfarm.com
http://example-markdowned.meteorfarm.com
http://example-photosharing.meteorfarm.com
http://example-upload.meteorfarm.com
http://example-iot.meteorfarm.com
http://example-geiger.meteorfarm.com
http://example-ide.meteorfarm.com
http://example-human.meteorfarm.com
http://example-human-iot.meteorfarm.com
http://example-human2machine.meteorfarm.com
http://example-semantic.meteorfarm.com
http://example-materialize.meteorfarm.com

Using mup to deploy. Each app mapped to different port and nginx runing on Ubuntu 14.04 server. nginx config in /etc/nginx/sites-enabled/kitchen-examples looks like this:

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;
 }
}

server {
 listen 80;

 server_name example-dataview.meteorfarm.com;

 location / {
 proxy_pass http://localhost:3004;
 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;
 }
}

# ...and in the same manner for the next 16 apps...

Note: this thing will use more than 512M RAM, so I set 4GB swap.

And… that’s it. :slight_smile:


El Cheapo VPS hosting. Anyone tried Meteor on it?
$0.035 /Container/Hour
URLs and Routing
How hard would it be to run multiple isolated apps in one container?
#2

Looks like nginx is down. :confused:

Don’t know about you, but I found this migration to actually be a great exercise. Everything is now upgraded, on the same version, using common libraries, the experiments powers down, etc. Did you wind up doing that sort of maintenance during the migration? Are these all on a common release?

I’m really curious to see the projects from the Kitchen that made it through the migration. And so glad to know that other people are doing integration tests/demos like this.


#3

It’s heartening to hear stories like this and that nginx config is really helpful for others doing the same thing. Thanks for sharing!
(p.s. Going to do a similar thing with my demo stuff tonight.)


#4

I made a mess trying to (over)configure things… It’s online again.

Yeah, great exercise! All apps are freshly built and using latest package version and the same Meteor 1.2.1, lemon-fresh :slight_smile:


#5

Takes quite some time (20+ seconds) for me to connect, but this is really cool!

Are these all running their own Mongo instance on the same droplet?


#6

Performance is not great, but it works.

Here is some of problems I had:

Node at server must be version 0.10.40, so in your mup.json set:

  "nodeVersion": "0.10.40"

Mongo didn’t want to start (mup didn’t reported any problems), because some problems with locales in Ubuntu 14.04. I had to set environment variable:

In /etc/environment I added:

LC_ALL=C

#7

No, it’s single mongo instance


#8

yeah, this is what I’ve done with my simple websites on DO too :wink: I described it here: http://julian.io/how-do-i-host-multiple-meteor-apps-on-one-digitalocean-droplet/

The funny thing is that there is only 512 mb ram but they have SSD discs so it all can work quite well on Swap File :smiley:

@perak do you use mup or mupx ? With mupx I haven’t any problems with node versions (probably because of Docker)


#9

I am using mup not mupx (I believe docker container with app is using more RAM than naked app… but I’m not sure).


#10

It could be true. I have less apps than you. :slight_smile:


#11

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:


#13

Cool idea and experiment!


#14

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


#15

@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.


#16

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.


#17

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?


#18

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.


#19

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!


#20

Update

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


#21

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;
 }
}

?