SlideShare una empresa de Scribd logo
1 de 46
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.

Más contenido relacionado

La actualidad más candente

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 cloudPhilip Stehlik
 
PyCon India 2012: Celery Talk
PyCon India 2012: Celery TalkPyCon India 2012: Celery Talk
PyCon India 2012: Celery TalkPiyush 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 systemsMarkus 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 newsShapeBlue
 
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 ContractOmri Spector
 
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 2014Amazon 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 VPCMatthew Barlocker
 
Building Bizweb Microservices with Docker
Building Bizweb Microservices with DockerBuilding Bizweb Microservices with Docker
Building Bizweb Microservices with DockerKhô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_2020Michel 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 edgeFastly
 
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 LXCkscaldef
 
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 NetflixDocker, Inc.
 
Melbourne User Group OAK and MongoDB
Melbourne User Group OAK and MongoDBMelbourne User Group OAK and MongoDB
Melbourne User Group OAK and MongoDBYuval 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 2014Arun Gupta
 
Bulk Export Tool for Alfresco
Bulk Export Tool for AlfrescoBulk Export Tool for Alfresco
Bulk Export Tool for AlfrescoRichard McKnight
 
Xen_and_Rails_deployment
Xen_and_Rails_deploymentXen_and_Rails_deployment
Xen_and_Rails_deploymentAbhishek Singh
 

La actualidad más candente (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
 

Destacado

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 ApplicationsDesignveloper
 
MeteorJS - How to start
MeteorJS  -  How to startMeteorJS  -  How to start
MeteorJS - How to startDan Tran
 
Lessons Learned About MeteorJS
Lessons Learned About MeteorJSLessons Learned About MeteorJS
Lessons Learned About MeteorJSAlmog 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 MeteorjsMichael Lazarski
 
Meteor intro-2015
Meteor intro-2015Meteor intro-2015
Meteor intro-2015MeteorJS
 
Meteor presentation
Meteor presentationMeteor presentation
Meteor presentationscandiweb
 
Meteorites and Meteoroids
Meteorites and MeteoroidsMeteorites and Meteoroids
Meteorites and Meteoroidsangelothumbs
 
Build Your Own SaaS using Docker
Build Your Own SaaS using DockerBuild Your Own SaaS using Docker
Build Your Own SaaS using DockerJulien Barbier
 

Destacado (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 a Scaling a MeteorJS SaaS app on AWS

John adams talk cloudy
John adams   talk cloudyJohn adams   talk cloudy
John adams talk cloudyJohn 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 cloudDavid Veksler
 
Mongo DB at Community Engine
Mongo DB at Community EngineMongo DB at Community Engine
Mongo DB at Community EngineCommunity Engine
 
MongoDB at community engine
MongoDB at community engineMongoDB at community engine
MongoDB at community enginemathraq
 
State of the Container Ecosystem
State of the Container EcosystemState of the Container Ecosystem
State of the Container EcosystemVinay 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 throughputPaolo Negri
 
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
 
Erlang as a Cloud Citizen
Erlang as a Cloud CitizenErlang as a Cloud Citizen
Erlang as a Cloud CitizenWooga
 
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 GoelevenParticular Software
 
Satrtup Bootcamp - Scale on AWS
Satrtup Bootcamp - Scale on AWSSatrtup Bootcamp - Scale on AWS
Satrtup Bootcamp - Scale on AWSIdan Tohami
 
Deploying microservices on AWS
Deploying microservices on AWSDeploying microservices on AWS
Deploying microservices on AWSMichael Haberman
 
An introduction to Node.js
An introduction to Node.jsAn introduction to Node.js
An introduction to Node.jsKasey McCurdy
 
Integration in the age of DevOps
Integration in the age of DevOpsIntegration in the age of DevOps
Integration in the age of DevOpsAlbert 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 twitterRoger 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 TwitterJohn 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 microservicesBigstep
 

Similar a 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 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
 
Erlang as a Cloud Citizen
Erlang as a Cloud CitizenErlang as a Cloud Citizen
Erlang as a Cloud Citizen
 
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
 

Último

%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...masabamasaba
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfkalichargn70th171
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastPapp Krisztián
 
tonesoftg
tonesoftgtonesoftg
tonesoftglanshi9
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationJuha-Pekka Tolvanen
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxAnnaArtyushina1
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...masabamasaba
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Bert Jan Schrijver
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...masabamasaba
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...Jittipong Loespradit
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyviewmasabamasaba
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareJim McKeeth
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 

Último (20)

%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 

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.