3 min read

Meteor Shell to see what's behind "meteor deploy"

Meteor is a great framework and "meteor deploy" is the integrated way to deploy you meteor app, but how is done the production server and how much are isolated the deployed apps?

Meteor Shell is a web terminal for curious people, on meteor.com you can look around and play with your deployed app, on your development environment you can execure commands like the development user in remote. 

Some info about the system

$ lsb_release -a
Distributor ID:	Ubuntu
Description:	Ubuntu 12.10
Release:	12.10
Codename:	quantal
$ free -h
             total       used       free     shared    buffers     cached
Mem:           58G        39G        18G         0B       2.1G        15G
-/+ buffers/cache:        22G        36G
Swap:         1.0G         0B       1.0G
$ pwd
/meteor/containers/287c4b7d-db1f-77e1-aca9-b6ef9744c242

Every app lives in its own container

$ ps auxr

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
18972    14473  0.1  0.0 893820 31048 ?        Rl   08:54   0:01 /meteor/dev_bundles/0.3.3/bin/node /meteor/containers/281924...
25021    16797  0.0  0.0  17128  1340 ?        R    09:20   0:01 ps auxr
24764    27196  0.1  0.0 900236 34556 ?        Rl   Jun19   0:46 /meteor/dev_bundles/0.3.6/bin/node /meteor/containers/537..
25056    32596 77.0  0.2 997784 153256 ?       Rl   00:22 414:11 /meteor/dev_bundles/0.3.6/bin/node /meteor/containers/3ec
..but you can see others processes

$ whoami
25021

This is an unpriviledged user.

Let's see who are our meteor neighbors

$ netstat -an
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 0.0.0.0:23710           0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:17054           0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:6174            0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:11294           0.0.0.0:*               LISTEN

Every webapp listen on a localhost port, let's see who is "25246"

$ wget localhost:25246/25246.txt
--2013-06-20 09:24:46-- http://localhost:25246/25246.txt

$ grep URL 25246.txt
meteor_runtime_config = {"meteorRelease":"0.6.3.1","ROOT_URL":"http://loomis-todos.meteor.com","serverId":"9d88..

And now let's grab the public URL, cool another Todo List with Meteor :P

The most consuming apps on *.meteor.com

$ ps aux --sort -time
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root     17697  4.7  0.1 928100 99524 ?        Ssl  Jun07 915:13 /home/ubuntu/meteor/dev_bundle/bin/node /home/ubuntu/mother/runner/runner.js --galaxy=production --runner_instance=default
11766     6397 36.7  1.1 1594364 726148 ?      Sl   Jun19 851:27 /meteor/dev_bundles/0.3.3/bin/node /meteor/containers/4024fe26-404f-77a8-aebe-41fb10ed4f37/bundle/main.js --keepalive
10074     6529 18.0  0.1 980208 114620 ?       Sl   Jun19 418:28 /meteor/dev_bundles/0.3.3/bin/node /meteor/containers/df7fe2d1-1f23-d889-59c4-f092c8d12635/bundle/main.js --keepalive
17516     4352  9.4  0.2 1036236 139872 ?      Sl   Jun19 218:17 /meteor/dev_bundles/0.3.6/bin/node /meteor/containers/23ce8f75-34a2-54f1-463d-d10c18d8d9ae/bundle/main.js --keepalive
20439     6295  5.6  0.0 895860 35544 ?        Sl   Jun19 130:03 /meteor/dev_bundles/0.3.0/bin/node /meteor/containers/795a2118-fab7-3370-fd34-99359eb64ddc/bundle/main.js --keepalive
16278     2880  5.2  0.1 935456 91520 ?        Sl   Jun19 122:30 /meteor/dev_bundles/0.3.6/bin/node /meteor/containers/41c44a7e-c88b-bac1-6172-13333f1e0c33/bundle/main.js --keepalive
18415     6635  5.2  0.2 962480 124988 ?       Sl   Jun19 121:09 /meteor/dev_bundles/0.3.0/bin/node /meteor/containers/27cce3b3-36ec-f429-9142-ecba45ea8f88/bundle/main.js --keepalive
22920    18540  5.4  0.2 1001280 141136 ?      Sl   Jun19 100:12 /meteor/dev_bundles/0.3.3/bin/node /meteor/containers/a5d7001b-df58-95ee-dd04-38a6654c21e9/bundle/main.js --keepalive
3021      6286  3.2  1.1 1635264 721776 ?      Sl   Jun19  74:40 /meteor/dev_bundles/0.3.6/bin/node /meteor/containers/72c3533f-0dbe-39e8-706e-80c4132cfaf8/bundle/main.js --keepalive
root     11093  0.1  0.0 109448  3616 ?        Sl   May22  66:12 /usr/bin/monit -c /etc/monit/monitrc
23121     3361  2.6  0.2 1038372 125356 ?      Sl   Jun19  62:24 /meteor/dev_bundles/0.3.3/bin/node /meteor/containers/11537c84-b289-23f3-4de2-365c446b4502/bundle/main.js --keepalive
root         3  0.1  0.0      0     0 ?        S    May22  60:37 [ksoftirqd/0]
sd-agent  1316  0.0  0.0  54748 17164 ?        S    May22  42:51 python /usr/bin/sd-agent/agent.py start init --clean
3013      3370  1.7  0.4 1244440 304980 ?      Sl   Jun19  41:22 /meteor/dev_bundles/0.3.6/bin/node /meteor/containers/fb2ecd1c-4f35-a39a-020e-a1640a40e745/bundle/main.js --keepalive
..and as expected 11766 is atmosphere.meteor.com :)