25
Deploy Meteor in production [email protected] .

Deploy meteor in production

Embed Size (px)

DESCRIPTION

deploy your meteor online foro production usage. Speak took at the first meteor day (2014) in Turin, Italy

Citation preview

Page 1: Deploy meteor in production

Deploy Meteor in [email protected]

.

Page 2: Deploy meteor in production

Who is Miro?

• Dev4Side srl - Milano (12 emp)

• 10years of .NET (asp.net)

• 8months with server-side JS

Page 3: Deploy meteor in production

Why meteor

• Fullstack JS

• $11.2 million in funding

• Mongodb

• Reactive

Page 4: Deploy meteor in production

So, you wanna see your meteor project online?

• Deploy – meteor deploy (core)– meteor build (core)– Demeteorizer (from modulus)– MUP (arunoda)

• Host– on meteor.com – on Modulus– Own infrastructure

• Solutions, tuning and tips

Page 5: Deploy meteor in production

meteor deploy

Page 6: Deploy meteor in production

Meteor deploy

Client

[Meteor]

Server

meteor.com

$ meteor deploy myapp.meteor.com• Part of the core• Running on Meteor's infrastructure• The easiest way to deploy your application is to use meteor • Your application is now available at myapp.meteor.com

Page 7: Deploy meteor in production

Meteor deploy

• Galaxy (from trello)

This is MDG's commercial product -- a managed cloud platform for deploying Meteor apps. You have control of the underlying hardware (you own the servers or the EC2 instances, and Galaxy manages them for you).

General Availability for Galaxy will be sometime after 1.0, since we want to focus on Meteor 1.0 and get it out as quickly as possible.

Page 8: Deploy meteor in production

meteor build(meteor bundle)

Page 9: Deploy meteor in production

Meteor build

Client

[Meteor]

Server

[Node.js + deps]

$ meteor build my_directory• Part of the meteor core• Running on your own infrastructure• Generates a fully-contained Node.js application in the form of a tarball

(bundle). • Used also for generating mobile versions (android/ios)• Starts the app with: node main.js• Still not documented in docs.meteor.com

Page 10: Deploy meteor in production

Meteor build – still some deps are missing...

• But if you’ve used a binary npm module, you need to re-install it manually. Just like you are doing it with fibers.

• Actually things are changing from version >0.9

But If you are using demeteorizer, then there is no problem.

Page 11: Deploy meteor in production

demeteorizer

Page 12: Deploy meteor in production

demeteorizer

• Installs via NPM

• Demeteorizer's output is similar to meteor build except that it generates a package.json containing all required dependencies. This allows you to easily run npm install on the destination server, which is especially important for compiled modules.

• Adds package.json

• Installs with npm install -g demeteorizer

Page 13: Deploy meteor in production

demeteorizer

Client

[Meteor]

Server

[Node.js]

$ meteor build my_directory• Running on your own infrastructure• Generates a fully-contained Node.js application in the form of a tarball

(bundle)• Starts the app with: node main.js

Page 14: Deploy meteor in production

Demeteorizer – modulus

• Opensourced by Modulus

• Modulus is a PaaS that officially support Meteor

• Intregrated into CLI moduls deploy

Page 15: Deploy meteor in production

Modulus – how it works

BALANCER

servo1

servo2

servo3

http req

Page 16: Deploy meteor in production

MUPProduction Quality Meteor

Deployments

Page 17: Deploy meteor in production

MUP

Client

[Meteor]

Server

[ubuntu/debian

opensolaris]

• Installs via NPM• Developed by Arunoda• Single command server setup• Single command deployment• Autostarts app (upstart and forever)• Access, logs from the terminal (supports log tailing)• Support for multiple meteor deployments

Page 18: Deploy meteor in production

Mup – why is cool

• Deploys on AWS EC2

• Rebuilds platform dependent NPM modules

• Uses JSON for muliple deployment paths (can manipulate them via gruntjs)

• Supports meteor.settings

• Env vars are in json

Page 19: Deploy meteor in production

How I launched my project on line

• problem– We want to serve many users, from everyware

– We want to scale easy

– Backgrounds and heavy loads are moved outside meteor.

• solution– Platform: AWS + compose.io

– Deployment: gruntjs + mup

Page 20: Deploy meteor in production

AWS + Compose configuration

HA PROXY

EC2ubuntu

EC2ubuntu

EC2ubuntu

CLOUDFRONTCDN

S3Static assets

Meteor callsmongoDb

OpLog Enabled

Page 21: Deploy meteor in production

tips

• Use MongoDb with OpLog

– Compose is a good start

• Don’t serve static content via nodejs

• Use balancer that supports

– Sticky session when websockets not work.

– Leastconn algorithm

– Client timeouts > 30 sec

Page 22: Deploy meteor in production

Haproxy.confdefaultsmode httptimeout connect 60stimeout server 60stimeout client 60stimeout check 5s

frontend public#binding port 80bind *:80default_backend apps

backend apps#load balancing algorithmbalance leastconn

#using JSESSIONID as the cookiecookie JSESSIONID insert nocache

#adding serverserver host1 host1.example.com cookie host1server host2 host2.example.com cookie host2server host3 host3.example.com cookie host3

#Link: https://meteorhacks.com/how-to-scale-meteor.html

Page 23: Deploy meteor in production

deployment

• Use Gruntjs for your deployment steps

– Create a .deploy folder in your meteor proj

– Run tests, before deployment

– Compile Scss to css

– Upload statics to CDN (S3)

– Add private local npm modules

– Edit MUP json conf files before deploying

• And finally, use mup for the upload

Page 24: Deploy meteor in production

deployment

..and make sure your deployments to Test and Production enviroments requires minimum manual operations...