SlideShare a Scribd company logo
1 of 26
Building a
Production-Ready
Meteor App
by Ritik Malhotra
Streem (https://www.streem.com)
The Four Components

App
Structure

Packages

Server
Architecture

Security*
General Philosophy
• Keep Meteor intact, build around what
exists
• Monkey patch only if necessary
• Remove autopublish and insecure
Part 1

App Structure
How to design for maintainability
App Structure
/client
/lib
/packages
/private
/public
/server
/tests
© your company name. All rights reserved.

Title of your presentation
Client-side code
/client
/css
/js = 3rd party libraries (jQuery libs, etc.)
/lib = Gets loaded first
/helpers = client-side helper methods
/meteor = meteor-specific client code
router.js = Client-side routing
startup.js = Run on new client init
subscriptions.js = Subscribe to data
/views
/view-group
template.html
template.js = helpers, events, rendered
- ex:
/accounts/{login,register}.{html,js}
Shared lib folder
/lib
/helpers
- Helper functions that are useful on the
client and server
- ex: basename(), isValidEmailAddress()
/models
init.js = Instantiate collections
- Individual model files containing model
methods for specific collection
- ex: UserModel.js contains getUsername(),
setNotificationSetting(), etc.
- Abstract database queries out to specific
model functions
Packages, assets, tests
/packages
- Smart packages that your app depends on
- Use Atmosphere/Meteorite to manage these
/private
- Store private assets for the server to
access
- ex: Email templates
/public = All your static assets
/img
/fonts
/js
- Contains any JS files that you don’t want
minified and bundled in with the rest
/tests = Test suite
Server-side code
/api
- REST API (optional)
/config
accounts.js = Accounts.config(), etc.
users.js = Accounts.onCreateUser(), etc.
/helpers = Server-side helper functions
/lib = What should get loaded first
*settings.js = Load into Meteor.settings
packages.js = Instantiate your NPM modules
startup.js = Run on server startup
/models = Server-only Meteor.methods
/publish
- Individual files for the type of data
- ex: user.js to publish UserModel data
Part 2

Packages
Essential to maintaining your system
Packages
• Different categories of packages
•
•
•
•
•

Routing
User accounts
Testing
Logging, error handling
Optimizations

• Node.js NPM packages
• meteor-npm
• https://github.com/arunoda/meteor-npm
Routing
• Client-side routing
• iron-router
• https://github.com/EventedMind/iron-router

• Server-side routing
• Useful for a REST API
• meteor-router
• https://github.com/tmeasday/meteor-router

• reststop2
• https://github.com/BeDifferential/reststop2
User Accounts
• Meteor has an accounts system
• http://docs.meteor.com/#accounts_api
• accounts-password, accounts-facebook, etc…
• accounts-ui for a simple UI

• Configurable
• Accounts.config, Accounts.ui.config
• Accounts.onCreateUser, Accounts.validateNe
wUser
Testing
• Optimized for Meteor
• laika (http://arunoda.github.io/laika/)
• Based off of mocha
• Can write tests that interact with server and client

• RTD (http://xolvio.github.io/rtd/)
• Unit + acceptance testing

• Other options
• tinytest
Logging & Error Handling
• Logging
• winston (https://github.com/flatiron/winston)
• Compatible with Papertrail, Airbrake, etc.

• Observatory (http://observatoryjs.com/)
• Logs HTTP/DDP requests, subscriptions, etc.
• Profiles your app, displays load, monitoring

• Error handling
• Raven/sentry
• https://github.com/deepwell/meteor-raven
Optimizations
• Fast database synchronization
• meteor-smart-collections package
• https://github.com/arunoda/meteor-smart-collections

• meteor-oplog branch
• https://github.com/meteor/meteor/tree/oplog

• Fast server synchronization
• meteor-cluster package
• https://github.com/arunoda/meteor-cluster

• Not needed if using meteor-smartcollections or meteor-oplog
Part 3

Server Architecture
How to design for easy scalability
Server Architecture
• Multiple components
• Deployment
• Multiple web servers
• Problem: slow data synchronization (10 seconds)

• Load balancing
• Problem: sticky sessions required

• Scalable database (MongoDB)
• Problem: inefficient to handle reactivity
Deployment
• Amazon Elastic Beanstalk
•
•
•
•

Heroku for AWS
Reliable, Amazon-backed
Custom deploy scripts
Manages server instances, load
balancer, static asset
delivery, monitoring, auto scaling
Web Server
• EC2 configuration
• Node.js v0.8.24 or v0.10.10
• nginx
• Point static assets to /public/*
• gzip enabled

• Build script (TODO: link)
• Auto scaling
• Auto-scale up 1 instance at 60% CPU usage
• Auto-scale down 1 instance at 30% CPU usage

• meteor-cluster package for fast data
synchronization between server instances
• Uses Redis
Load Balancing
• Elastic Load Balancer configuration
• Cookie-based sticky sessions enabled
• 0 second cookie expiration period

• HTTP on port 80
• HTTPS on port 443 w/ SSL certificate
• Health checks

• Can’t use WebSockets
• DISABLE_WEBSOCKETS = true
• SockJS gracefully falls back
Database
• Easiest to use a hosted MongoDB solution
• Best option
• Oplog-enabled replica-set cluster
• MongoLab SSD Cluster (or host your own)
• meteor-smart-collections package or
meteor-oplog branch

• Alternative
• MongoHQ/MongoLab regular DB instance
Extras (optional)
• Amazon CloudFront
• CDN’d asset delivery
• Can configure to deliver assets out of a
specific app directory (/public)

• Development, staging, production
environments on Elastic Beanstalk
• Enable monitoring on Elastic Beanstalk to
get alerts when servers are down
Server Diagram
Route 53 / DNS
SSL
Elastic Load Balancer
CloudFront

nginx

nginx
Auto-scaling

Meteor bundle
+ static assets

EC2 (web
server)

EC2 (web
server)

MongoDB + Oplog
What’s Next?
• App scaffolding
• Automatically generate your app structure

• Packages to automate good practices
• Meteor guides and tutorials
• In-depth instructions on setting up your
server, deploying your app, packages, etc.

• Meteor Cookbook
• Tips and tricks, FAQ

• URL coming soon
We’re Hiring Engineer #1!
• Streem (https://www.streem.com)
• Large-scale Meteor app
• YCombinator-backed & venture-funded
• jobs@streem.com

• Ritik Malhotra
• ritik@streem.com
• @ritikm

More Related Content

What's hot

Java Microservices with Spring Boot and Spring Cloud - Denver JUG 2019
Java Microservices with Spring Boot and Spring Cloud - Denver JUG 2019Java Microservices with Spring Boot and Spring Cloud - Denver JUG 2019
Java Microservices with Spring Boot and Spring Cloud - Denver JUG 2019Matt Raible
 
[1D1]신개념 N스크린 웹 앱 프레임워크 PARS
[1D1]신개념 N스크린 웹 앱 프레임워크 PARS[1D1]신개념 N스크린 웹 앱 프레임워크 PARS
[1D1]신개념 N스크린 웹 앱 프레임워크 PARSNAVER D2
 
Microservices with SenecaJS (part 2)
Microservices with SenecaJS (part 2)Microservices with SenecaJS (part 2)
Microservices with SenecaJS (part 2)Designveloper
 
Automating MySQL Deployments on Kubernetes
Automating MySQL Deployments on KubernetesAutomating MySQL Deployments on Kubernetes
Automating MySQL Deployments on KubernetesPresslabs
 
Building ‘Bootiful’ microservices cloud
Building ‘Bootiful’ microservices cloudBuilding ‘Bootiful’ microservices cloud
Building ‘Bootiful’ microservices cloudIdan Fridman
 
Use Angular Schematics to Simplify Your Life - Develop Denver 2019
Use Angular Schematics to Simplify Your Life - Develop Denver 2019Use Angular Schematics to Simplify Your Life - Develop Denver 2019
Use Angular Schematics to Simplify Your Life - Develop Denver 2019Matt Raible
 
The Past Year in Spring for Apache Geode
The Past Year in Spring for Apache GeodeThe Past Year in Spring for Apache Geode
The Past Year in Spring for Apache GeodeVMware Tanzu
 
Kubernetes your next application server
Kubernetes  your next application serverKubernetes  your next application server
Kubernetes your next application serverRed Hat Developers
 
NodeJS : Communication and Round Robin Way
NodeJS : Communication and Round Robin WayNodeJS : Communication and Round Robin Way
NodeJS : Communication and Round Robin WayEdureka!
 
Qui Quaerit, Reperit. AWS Elasticsearch in Action
Qui Quaerit, Reperit. AWS Elasticsearch in ActionQui Quaerit, Reperit. AWS Elasticsearch in Action
Qui Quaerit, Reperit. AWS Elasticsearch in ActionGlobalLogic Ukraine
 
Cloud Native Microservices with Spring Cloud
Cloud Native Microservices with Spring CloudCloud Native Microservices with Spring Cloud
Cloud Native Microservices with Spring CloudConor Svensson
 
How to Build Your First Web App in Go
How to Build Your First Web App in GoHow to Build Your First Web App in Go
How to Build Your First Web App in GoAll Things Open
 
watir-webdriver
watir-webdriverwatir-webdriver
watir-webdriverAmit DEWAN
 
Secrets in Kubernetes
Secrets in KubernetesSecrets in Kubernetes
Secrets in KubernetesJerry Jalava
 
Securing Microservices using Play and Akka HTTP
Securing Microservices using Play and Akka HTTPSecuring Microservices using Play and Akka HTTP
Securing Microservices using Play and Akka HTTPRafal Gancarz
 
Vert.x for Microservices Architecture
Vert.x for Microservices ArchitectureVert.x for Microservices Architecture
Vert.x for Microservices ArchitectureIdan Fridman
 
GWT Web Socket and data serialization
GWT Web Socket and data serializationGWT Web Socket and data serialization
GWT Web Socket and data serializationGWTcon
 
Moving Quickly with Data Services in the Cloud
Moving Quickly with Data Services in the CloudMoving Quickly with Data Services in the Cloud
Moving Quickly with Data Services in the CloudMatthew Dimich
 
Test Automation using Ruby, Watir, Rspec and AutoIT for GAMESCALE products te...
Test Automation using Ruby, Watir, Rspec and AutoIT for GAMESCALE products te...Test Automation using Ruby, Watir, Rspec and AutoIT for GAMESCALE products te...
Test Automation using Ruby, Watir, Rspec and AutoIT for GAMESCALE products te...Sla Va
 

What's hot (20)

Java Microservices with Spring Boot and Spring Cloud - Denver JUG 2019
Java Microservices with Spring Boot and Spring Cloud - Denver JUG 2019Java Microservices with Spring Boot and Spring Cloud - Denver JUG 2019
Java Microservices with Spring Boot and Spring Cloud - Denver JUG 2019
 
[1D1]신개념 N스크린 웹 앱 프레임워크 PARS
[1D1]신개념 N스크린 웹 앱 프레임워크 PARS[1D1]신개념 N스크린 웹 앱 프레임워크 PARS
[1D1]신개념 N스크린 웹 앱 프레임워크 PARS
 
Microservices with SenecaJS (part 2)
Microservices with SenecaJS (part 2)Microservices with SenecaJS (part 2)
Microservices with SenecaJS (part 2)
 
Automating MySQL Deployments on Kubernetes
Automating MySQL Deployments on KubernetesAutomating MySQL Deployments on Kubernetes
Automating MySQL Deployments on Kubernetes
 
Building ‘Bootiful’ microservices cloud
Building ‘Bootiful’ microservices cloudBuilding ‘Bootiful’ microservices cloud
Building ‘Bootiful’ microservices cloud
 
Use Angular Schematics to Simplify Your Life - Develop Denver 2019
Use Angular Schematics to Simplify Your Life - Develop Denver 2019Use Angular Schematics to Simplify Your Life - Develop Denver 2019
Use Angular Schematics to Simplify Your Life - Develop Denver 2019
 
The Past Year in Spring for Apache Geode
The Past Year in Spring for Apache GeodeThe Past Year in Spring for Apache Geode
The Past Year in Spring for Apache Geode
 
Kubernetes your next application server
Kubernetes  your next application serverKubernetes  your next application server
Kubernetes your next application server
 
Web Developer Tools
Web Developer ToolsWeb Developer Tools
Web Developer Tools
 
NodeJS : Communication and Round Robin Way
NodeJS : Communication and Round Robin WayNodeJS : Communication and Round Robin Way
NodeJS : Communication and Round Robin Way
 
Qui Quaerit, Reperit. AWS Elasticsearch in Action
Qui Quaerit, Reperit. AWS Elasticsearch in ActionQui Quaerit, Reperit. AWS Elasticsearch in Action
Qui Quaerit, Reperit. AWS Elasticsearch in Action
 
Cloud Native Microservices with Spring Cloud
Cloud Native Microservices with Spring CloudCloud Native Microservices with Spring Cloud
Cloud Native Microservices with Spring Cloud
 
How to Build Your First Web App in Go
How to Build Your First Web App in GoHow to Build Your First Web App in Go
How to Build Your First Web App in Go
 
watir-webdriver
watir-webdriverwatir-webdriver
watir-webdriver
 
Secrets in Kubernetes
Secrets in KubernetesSecrets in Kubernetes
Secrets in Kubernetes
 
Securing Microservices using Play and Akka HTTP
Securing Microservices using Play and Akka HTTPSecuring Microservices using Play and Akka HTTP
Securing Microservices using Play and Akka HTTP
 
Vert.x for Microservices Architecture
Vert.x for Microservices ArchitectureVert.x for Microservices Architecture
Vert.x for Microservices Architecture
 
GWT Web Socket and data serialization
GWT Web Socket and data serializationGWT Web Socket and data serialization
GWT Web Socket and data serialization
 
Moving Quickly with Data Services in the Cloud
Moving Quickly with Data Services in the CloudMoving Quickly with Data Services in the Cloud
Moving Quickly with Data Services in the Cloud
 
Test Automation using Ruby, Watir, Rspec and AutoIT for GAMESCALE products te...
Test Automation using Ruby, Watir, Rspec and AutoIT for GAMESCALE products te...Test Automation using Ruby, Watir, Rspec and AutoIT for GAMESCALE products te...
Test Automation using Ruby, Watir, Rspec and AutoIT for GAMESCALE products te...
 

Viewers also liked

How To Deploy And Scale Meteor Applications
How To Deploy And Scale Meteor ApplicationsHow To Deploy And Scale Meteor Applications
How To Deploy And Scale Meteor ApplicationsDesignveloper
 
Web security at Meteor (Pivotal Labs)
Web security at Meteor (Pivotal Labs)Web security at Meteor (Pivotal Labs)
Web security at Meteor (Pivotal Labs)Emily Stark
 
Best practice routing in Meteor.js and beyond
Best practice routing in Meteor.js and beyondBest practice routing in Meteor.js and beyond
Best practice routing in Meteor.js and beyondFabian Kromer
 
MeteorJS - How to start
MeteorJS  -  How to startMeteorJS  -  How to start
MeteorJS - How to startDan Tran
 
How to build a SaaS solution in 60 days
How to build a SaaS solution in 60 daysHow to build a SaaS solution in 60 days
How to build a SaaS solution in 60 daysBrett McLain
 
Whatsmeteor a whatsApp like Chat App writen in Meteorjs
Whatsmeteor a whatsApp like Chat App writen in MeteorjsWhatsmeteor a whatsApp like Chat App writen in Meteorjs
Whatsmeteor a whatsApp like Chat App writen in MeteorjsMichael Lazarski
 
Meteor intro-2015
Meteor intro-2015Meteor intro-2015
Meteor intro-2015MeteorJS
 
Build Your Own SaaS using Docker
Build Your Own SaaS using DockerBuild Your Own SaaS using Docker
Build Your Own SaaS using DockerJulien Barbier
 
Earlybird Europe Venture Capital Report
Earlybird Europe Venture Capital ReportEarlybird Europe Venture Capital Report
Earlybird Europe Venture Capital ReportJason Whitmire
 

Viewers also liked (13)

How To Deploy And Scale Meteor Applications
How To Deploy And Scale Meteor ApplicationsHow To Deploy And Scale Meteor Applications
How To Deploy And Scale Meteor Applications
 
Web security at Meteor (Pivotal Labs)
Web security at Meteor (Pivotal Labs)Web security at Meteor (Pivotal Labs)
Web security at Meteor (Pivotal Labs)
 
D3 & MeteorJS
D3 & MeteorJSD3 & MeteorJS
D3 & MeteorJS
 
Best practice routing in Meteor.js and beyond
Best practice routing in Meteor.js and beyondBest practice routing in Meteor.js and beyond
Best practice routing in Meteor.js and beyond
 
MeteorJS - How to start
MeteorJS  -  How to startMeteorJS  -  How to start
MeteorJS - How to start
 
MeteorJS Introduction
MeteorJS IntroductionMeteorJS Introduction
MeteorJS Introduction
 
How to build a SaaS solution in 60 days
How to build a SaaS solution in 60 daysHow to build a SaaS solution in 60 days
How to build a SaaS solution in 60 days
 
Understanding meteor
Understanding meteorUnderstanding meteor
Understanding meteor
 
Whatsmeteor a whatsApp like Chat App writen in Meteorjs
Whatsmeteor a whatsApp like Chat App writen in MeteorjsWhatsmeteor a whatsApp like Chat App writen in Meteorjs
Whatsmeteor a whatsApp like Chat App writen in Meteorjs
 
Meteor intro-2015
Meteor intro-2015Meteor intro-2015
Meteor intro-2015
 
Build Your Own SaaS using Docker
Build Your Own SaaS using DockerBuild Your Own SaaS using Docker
Build Your Own SaaS using Docker
 
Presentation .- meteors
Presentation  .- meteorsPresentation  .- meteors
Presentation .- meteors
 
Earlybird Europe Venture Capital Report
Earlybird Europe Venture Capital ReportEarlybird Europe Venture Capital Report
Earlybird Europe Venture Capital Report
 

Similar to Building a production ready meteor app

Architectures, Frameworks and Infrastructure
Architectures, Frameworks and InfrastructureArchitectures, Frameworks and Infrastructure
Architectures, Frameworks and Infrastructureharendra_pathak
 
Docker based Architecture by Denys Serdiuk
Docker based Architecture by Denys SerdiukDocker based Architecture by Denys Serdiuk
Docker based Architecture by Denys SerdiukLohika_Odessa_TechTalks
 
Mastering MongoDB on Kubernetes, the power of operators
Mastering MongoDB on Kubernetes, the power of operators Mastering MongoDB on Kubernetes, the power of operators
Mastering MongoDB on Kubernetes, the power of operators DoKC
 
Kudu voodoo slideshare
Kudu voodoo   slideshareKudu voodoo   slideshare
Kudu voodoo slideshareAidan Casey
 
The Meteor Framework
The Meteor FrameworkThe Meteor Framework
The Meteor FrameworkDamien Magoni
 
Webpack Introduction
Webpack IntroductionWebpack Introduction
Webpack IntroductionAnjali Chawla
 
Feedback on building Production-Ready Microsoft Teams Apps
Feedback on building Production-Ready Microsoft Teams AppsFeedback on building Production-Ready Microsoft Teams Apps
Feedback on building Production-Ready Microsoft Teams AppsGuillaume Meyer
 
Fuse Online Hands-on Guide
Fuse Online Hands-on GuideFuse Online Hands-on Guide
Fuse Online Hands-on GuideNobuhiro Sue
 
Making MySQL Administration a Breeze - A look into a MySQL DBA's toolchest
Making MySQL Administration a Breeze - A look into a MySQL DBA's toolchest Making MySQL Administration a Breeze - A look into a MySQL DBA's toolchest
Making MySQL Administration a Breeze - A look into a MySQL DBA's toolchest Lenz Grimmer
 
Play Framework and Activator
Play Framework and ActivatorPlay Framework and Activator
Play Framework and ActivatorKevin Webber
 
Fuse Online Hands-on Guide
Fuse Online Hands-on GuideFuse Online Hands-on Guide
Fuse Online Hands-on GuideNobuhiro Sue
 
Grabbing the PostgreSQL Elephant by the Trunk
Grabbing the PostgreSQL Elephant by the TrunkGrabbing the PostgreSQL Elephant by the Trunk
Grabbing the PostgreSQL Elephant by the TrunkHarold Giménez
 
(WEB301) Operational Web Log Analysis | AWS re:Invent 2014
(WEB301) Operational Web Log Analysis | AWS re:Invent 2014(WEB301) Operational Web Log Analysis | AWS re:Invent 2014
(WEB301) Operational Web Log Analysis | AWS re:Invent 2014Amazon Web Services
 
Monitoring in Big Data Platform - Albert Lewandowski, GetInData
Monitoring in Big Data Platform - Albert Lewandowski, GetInDataMonitoring in Big Data Platform - Albert Lewandowski, GetInData
Monitoring in Big Data Platform - Albert Lewandowski, GetInDataGetInData
 
Stay productive while slicing up the monolith
Stay productive while slicing up the monolith Stay productive while slicing up the monolith
Stay productive while slicing up the monolith Markus Eisele
 
Time series denver an introduction to prometheus
Time series denver   an introduction to prometheusTime series denver   an introduction to prometheus
Time series denver an introduction to prometheusBob Cotton
 
Using GitHub Actions to Deploy your Workloads to Azure
Using GitHub Actions to Deploy your Workloads to AzureUsing GitHub Actions to Deploy your Workloads to Azure
Using GitHub Actions to Deploy your Workloads to AzureKasun Kodagoda
 

Similar to Building a production ready meteor app (20)

Architectures, Frameworks and Infrastructure
Architectures, Frameworks and InfrastructureArchitectures, Frameworks and Infrastructure
Architectures, Frameworks and Infrastructure
 
Docker based Architecture by Denys Serdiuk
Docker based Architecture by Denys SerdiukDocker based Architecture by Denys Serdiuk
Docker based Architecture by Denys Serdiuk
 
Mastering MongoDB on Kubernetes, the power of operators
Mastering MongoDB on Kubernetes, the power of operators Mastering MongoDB on Kubernetes, the power of operators
Mastering MongoDB on Kubernetes, the power of operators
 
Kudu voodoo slideshare
Kudu voodoo   slideshareKudu voodoo   slideshare
Kudu voodoo slideshare
 
The Meteor Framework
The Meteor FrameworkThe Meteor Framework
The Meteor Framework
 
Webpack Introduction
Webpack IntroductionWebpack Introduction
Webpack Introduction
 
Ember - introduction
Ember - introductionEmber - introduction
Ember - introduction
 
Azure serverless computing
Azure serverless computingAzure serverless computing
Azure serverless computing
 
Feedback on building Production-Ready Microsoft Teams Apps
Feedback on building Production-Ready Microsoft Teams AppsFeedback on building Production-Ready Microsoft Teams Apps
Feedback on building Production-Ready Microsoft Teams Apps
 
DevOpsVersion2
DevOpsVersion2DevOpsVersion2
DevOpsVersion2
 
Fuse Online Hands-on Guide
Fuse Online Hands-on GuideFuse Online Hands-on Guide
Fuse Online Hands-on Guide
 
Making MySQL Administration a Breeze - A look into a MySQL DBA's toolchest
Making MySQL Administration a Breeze - A look into a MySQL DBA's toolchest Making MySQL Administration a Breeze - A look into a MySQL DBA's toolchest
Making MySQL Administration a Breeze - A look into a MySQL DBA's toolchest
 
Play Framework and Activator
Play Framework and ActivatorPlay Framework and Activator
Play Framework and Activator
 
Fuse Online Hands-on Guide
Fuse Online Hands-on GuideFuse Online Hands-on Guide
Fuse Online Hands-on Guide
 
Grabbing the PostgreSQL Elephant by the Trunk
Grabbing the PostgreSQL Elephant by the TrunkGrabbing the PostgreSQL Elephant by the Trunk
Grabbing the PostgreSQL Elephant by the Trunk
 
(WEB301) Operational Web Log Analysis | AWS re:Invent 2014
(WEB301) Operational Web Log Analysis | AWS re:Invent 2014(WEB301) Operational Web Log Analysis | AWS re:Invent 2014
(WEB301) Operational Web Log Analysis | AWS re:Invent 2014
 
Monitoring in Big Data Platform - Albert Lewandowski, GetInData
Monitoring in Big Data Platform - Albert Lewandowski, GetInDataMonitoring in Big Data Platform - Albert Lewandowski, GetInData
Monitoring in Big Data Platform - Albert Lewandowski, GetInData
 
Stay productive while slicing up the monolith
Stay productive while slicing up the monolith Stay productive while slicing up the monolith
Stay productive while slicing up the monolith
 
Time series denver an introduction to prometheus
Time series denver   an introduction to prometheusTime series denver   an introduction to prometheus
Time series denver an introduction to prometheus
 
Using GitHub Actions to Deploy your Workloads to Azure
Using GitHub Actions to Deploy your Workloads to AzureUsing GitHub Actions to Deploy your Workloads to Azure
Using GitHub Actions to Deploy your Workloads to Azure
 

Recently uploaded

Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 

Recently uploaded (20)

Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 

Building a production ready meteor app

  • 1. Building a Production-Ready Meteor App by Ritik Malhotra Streem (https://www.streem.com)
  • 3. General Philosophy • Keep Meteor intact, build around what exists • Monkey patch only if necessary • Remove autopublish and insecure
  • 4. Part 1 App Structure How to design for maintainability
  • 5. App Structure /client /lib /packages /private /public /server /tests © your company name. All rights reserved. Title of your presentation
  • 6. Client-side code /client /css /js = 3rd party libraries (jQuery libs, etc.) /lib = Gets loaded first /helpers = client-side helper methods /meteor = meteor-specific client code router.js = Client-side routing startup.js = Run on new client init subscriptions.js = Subscribe to data /views /view-group template.html template.js = helpers, events, rendered - ex: /accounts/{login,register}.{html,js}
  • 7. Shared lib folder /lib /helpers - Helper functions that are useful on the client and server - ex: basename(), isValidEmailAddress() /models init.js = Instantiate collections - Individual model files containing model methods for specific collection - ex: UserModel.js contains getUsername(), setNotificationSetting(), etc. - Abstract database queries out to specific model functions
  • 8. Packages, assets, tests /packages - Smart packages that your app depends on - Use Atmosphere/Meteorite to manage these /private - Store private assets for the server to access - ex: Email templates /public = All your static assets /img /fonts /js - Contains any JS files that you don’t want minified and bundled in with the rest /tests = Test suite
  • 9. Server-side code /api - REST API (optional) /config accounts.js = Accounts.config(), etc. users.js = Accounts.onCreateUser(), etc. /helpers = Server-side helper functions /lib = What should get loaded first *settings.js = Load into Meteor.settings packages.js = Instantiate your NPM modules startup.js = Run on server startup /models = Server-only Meteor.methods /publish - Individual files for the type of data - ex: user.js to publish UserModel data
  • 10. Part 2 Packages Essential to maintaining your system
  • 11. Packages • Different categories of packages • • • • • Routing User accounts Testing Logging, error handling Optimizations • Node.js NPM packages • meteor-npm • https://github.com/arunoda/meteor-npm
  • 12. Routing • Client-side routing • iron-router • https://github.com/EventedMind/iron-router • Server-side routing • Useful for a REST API • meteor-router • https://github.com/tmeasday/meteor-router • reststop2 • https://github.com/BeDifferential/reststop2
  • 13. User Accounts • Meteor has an accounts system • http://docs.meteor.com/#accounts_api • accounts-password, accounts-facebook, etc… • accounts-ui for a simple UI • Configurable • Accounts.config, Accounts.ui.config • Accounts.onCreateUser, Accounts.validateNe wUser
  • 14. Testing • Optimized for Meteor • laika (http://arunoda.github.io/laika/) • Based off of mocha • Can write tests that interact with server and client • RTD (http://xolvio.github.io/rtd/) • Unit + acceptance testing • Other options • tinytest
  • 15. Logging & Error Handling • Logging • winston (https://github.com/flatiron/winston) • Compatible with Papertrail, Airbrake, etc. • Observatory (http://observatoryjs.com/) • Logs HTTP/DDP requests, subscriptions, etc. • Profiles your app, displays load, monitoring • Error handling • Raven/sentry • https://github.com/deepwell/meteor-raven
  • 16. Optimizations • Fast database synchronization • meteor-smart-collections package • https://github.com/arunoda/meteor-smart-collections • meteor-oplog branch • https://github.com/meteor/meteor/tree/oplog • Fast server synchronization • meteor-cluster package • https://github.com/arunoda/meteor-cluster • Not needed if using meteor-smartcollections or meteor-oplog
  • 17. Part 3 Server Architecture How to design for easy scalability
  • 18. Server Architecture • Multiple components • Deployment • Multiple web servers • Problem: slow data synchronization (10 seconds) • Load balancing • Problem: sticky sessions required • Scalable database (MongoDB) • Problem: inefficient to handle reactivity
  • 19. Deployment • Amazon Elastic Beanstalk • • • • Heroku for AWS Reliable, Amazon-backed Custom deploy scripts Manages server instances, load balancer, static asset delivery, monitoring, auto scaling
  • 20. Web Server • EC2 configuration • Node.js v0.8.24 or v0.10.10 • nginx • Point static assets to /public/* • gzip enabled • Build script (TODO: link) • Auto scaling • Auto-scale up 1 instance at 60% CPU usage • Auto-scale down 1 instance at 30% CPU usage • meteor-cluster package for fast data synchronization between server instances • Uses Redis
  • 21. Load Balancing • Elastic Load Balancer configuration • Cookie-based sticky sessions enabled • 0 second cookie expiration period • HTTP on port 80 • HTTPS on port 443 w/ SSL certificate • Health checks • Can’t use WebSockets • DISABLE_WEBSOCKETS = true • SockJS gracefully falls back
  • 22. Database • Easiest to use a hosted MongoDB solution • Best option • Oplog-enabled replica-set cluster • MongoLab SSD Cluster (or host your own) • meteor-smart-collections package or meteor-oplog branch • Alternative • MongoHQ/MongoLab regular DB instance
  • 23. Extras (optional) • Amazon CloudFront • CDN’d asset delivery • Can configure to deliver assets out of a specific app directory (/public) • Development, staging, production environments on Elastic Beanstalk • Enable monitoring on Elastic Beanstalk to get alerts when servers are down
  • 24. Server Diagram Route 53 / DNS SSL Elastic Load Balancer CloudFront nginx nginx Auto-scaling Meteor bundle + static assets EC2 (web server) EC2 (web server) MongoDB + Oplog
  • 25. What’s Next? • App scaffolding • Automatically generate your app structure • Packages to automate good practices • Meteor guides and tutorials • In-depth instructions on setting up your server, deploying your app, packages, etc. • Meteor Cookbook • Tips and tricks, FAQ • URL coming soon
  • 26. We’re Hiring Engineer #1! • Streem (https://www.streem.com) • Large-scale Meteor app • YCombinator-backed & venture-funded • jobs@streem.com • Ritik Malhotra • ritik@streem.com • @ritikm

Editor's Notes

  1. Going into detailEach key point is anchored with a question. I find posing a question to the audience relative to each key point engages them to proactively think and apply the ideas to their own situation vs. just listen to what I have to say.  Slide Notes:Place the title of the first key point where it says “People” and also in the box in the upper right.This may seem redundant, but the repetition is important. The “subline” in the upper right hand box is for a one or two word anchor to the first key point.In my case, the subline for “People” is “Happiness” – it’s the people you surround yourself with in business who impact your happiness.I’ll then carry the “box” in the upper right hand corner, color-coded to that section, to additional content slides in that section.
  2. Going into detailEach key point is anchored with a question. I find posing a question to the audience relative to each key point engages them to proactively think and apply the ideas to their own situation vs. just listen to what I have to say.  Slide Notes:Place the title of the first key point where it says “People” and also in the box in the upper right.This may seem redundant, but the repetition is important. The “subline” in the upper right hand box is for a one or two word anchor to the first key point.In my case, the subline for “People” is “Happiness” – it’s the people you surround yourself with in business who impact your happiness.I’ll then carry the “box” in the upper right hand corner, color-coded to that section, to additional content slides in that section.