SlideShare a Scribd company logo
Scaling a MeteorJS SaaS app on
AWS
Brett McLain
Application Systems Architect
PotashCorp
Agenda
• Overview of my application.
• Overview of MeteorJS (architecture,
deployment tools, clustering).
• Overview of Amazon (EC2, ELB, EBS, Route 53,
Auto Scaling).
• My journey of trying to scale MeteorJS on
Amazon Web Services.
What should you get out of this talk?
• A better understanding of MeteorJS.
• A better understanding of Amazon Web
Services.
• How to deploy, cluster, and scale a MeteorJS
web app.
Application Overview
• SaaS application that uses Twilio to send SMS
and phone calls to devices that connect to the
cell phone network.
• MeteorJS (runs on Node.js)
• MongoDB
• Flot Charts
• Twitter Bootstrap
• Blah blah blah.
What is MeteorJS?
• "Meteor is a full-stack JavaScript platform for
developing modern web and mobile applications.“
• Out of the box tight integration with MongoDB + full
data reactivity.
• Install MeteorJS and have an app written in minutes
with well established and easily understood patterns.
• Hot code push.
• Full data reactivity.
• Easily build for Android and iPhone (hot code push).
Meteor Architecture
• Production deployments are NodeJS applications.
• Meteor has it’s own package manager called
isobuild. Extremely similar to NPM.
• Meteor can also use NPM packages now on the
client or server (as of version 1.3).
• Supports ECMAScript 6 (ES 2015).
• Meteor Up (mup) - Meteor deployment plugin.
• Meteor Cluster - Meteor clustering plugin.
Meteor Architecture
Meteor Deployments
• I use Meteor Up (mup) for deployments.
• Single command to build and deploy code to an
unlimited number of servers in a rolling fashion.
• Installs all necessary software automatically
(NodeJS, npm, MeteorJS, docker, nginx, mongo).
• Setups up an nginx reverse proxy in front of a
docker instance for meteor and a docker instance
for mongo.
• 10 seconds of downtime per instance!
Meteor Cluster
• Provides clustering capability within Meteor JS
apps.
• Meteor Cluster is a regular meteor package.
• Turns each meteor server into a load balancer
or a DDP instance (backend server).New
nodes register with MongoDB backend and
are auto-discovered. Traffic begins routing to
them immediately.
Round Robin DNS Load Balancing
1 Load Balancer, 2 DDP Servers
2 Load Balancers, 2 DDP Servers
Meteor Clustering
• Load balancer servers are pointed to by DNS
records.
• Once the client connects to a load balancer
server, it *might* receive the address of a DDP
server to share out the load.
• Supports clustering of microservices too!
So…now what?
• Meteor has some great deployment and
clustering tools, but how do we deploy it in a
scalable way?We need to pick a host that fits
well with our deployment tools and utilize the
clustering capabilities of Meteor.
Initial Objectives
• Low Cost!
• Availability
• Performance
• Low Maintenance
Where to start?
• Originally hosted everything (prod, dev,
mongo, reverse proxy) on a single Virtual
Private Server (VPS).
• I have past experience with Amazon, it’s well
documented, tons of tools.
• Google *appears* pricier, less tools.
• Digital Ocean…?
So what does Amazon offer?
• EC2 (Elastic Compute Cloud)
• Elastic Bean Stalk
• Elastic Load Balancers
• Route 53 (DNS)
• OpsWorks
• CloudFormation
• Elastic Block Store
• The list goes on!
Elastic Compute Cloud (EC2)
• On demand infrastructure.
• Amazon Machine Image (AMI) of many popular
operating systems, platforms, community images,
etc.
• Reserved Instances - t2.micro = $0.006/hour - 3
year contract. Relatively cheap.
• Spot instances (bid for unused servers @ 80% of
cost).
• Can apply auto-scaling groups.
• Fairly basic...let's see what else Amazon has!
EC2 Availability Zones + Regions
• 11 Regions (i.e. US
East)
• 33 Availability
Zones
• us-east-1a
• us-east-1b, etc are
availability zones
while US East (N.
Virginia), US West
(Oregon), Asia
Pacific (Tokyo)
EC2 Regions
Elastic Beanstalk
• Elastic Beanstalk is a Platform as a Service
(PaaS) that handles the complexities of your
underlying infrastructure.
• Manages load balancing (via ELBs), instance
scaling, instance health monitoring, and
deployments.
• Supports Docker, Go, Java, .NET, Node, PHP,
Python, Ruby.
Let's see how this goes...
• Elastic Beanstalk seemed like a great solution.
Handles scaling and load balancing (with ELB).
• Ran into problems very quickly...
• MeteorJS settings are a JSON file exported as an
environment variable. Beanstalk strips
environment variables of a number of special
characters!
• Quickly realized that it is not possible to do
websockets, sticky sessions, and HTTPS with
Elastic Load Balancers.
How about OpsWorks?
• OpsWorks is a configuration management
service that helps you configure and operate
applications of all shapes and sizes using Chef.
• You can define the application’s architecture
and the specification of each component
including package installation, software
configuration and resources such as storage.
Nope!
• Stood up a MongoDB cluster and two separate
Meteor clusters.
• Autoscaling and application stack health-checks
are nice!
• Didn't bother using Chef as I have my own
deployment tools.
• Ran into problems very quickly...
• "running_setup" never ended. Servers would
hang. No support from Amazon!
Ok, uh, what else is left?
CloudFormation?
• CloudFormation allows you to define
infrastructure and services as a configuration
template.
• Provision servers, storage, networks, NATs,
relationships, run scripts, etc. all from a JSON
config.
• Rapid deployment of an entire stack,
extremely powerful and complicated.
CloudFormation
• I used the MongoDB CloudFormation
template provided by Amazon (only on github,
not via the CloudFormation interface).
• Over time I abandoned it as the scripts they
used for deployment contained a race
condition that would cause deployment to fail
about 50% of the time.
• For my purposes, this was overkill.
So, EC2 then?
• Setup 3 layers: (1) Load Balancers, (1) DDP
Servers, (3) Mongo Replica Sets (no shards).
• Created 5 DNS records for the load balancers to
do round robin DNS.
• Used Route 53 latency weighted routing to
failover load balancers that are offline to load
balancers that are online.
• 2 auto scaling groups, one for load balancers, one
for DDP servers.
• Lets Encrypt for SSL/TLS.
Route 53
• Route 53 is a highly available and scalable
DNS.Routing policies are:
– Simple Routing
– Weighted Routing
– Latency Routing
– Failover Routing
Down the rabbit hole…
• Auto scaling occurs when average CPU > 70%
for 2 minutes.
• When auto scaling occurs in either auto
scaling group, it creates a new instance using
the same image.
• That image runs a script on boot...
do_all_the_things.sh
• Step 1: git pull to get latest code.
• Step 2: Determine if an elastic IP address is
already assigned (if not, then this is a fresh
instance).
• Step 3a: If fresh instance, and DDP server, use
auto-assigned public IP.
• Step 3b: If fresh instance, and load balancer,
check to see which DNS elastic IP's are unused
and assign one.Deploy to self (build code and
deploy to localhost).
• Step 4: Done!
Testing Methodology
• Used MeteorDown for load testing. It connects to
an endpoint, opens up a DDP connect and
completes some action (in this case a 200kb
document transfer) before closing the
connection.
• Scale up connections incrementally and monitor
when and how fast instances are created.
• Determine total capability of 5 load balancers and
10 DDP servers (each instance is t2.micro, 1
vCPU, 512mb ram).
Testing Results
• First auto scaling event: provisioning of
instance, boot, git pull, build, and deploy is 2
minutes 30 seconds.
• Second+ auto scaling event: 1 minute 10
seconds.
• Concurrent subscriptions achieved: 38,000
• Maximum subscriptions per instance is
reduced by approximately 1% per added
instance.
What I learned…
• Meteor has very powerful tools out of the box,
however these tools do not lend themselves well
to solutions such as Elastic Beanstalk or Google
App Engine.
• DNS is a finicky mistress.
• Scaling load balancers is hard; scaling a web app
using sticky websockets is even harder!
• Diving in head first has some serious drawbacks -
it's difficult to navigate this space without
someone to guide you.
What did I end up with?
• One line command to do rolling deployments to all my
servers.
• 10 second downtime when deploying.
• Highly available (across AZ's), scalable architecture
(auto-scaling + MongoDB sharding/replicas).
• 38,000 concurrent connections constantly re-
establishing websockets and sending data.
• Great support for microservices.
• Reactive data and UI, hot code push, mobile
deployment.
What was the point of this?
• Hopefully you understand that it IS possible to
scale MeteorJS applications, and that it isn't
that hard (I just made it hard for myself).
• High level understanding of a few of Amazon's
infrastructure and deployment services.

More Related Content

What's hot

Deploying and running Grails in the cloud
Deploying and running Grails in the cloudDeploying and running Grails in the cloud
Deploying and running Grails in the cloud
Philip Stehlik
 
PyCon India 2012: Celery Talk
PyCon India 2012: Celery TalkPyCon India 2012: Celery Talk
PyCon India 2012: Celery Talk
Piyush Kumar
 
How lagom helps to build real world microservice systems
How lagom helps to build real world microservice systemsHow lagom helps to build real world microservice systems
How lagom helps to build real world microservice systems
Markus Eisele
 
From VMs to Containers: Introducing Docker Containers for Linux and Windows S...
From VMs to Containers: Introducing Docker Containers for Linux and Windows S...From VMs to Containers: Introducing Docker Containers for Linux and Windows S...
From VMs to Containers: Introducing Docker Containers for Linux and Windows S...
Ido Flatow
 
What's new with tooling for Spring, Grails, and the Cloud
What's new with tooling for Spring, Grails, and the CloudWhat's new with tooling for Spring, Grails, and the Cloud
What's new with tooling for Spring, Grails, and the Cloudmartinlippert
 
Giles sirett welcome and cloud stack news
Giles sirett   welcome and cloud stack newsGiles sirett   welcome and cloud stack news
Giles sirett welcome and cloud stack news
ShapeBlue
 
Coordinating Micro-Services with Spring Cloud Contract
Coordinating Micro-Services with Spring Cloud ContractCoordinating Micro-Services with Spring Cloud Contract
Coordinating Micro-Services with Spring Cloud Contract
Omri Spector
 
Introducing CQ 5.1
Introducing CQ 5.1Introducing CQ 5.1
Introducing CQ 5.1
David Nuescheler
 
2 Day Bootcamp for OpenStack--Cloud Training by Mirantis (Preview)
2 Day Bootcamp for OpenStack--Cloud Training by Mirantis (Preview)2 Day Bootcamp for OpenStack--Cloud Training by Mirantis (Preview)
2 Day Bootcamp for OpenStack--Cloud Training by Mirantis (Preview)
Mirantis
 
(APP309) Running and Monitoring Docker Containers at Scale | AWS re:Invent 2014
(APP309) Running and Monitoring Docker Containers at Scale | AWS re:Invent 2014(APP309) Running and Monitoring Docker Containers at Scale | AWS re:Invent 2014
(APP309) Running and Monitoring Docker Containers at Scale | AWS re:Invent 2014
Amazon Web Services
 
Case Study: Lucidchart's Migration to VPC
Case Study: Lucidchart's Migration to VPCCase Study: Lucidchart's Migration to VPC
Case Study: Lucidchart's Migration to VPC
Matthew Barlocker
 
Building Bizweb Microservices with Docker
Building Bizweb Microservices with DockerBuilding Bizweb Microservices with Docker
Building Bizweb Microservices with Docker
Khôi Nguyễn Minh
 
Keynote Oracle Fusion Middleware Summit_2020
Keynote Oracle Fusion Middleware Summit_2020Keynote Oracle Fusion Middleware Summit_2020
Keynote Oracle Fusion Middleware Summit_2020
Michel Schildmeijer
 
Altitude SF 2017: Security at the edge
Altitude SF 2017: Security at the edgeAltitude SF 2017: Security at the edge
Altitude SF 2017: Security at the edge
Fastly
 
Innovating faster with SBT, Continuous Delivery, and LXC
Innovating faster with SBT, Continuous Delivery, and LXCInnovating faster with SBT, Continuous Delivery, and LXC
Innovating faster with SBT, Continuous Delivery, and LXC
kscaldef
 
DCSF19 Container Security: Theory & Practice at Netflix
DCSF19 Container Security: Theory & Practice at NetflixDCSF19 Container Security: Theory & Practice at Netflix
DCSF19 Container Security: Theory & Practice at Netflix
Docker, Inc.
 
Melbourne User Group OAK and MongoDB
Melbourne User Group OAK and MongoDBMelbourne User Group OAK and MongoDB
Melbourne User Group OAK and MongoDB
Yuval Ararat
 
Lessons Learned from Real-World Deployments of Java EE 7 at JavaOne 2014
Lessons Learned from Real-World Deployments of Java EE 7 at JavaOne 2014Lessons Learned from Real-World Deployments of Java EE 7 at JavaOne 2014
Lessons Learned from Real-World Deployments of Java EE 7 at JavaOne 2014
Arun Gupta
 
Bulk Export Tool for Alfresco
Bulk Export Tool for AlfrescoBulk Export Tool for Alfresco
Bulk Export Tool for Alfresco
Richard McKnight
 
Xen_and_Rails_deployment
Xen_and_Rails_deploymentXen_and_Rails_deployment
Xen_and_Rails_deploymentAbhishek Singh
 

What's hot (20)

Deploying and running Grails in the cloud
Deploying and running Grails in the cloudDeploying and running Grails in the cloud
Deploying and running Grails in the cloud
 
PyCon India 2012: Celery Talk
PyCon India 2012: Celery TalkPyCon India 2012: Celery Talk
PyCon India 2012: Celery Talk
 
How lagom helps to build real world microservice systems
How lagom helps to build real world microservice systemsHow lagom helps to build real world microservice systems
How lagom helps to build real world microservice systems
 
From VMs to Containers: Introducing Docker Containers for Linux and Windows S...
From VMs to Containers: Introducing Docker Containers for Linux and Windows S...From VMs to Containers: Introducing Docker Containers for Linux and Windows S...
From VMs to Containers: Introducing Docker Containers for Linux and Windows S...
 
What's new with tooling for Spring, Grails, and the Cloud
What's new with tooling for Spring, Grails, and the CloudWhat's new with tooling for Spring, Grails, and the Cloud
What's new with tooling for Spring, Grails, and the Cloud
 
Giles sirett welcome and cloud stack news
Giles sirett   welcome and cloud stack newsGiles sirett   welcome and cloud stack news
Giles sirett welcome and cloud stack news
 
Coordinating Micro-Services with Spring Cloud Contract
Coordinating Micro-Services with Spring Cloud ContractCoordinating Micro-Services with Spring Cloud Contract
Coordinating Micro-Services with Spring Cloud Contract
 
Introducing CQ 5.1
Introducing CQ 5.1Introducing CQ 5.1
Introducing CQ 5.1
 
2 Day Bootcamp for OpenStack--Cloud Training by Mirantis (Preview)
2 Day Bootcamp for OpenStack--Cloud Training by Mirantis (Preview)2 Day Bootcamp for OpenStack--Cloud Training by Mirantis (Preview)
2 Day Bootcamp for OpenStack--Cloud Training by Mirantis (Preview)
 
(APP309) Running and Monitoring Docker Containers at Scale | AWS re:Invent 2014
(APP309) Running and Monitoring Docker Containers at Scale | AWS re:Invent 2014(APP309) Running and Monitoring Docker Containers at Scale | AWS re:Invent 2014
(APP309) Running and Monitoring Docker Containers at Scale | AWS re:Invent 2014
 
Case Study: Lucidchart's Migration to VPC
Case Study: Lucidchart's Migration to VPCCase Study: Lucidchart's Migration to VPC
Case Study: Lucidchart's Migration to VPC
 
Building Bizweb Microservices with Docker
Building Bizweb Microservices with DockerBuilding Bizweb Microservices with Docker
Building Bizweb Microservices with Docker
 
Keynote Oracle Fusion Middleware Summit_2020
Keynote Oracle Fusion Middleware Summit_2020Keynote Oracle Fusion Middleware Summit_2020
Keynote Oracle Fusion Middleware Summit_2020
 
Altitude SF 2017: Security at the edge
Altitude SF 2017: Security at the edgeAltitude SF 2017: Security at the edge
Altitude SF 2017: Security at the edge
 
Innovating faster with SBT, Continuous Delivery, and LXC
Innovating faster with SBT, Continuous Delivery, and LXCInnovating faster with SBT, Continuous Delivery, and LXC
Innovating faster with SBT, Continuous Delivery, and LXC
 
DCSF19 Container Security: Theory & Practice at Netflix
DCSF19 Container Security: Theory & Practice at NetflixDCSF19 Container Security: Theory & Practice at Netflix
DCSF19 Container Security: Theory & Practice at Netflix
 
Melbourne User Group OAK and MongoDB
Melbourne User Group OAK and MongoDBMelbourne User Group OAK and MongoDB
Melbourne User Group OAK and MongoDB
 
Lessons Learned from Real-World Deployments of Java EE 7 at JavaOne 2014
Lessons Learned from Real-World Deployments of Java EE 7 at JavaOne 2014Lessons Learned from Real-World Deployments of Java EE 7 at JavaOne 2014
Lessons Learned from Real-World Deployments of Java EE 7 at JavaOne 2014
 
Bulk Export Tool for Alfresco
Bulk Export Tool for AlfrescoBulk Export Tool for Alfresco
Bulk Export Tool for Alfresco
 
Xen_and_Rails_deployment
Xen_and_Rails_deploymentXen_and_Rails_deployment
Xen_and_Rails_deployment
 

Viewers also liked

Building a production ready meteor app
Building a production ready meteor appBuilding a production ready meteor app
Building a production ready meteor appRitik Malhotra
 
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
Designveloper
 
MeteorJS - How to start
MeteorJS  -  How to startMeteorJS  -  How to start
MeteorJS - How to start
Dan Tran
 
MeteorJS Introduction
MeteorJS IntroductionMeteorJS Introduction
MeteorJS Introduction
Nitya Narasimhan
 
D3 & MeteorJS
D3 & MeteorJSD3 & MeteorJS
D3 & MeteorJS
saarmstrong
 
Lessons Learned About MeteorJS
Lessons Learned About MeteorJSLessons Learned About MeteorJS
Lessons Learned About MeteorJS
Almog Koren
 
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
Michael Lazarski
 
Meteor intro-2015
Meteor intro-2015Meteor intro-2015
Meteor intro-2015
MeteorJS
 
Meteor presentation
Meteor presentationMeteor presentation
Meteor presentation
scandiweb
 
Meteorites and Meteoroids
Meteorites and MeteoroidsMeteorites and Meteoroids
Meteorites and Meteoroids
angelothumbs
 
Build Your Own SaaS using Docker
Build Your Own SaaS using DockerBuild Your Own SaaS using Docker
Build Your Own SaaS using Docker
Julien Barbier
 
Presentation .- meteors
Presentation  .- meteorsPresentation  .- meteors
Presentation .- meteors
Romilenes Paraiso
 

Viewers also liked (12)

Building a production ready meteor app
Building a production ready meteor appBuilding a production ready meteor app
Building a production ready meteor app
 
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
 
MeteorJS - How to start
MeteorJS  -  How to startMeteorJS  -  How to start
MeteorJS - How to start
 
MeteorJS Introduction
MeteorJS IntroductionMeteorJS Introduction
MeteorJS Introduction
 
D3 & MeteorJS
D3 & MeteorJSD3 & MeteorJS
D3 & MeteorJS
 
Lessons Learned About MeteorJS
Lessons Learned About MeteorJSLessons Learned About MeteorJS
Lessons Learned About MeteorJS
 
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
 
Meteor presentation
Meteor presentationMeteor presentation
Meteor presentation
 
Meteorites and Meteoroids
Meteorites and MeteoroidsMeteorites and Meteoroids
Meteorites and Meteoroids
 
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
 

Similar to Scaling a MeteorJS SaaS app on AWS

John adams talk cloudy
John adams   talk cloudyJohn adams   talk cloudy
John adams talk cloudy
John Adams
 
Nuts and bolts of running a popular site in the aws cloud
Nuts and bolts of running a popular site in the aws cloudNuts and bolts of running a popular site in the aws cloud
Nuts and bolts of running a popular site in the aws cloud
David Veksler
 
Mongo DB at Community Engine
Mongo DB at Community EngineMongo DB at Community Engine
Mongo DB at Community Engine
Community Engine
 
MongoDB at community engine
MongoDB at community engineMongoDB at community engine
MongoDB at community engine
mathraq
 
State of the Container Ecosystem
State of the Container EcosystemState of the Container Ecosystem
State of the Container Ecosystem
Vinay Rao
 
Erlang as a cloud citizen, a fractal approach to throughput
Erlang as a cloud citizen, a fractal approach to throughputErlang as a cloud citizen, a fractal approach to throughput
Erlang as a cloud citizen, a fractal approach to throughput
Paolo Negri
 
Erlang as a Cloud Citizen
Erlang as a Cloud CitizenErlang as a Cloud Citizen
Erlang as a Cloud Citizen
Wooga
 
Erlang and the Cloud: A Fractal Approach to Throughput
Erlang and the Cloud: A Fractal Approach to ThroughputErlang and the Cloud: A Fractal Approach to Throughput
Erlang and the Cloud: A Fractal Approach to ThroughputWooga
 
The impact of cloud NSBCon NY by Yves Goeleven
The impact of cloud NSBCon NY by Yves GoelevenThe impact of cloud NSBCon NY by Yves Goeleven
The impact of cloud NSBCon NY by Yves Goeleven
Particular Software
 
Satrtup Bootcamp - Scale on AWS
Satrtup Bootcamp - Scale on AWSSatrtup Bootcamp - Scale on AWS
Satrtup Bootcamp - Scale on AWS
Idan Tohami
 
Deploying microservices on AWS
Deploying microservices on AWSDeploying microservices on AWS
Deploying microservices on AWS
Michael Haberman
 
An introduction to Node.js
An introduction to Node.jsAn introduction to Node.js
An introduction to Node.js
Kasey McCurdy
 
Integration in the age of DevOps
Integration in the age of DevOpsIntegration in the age of DevOps
Integration in the age of DevOps
Albert Wong
 
To Build My Own Cloud with Blackjack…
To Build My Own Cloud with Blackjack…To Build My Own Cloud with Blackjack…
To Build My Own Cloud with Blackjack…
Sergey Dzyuban
 
Fixing twitter
Fixing twitterFixing twitter
Fixing twitter
Roger Xia
 
Fixing Twitter Improving The Performance And Scalability Of The Worlds Most ...
Fixing Twitter  Improving The Performance And Scalability Of The Worlds Most ...Fixing Twitter  Improving The Performance And Scalability Of The Worlds Most ...
Fixing Twitter Improving The Performance And Scalability Of The Worlds Most ...
smallerror
 
Fixing Twitter Improving The Performance And Scalability Of The Worlds Most ...
Fixing Twitter  Improving The Performance And Scalability Of The Worlds Most ...Fixing Twitter  Improving The Performance And Scalability Of The Worlds Most ...
Fixing Twitter Improving The Performance And Scalability Of The Worlds Most ...xlight
 
Chirp 2010: Scaling Twitter
Chirp 2010: Scaling TwitterChirp 2010: Scaling Twitter
Chirp 2010: Scaling Twitter
John Adams
 
Data Lake and the rise of the microservices
Data Lake and the rise of the microservicesData Lake and the rise of the microservices
Data Lake and the rise of the microservices
Bigstep
 

Similar to Scaling a MeteorJS SaaS app on AWS (20)

John adams talk cloudy
John adams   talk cloudyJohn adams   talk cloudy
John adams talk cloudy
 
Nuts and bolts of running a popular site in the aws cloud
Nuts and bolts of running a popular site in the aws cloudNuts and bolts of running a popular site in the aws cloud
Nuts and bolts of running a popular site in the aws cloud
 
Mongo DB at Community Engine
Mongo DB at Community EngineMongo DB at Community Engine
Mongo DB at Community Engine
 
MongoDB at community engine
MongoDB at community engineMongoDB at community engine
MongoDB at community engine
 
State of the Container Ecosystem
State of the Container EcosystemState of the Container Ecosystem
State of the Container Ecosystem
 
Erlang as a cloud citizen, a fractal approach to throughput
Erlang as a cloud citizen, a fractal approach to throughputErlang as a cloud citizen, a fractal approach to throughput
Erlang as a cloud citizen, a fractal approach to throughput
 
Erlang as a Cloud Citizen
Erlang as a Cloud CitizenErlang as a Cloud Citizen
Erlang as a Cloud Citizen
 
Erlang and the Cloud: A Fractal Approach to Throughput
Erlang and the Cloud: A Fractal Approach to ThroughputErlang and the Cloud: A Fractal Approach to Throughput
Erlang and the Cloud: A Fractal Approach to Throughput
 
The impact of cloud NSBCon NY by Yves Goeleven
The impact of cloud NSBCon NY by Yves GoelevenThe impact of cloud NSBCon NY by Yves Goeleven
The impact of cloud NSBCon NY by Yves Goeleven
 
Satrtup Bootcamp - Scale on AWS
Satrtup Bootcamp - Scale on AWSSatrtup Bootcamp - Scale on AWS
Satrtup Bootcamp - Scale on AWS
 
Deploying microservices on AWS
Deploying microservices on AWSDeploying microservices on AWS
Deploying microservices on AWS
 
An introduction to Node.js
An introduction to Node.jsAn introduction to Node.js
An introduction to Node.js
 
Integration in the age of DevOps
Integration in the age of DevOpsIntegration in the age of DevOps
Integration in the age of DevOps
 
To Build My Own Cloud with Blackjack…
To Build My Own Cloud with Blackjack…To Build My Own Cloud with Blackjack…
To Build My Own Cloud with Blackjack…
 
Fixing twitter
Fixing twitterFixing twitter
Fixing twitter
 
Fixing_Twitter
Fixing_TwitterFixing_Twitter
Fixing_Twitter
 
Fixing Twitter Improving The Performance And Scalability Of The Worlds Most ...
Fixing Twitter  Improving The Performance And Scalability Of The Worlds Most ...Fixing Twitter  Improving The Performance And Scalability Of The Worlds Most ...
Fixing Twitter Improving The Performance And Scalability Of The Worlds Most ...
 
Fixing Twitter Improving The Performance And Scalability Of The Worlds Most ...
Fixing Twitter  Improving The Performance And Scalability Of The Worlds Most ...Fixing Twitter  Improving The Performance And Scalability Of The Worlds Most ...
Fixing Twitter Improving The Performance And Scalability Of The Worlds Most ...
 
Chirp 2010: Scaling Twitter
Chirp 2010: Scaling TwitterChirp 2010: Scaling Twitter
Chirp 2010: Scaling Twitter
 
Data Lake and the rise of the microservices
Data Lake and the rise of the microservicesData Lake and the rise of the microservices
Data Lake and the rise of the microservices
 

Recently uploaded

Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
WSO2
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
Ortus Solutions, Corp
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
NYGGS Automation Suite
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
Matt Welsh
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
Juraj Vysvader
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
Cyanic lab
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdfEnhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Jay Das
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
Globus
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 

Recently uploaded (20)

Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdfEnhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 

Scaling a MeteorJS SaaS app on AWS

  • 1. Scaling a MeteorJS SaaS app on AWS Brett McLain Application Systems Architect PotashCorp
  • 2. Agenda • Overview of my application. • Overview of MeteorJS (architecture, deployment tools, clustering). • Overview of Amazon (EC2, ELB, EBS, Route 53, Auto Scaling). • My journey of trying to scale MeteorJS on Amazon Web Services.
  • 3. What should you get out of this talk? • A better understanding of MeteorJS. • A better understanding of Amazon Web Services. • How to deploy, cluster, and scale a MeteorJS web app.
  • 4. Application Overview • SaaS application that uses Twilio to send SMS and phone calls to devices that connect to the cell phone network. • MeteorJS (runs on Node.js) • MongoDB • Flot Charts • Twitter Bootstrap • Blah blah blah.
  • 5. What is MeteorJS? • "Meteor is a full-stack JavaScript platform for developing modern web and mobile applications.“ • Out of the box tight integration with MongoDB + full data reactivity. • Install MeteorJS and have an app written in minutes with well established and easily understood patterns. • Hot code push. • Full data reactivity. • Easily build for Android and iPhone (hot code push).
  • 6. Meteor Architecture • Production deployments are NodeJS applications. • Meteor has it’s own package manager called isobuild. Extremely similar to NPM. • Meteor can also use NPM packages now on the client or server (as of version 1.3). • Supports ECMAScript 6 (ES 2015). • Meteor Up (mup) - Meteor deployment plugin. • Meteor Cluster - Meteor clustering plugin.
  • 8. Meteor Deployments • I use Meteor Up (mup) for deployments. • Single command to build and deploy code to an unlimited number of servers in a rolling fashion. • Installs all necessary software automatically (NodeJS, npm, MeteorJS, docker, nginx, mongo). • Setups up an nginx reverse proxy in front of a docker instance for meteor and a docker instance for mongo. • 10 seconds of downtime per instance!
  • 9.
  • 10. Meteor Cluster • Provides clustering capability within Meteor JS apps. • Meteor Cluster is a regular meteor package. • Turns each meteor server into a load balancer or a DDP instance (backend server).New nodes register with MongoDB backend and are auto-discovered. Traffic begins routing to them immediately.
  • 11. Round Robin DNS Load Balancing
  • 12. 1 Load Balancer, 2 DDP Servers
  • 13. 2 Load Balancers, 2 DDP Servers
  • 14. Meteor Clustering • Load balancer servers are pointed to by DNS records. • Once the client connects to a load balancer server, it *might* receive the address of a DDP server to share out the load. • Supports clustering of microservices too!
  • 15. So…now what? • Meteor has some great deployment and clustering tools, but how do we deploy it in a scalable way?We need to pick a host that fits well with our deployment tools and utilize the clustering capabilities of Meteor.
  • 16. Initial Objectives • Low Cost! • Availability • Performance • Low Maintenance
  • 17. Where to start? • Originally hosted everything (prod, dev, mongo, reverse proxy) on a single Virtual Private Server (VPS). • I have past experience with Amazon, it’s well documented, tons of tools. • Google *appears* pricier, less tools. • Digital Ocean…?
  • 18. So what does Amazon offer? • EC2 (Elastic Compute Cloud) • Elastic Bean Stalk • Elastic Load Balancers • Route 53 (DNS) • OpsWorks • CloudFormation • Elastic Block Store • The list goes on!
  • 19.
  • 20. Elastic Compute Cloud (EC2) • On demand infrastructure. • Amazon Machine Image (AMI) of many popular operating systems, platforms, community images, etc. • Reserved Instances - t2.micro = $0.006/hour - 3 year contract. Relatively cheap. • Spot instances (bid for unused servers @ 80% of cost). • Can apply auto-scaling groups. • Fairly basic...let's see what else Amazon has!
  • 21. EC2 Availability Zones + Regions • 11 Regions (i.e. US East) • 33 Availability Zones • us-east-1a • us-east-1b, etc are availability zones while US East (N. Virginia), US West (Oregon), Asia Pacific (Tokyo)
  • 23. Elastic Beanstalk • Elastic Beanstalk is a Platform as a Service (PaaS) that handles the complexities of your underlying infrastructure. • Manages load balancing (via ELBs), instance scaling, instance health monitoring, and deployments. • Supports Docker, Go, Java, .NET, Node, PHP, Python, Ruby.
  • 24. Let's see how this goes... • Elastic Beanstalk seemed like a great solution. Handles scaling and load balancing (with ELB). • Ran into problems very quickly... • MeteorJS settings are a JSON file exported as an environment variable. Beanstalk strips environment variables of a number of special characters! • Quickly realized that it is not possible to do websockets, sticky sessions, and HTTPS with Elastic Load Balancers.
  • 25. How about OpsWorks? • OpsWorks is a configuration management service that helps you configure and operate applications of all shapes and sizes using Chef. • You can define the application’s architecture and the specification of each component including package installation, software configuration and resources such as storage.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30. Nope! • Stood up a MongoDB cluster and two separate Meteor clusters. • Autoscaling and application stack health-checks are nice! • Didn't bother using Chef as I have my own deployment tools. • Ran into problems very quickly... • "running_setup" never ended. Servers would hang. No support from Amazon!
  • 31. Ok, uh, what else is left? CloudFormation? • CloudFormation allows you to define infrastructure and services as a configuration template. • Provision servers, storage, networks, NATs, relationships, run scripts, etc. all from a JSON config. • Rapid deployment of an entire stack, extremely powerful and complicated.
  • 32.
  • 33.
  • 34. CloudFormation • I used the MongoDB CloudFormation template provided by Amazon (only on github, not via the CloudFormation interface). • Over time I abandoned it as the scripts they used for deployment contained a race condition that would cause deployment to fail about 50% of the time. • For my purposes, this was overkill.
  • 35. So, EC2 then? • Setup 3 layers: (1) Load Balancers, (1) DDP Servers, (3) Mongo Replica Sets (no shards). • Created 5 DNS records for the load balancers to do round robin DNS. • Used Route 53 latency weighted routing to failover load balancers that are offline to load balancers that are online. • 2 auto scaling groups, one for load balancers, one for DDP servers. • Lets Encrypt for SSL/TLS.
  • 36. Route 53 • Route 53 is a highly available and scalable DNS.Routing policies are: – Simple Routing – Weighted Routing – Latency Routing – Failover Routing
  • 37. Down the rabbit hole… • Auto scaling occurs when average CPU > 70% for 2 minutes. • When auto scaling occurs in either auto scaling group, it creates a new instance using the same image. • That image runs a script on boot...
  • 38. do_all_the_things.sh • Step 1: git pull to get latest code. • Step 2: Determine if an elastic IP address is already assigned (if not, then this is a fresh instance). • Step 3a: If fresh instance, and DDP server, use auto-assigned public IP. • Step 3b: If fresh instance, and load balancer, check to see which DNS elastic IP's are unused and assign one.Deploy to self (build code and deploy to localhost). • Step 4: Done!
  • 39.
  • 40.
  • 41.
  • 42. Testing Methodology • Used MeteorDown for load testing. It connects to an endpoint, opens up a DDP connect and completes some action (in this case a 200kb document transfer) before closing the connection. • Scale up connections incrementally and monitor when and how fast instances are created. • Determine total capability of 5 load balancers and 10 DDP servers (each instance is t2.micro, 1 vCPU, 512mb ram).
  • 43. Testing Results • First auto scaling event: provisioning of instance, boot, git pull, build, and deploy is 2 minutes 30 seconds. • Second+ auto scaling event: 1 minute 10 seconds. • Concurrent subscriptions achieved: 38,000 • Maximum subscriptions per instance is reduced by approximately 1% per added instance.
  • 44. What I learned… • Meteor has very powerful tools out of the box, however these tools do not lend themselves well to solutions such as Elastic Beanstalk or Google App Engine. • DNS is a finicky mistress. • Scaling load balancers is hard; scaling a web app using sticky websockets is even harder! • Diving in head first has some serious drawbacks - it's difficult to navigate this space without someone to guide you.
  • 45. What did I end up with? • One line command to do rolling deployments to all my servers. • 10 second downtime when deploying. • Highly available (across AZ's), scalable architecture (auto-scaling + MongoDB sharding/replicas). • 38,000 concurrent connections constantly re- establishing websockets and sending data. • Great support for microservices. • Reactive data and UI, hot code push, mobile deployment.
  • 46. What was the point of this? • Hopefully you understand that it IS possible to scale MeteorJS applications, and that it isn't that hard (I just made it hard for myself). • High level understanding of a few of Amazon's infrastructure and deployment services.