SCALING ON AWS – FROM MVP TO 100 MILLION USERS by: Muhammad Umair Cloudifie: Cloud for Start-ups...

41
SCALING ON AWS – FROM MVP TO 100 MILLION USERS by: Muhammad Umair Cloudifie: Cloud for Start-ups @cloudifie

Transcript of SCALING ON AWS – FROM MVP TO 100 MILLION USERS by: Muhammad Umair Cloudifie: Cloud for Start-ups...

Page 1: SCALING ON AWS – FROM MVP TO 100 MILLION USERS by: Muhammad Umair Cloudifie: Cloud for Start-ups @cloudifie.

SCALING ON AWS – FROM MVP TO 100 MILLION USERS

by: Muhammad Umair

Cloudifie: Cloud for Start-ups@cloudifie

Page 2: SCALING ON AWS – FROM MVP TO 100 MILLION USERS by: Muhammad Umair Cloudifie: Cloud for Start-ups @cloudifie.

Introduction

Page 3: SCALING ON AWS – FROM MVP TO 100 MILLION USERS by: Muhammad Umair Cloudifie: Cloud for Start-ups @cloudifie.

Startup Challenges & Limitations

Challenges: High Competition Rapid Growth Fast Paced Marketing

Limitations: Tight Budget Time Constraints Limited Resources

Page 4: SCALING ON AWS – FROM MVP TO 100 MILLION USERS by: Muhammad Umair Cloudifie: Cloud for Start-ups @cloudifie.

Solution

Change traditional model, use agile solutions

Fail forward, fail fast and fail cheap

Focus on Product/App, not Infrastructure

Page 5: SCALING ON AWS – FROM MVP TO 100 MILLION USERS by: Muhammad Umair Cloudifie: Cloud for Start-ups @cloudifie.

Cloud Computing

Model of computing which allows to use shared resources on demand.

IaaS Offers Computing Infrastructure, like VM,

Storage, Network etc.

PaaS Offers Computing Platform e.g. Execution

runtimes, database, web-servers

SaaS Offer Application Services like CRM, Email,

Monitoring etc

Page 6: SCALING ON AWS – FROM MVP TO 100 MILLION USERS by: Muhammad Umair Cloudifie: Cloud for Start-ups @cloudifie.

Why AWS

1. Develop, Test, Deploy and go Global using same automated infrastructure.

2. Elastic infrastructure, easily scale up and down in no-time.

3. Low infrastructure cost – instead of high fixed cost.

Page 7: SCALING ON AWS – FROM MVP TO 100 MILLION USERS by: Muhammad Umair Cloudifie: Cloud for Start-ups @cloudifie.

Infrastructure: Global Footprint

Page 8: SCALING ON AWS – FROM MVP TO 100 MILLION USERS by: Muhammad Umair Cloudifie: Cloud for Start-ups @cloudifie.

AWS Building Blocks

Page 9: SCALING ON AWS – FROM MVP TO 100 MILLION USERS by: Muhammad Umair Cloudifie: Cloud for Start-ups @cloudifie.

AWS Services (Grouped)

Page 10: SCALING ON AWS – FROM MVP TO 100 MILLION USERS by: Muhammad Umair Cloudifie: Cloud for Start-ups @cloudifie.

MVP: Single Tier Architecture

Full application stack on single EC2 instance Application Database Web server Management etc

Elastic IP address Amazon Route53 for

DNS

1-100 request served concurrently

www.cloudifie.com

Page 11: SCALING ON AWS – FROM MVP TO 100 MILLION USERS by: Muhammad Umair Cloudifie: Cloud for Start-ups @cloudifie.

More Users, What to Do?

Scale Vertically Scale up for higher

capacity Scale down for lower

capacity

Scale from AWS Micro to Large computing instances

Easy to change instance types but will hit an endpoint eventually.

t2.micro

c4.8xlarge

Page 12: SCALING ON AWS – FROM MVP TO 100 MILLION USERS by: Muhammad Umair Cloudifie: Cloud for Start-ups @cloudifie.

Instance Types1. General Purpose

T2: instances with ability to burst above baseline performance M4: largest generation of GP, balanced compute, memory &

network

2. Compute Optimized C3: compute optimized for web-servers, batch processing &

analytics C4: largest in CO, best for high performance science &

engineering apps

3. Memory Optimized R3: recommended for high performance databases, distributed

memory cache, in-memory analytics & SAP, SharePoint etc.

4. Storage Optimized I2 & D2: Good for high IO NoSQL DBs & MPP data warehousing,

file systems, MapReduce/Hadoop, log processing

Page 13: SCALING ON AWS – FROM MVP TO 100 MILLION USERS by: Muhammad Umair Cloudifie: Cloud for Start-ups @cloudifie.

Vertical Scale Limitation

Can serve user up-to certain extend, like 100-1000 users.

Everything in same basket

No redundancy No failover

www.cloudifie.com

Page 14: SCALING ON AWS – FROM MVP TO 100 MILLION USERS by: Muhammad Umair Cloudifie: Cloud for Start-ups @cloudifie.

Two-Tiers Architecture

Solution?

Page 15: SCALING ON AWS – FROM MVP TO 100 MILLION USERS by: Muhammad Umair Cloudifie: Cloud for Start-ups @cloudifie.

Two-Tiers Architecture

Separately host application and

database.

Application on EC2 Self Managed

Database on EC2

or Use Amazon

Database Services

www.cloudifie.com

Page 16: SCALING ON AWS – FROM MVP TO 100 MILLION USERS by: Muhammad Umair Cloudifie: Cloud for Start-ups @cloudifie.

Benefits of Two-Tiers Architecture

Tailor instances for each tier Instance Type Storage

Easily manageable Scale each tier separately Enhanced Security

Separate security policy for each tier

DB behind the VPC subnet

www.cloudifie.com

Page 17: SCALING ON AWS – FROM MVP TO 100 MILLION USERS by: Muhammad Umair Cloudifie: Cloud for Start-ups @cloudifie.

Amazon Database Services

Rational Database Service (RDS) Managed relational database service Supports MySQL, Postgres, Oracle, SQL Server, and

Amazon Aurora ( up to 30 million select per minute)

Amazon DynamoDB: Fast, predictable, highly-scalable Amazon NoSQL data

store

Amazon Redshift Simple & cost effective, fully managed petabyte scale data warehouse

Page 18: SCALING ON AWS – FROM MVP TO 100 MILLION USERS by: Muhammad Umair Cloudifie: Cloud for Start-ups @cloudifie.

Which Database Service?

Choose Relational Database Service until there is clear use case for NoSQL, Why? Feature-rich well worn technology Mature & big community offering loads of help, code

and huge knowledgebase Can serve up to million users easily Patterns for read heavy scalability

Page 19: SCALING ON AWS – FROM MVP TO 100 MILLION USERS by: Muhammad Umair Cloudifie: Cloud for Start-ups @cloudifie.

Use NoSQL When

Super low latency is key

Dataset is very large > 5 TB

Dataset is highly non-relational or schema-less constructs

Application is data intensive ( ingestion of thousands of recodes/Sec)

Page 20: SCALING ON AWS – FROM MVP TO 100 MILLION USERS by: Muhammad Umair Cloudifie: Cloud for Start-ups @cloudifie.

EC2-RDS Architecture

Everything in NOT same basket More Secure Highly Scalable Easily Manageable (Managed

DB)

But still No redundancy No failover

www.cloudifie.com

Page 21: SCALING ON AWS – FROM MVP TO 100 MILLION USERS by: Muhammad Umair Cloudifie: Cloud for Start-ups @cloudifie.

Amazon Elastic Load Balancer

Allows seamless Horizontal Scaling by distributing load evenly

Cross-zone load balancing Automatic health checks for

failover Session stickiness: Routes

request to same instance Publish usage matrices to

CloudWatch

Page 22: SCALING ON AWS – FROM MVP TO 100 MILLION USERS by: Muhammad Umair Cloudifie: Cloud for Start-ups @cloudifie.

Add Redundancy

Use Amazon Elastic Load Balancer

Address Failover by adding infrastructure Redundancy

Ensure Multi-AZ redundancy for High Availability

User > 1000

cloudifie.com

Page 23: SCALING ON AWS – FROM MVP TO 100 MILLION USERS by: Muhammad Umair Cloudifie: Cloud for Start-ups @cloudifie.

Need More Capacity?

Scale Horizontally or Scaling Out Increase capacity by adding more resources

Add more Servers in each AZ

Increase count of database instances

Page 24: SCALING ON AWS – FROM MVP TO 100 MILLION USERS by: Muhammad Umair Cloudifie: Cloud for Start-ups @cloudifie.

100k+ Users

cloudifie.com

Page 25: SCALING ON AWS – FROM MVP TO 100 MILLION USERS by: Muhammad Umair Cloudifie: Cloud for Start-ups @cloudifie.

Amazon Auto Scaling

Allows to scale EC2 fleet automatically

Save time & effort through Automation Define scaling up & down policies

Optimize cost by on demand scaling

Page 26: SCALING ON AWS – FROM MVP TO 100 MILLION USERS by: Muhammad Umair Cloudifie: Cloud for Start-ups @cloudifie.

Where we are now

Cross zones failover load balancing High availability Capacity to serve 100k+ users Layered structure Auto-scaling

Page 27: SCALING ON AWS – FROM MVP TO 100 MILLION USERS by: Muhammad Umair Cloudifie: Cloud for Start-ups @cloudifie.

Revisit AWS Building Blocks

AWS offer three very important tools for web applications

1. Simple Storage Service (S3) Web services interface for storage & retrieval Best for static contents like images, css, js etc.

2. ElasticCache Very fast, highly scalable and fully managed Memchached & Redis

3. CloudFront AWS CDN for static & dynamic content caching and delivery through edge locations

Page 28: SCALING ON AWS – FROM MVP TO 100 MILLION USERS by: Muhammad Umair Cloudifie: Cloud for Start-ups @cloudifie.

Let’s Refine Architecture

Refine application architecture Reduce load on web servers by shifting it

to other managed services Move 3-Teirs: Web, App & DB

Store static contents on S3 Reduce load from Database by caching

frequent queries to AWS ElasticCache Use CloudFront for the distribution of

Static & Dynamic content delivery from edges.

Page 29: SCALING ON AWS – FROM MVP TO 100 MILLION USERS by: Muhammad Umair Cloudifie: Cloud for Start-ups @cloudifie.
Page 30: SCALING ON AWS – FROM MVP TO 100 MILLION USERS by: Muhammad Umair Cloudifie: Cloud for Start-ups @cloudifie.

You are good to go for

500K+ Users

Page 31: SCALING ON AWS – FROM MVP TO 100 MILLION USERS by: Muhammad Umair Cloudifie: Cloud for Start-ups @cloudifie.

But with this COMPLEXITY

You would start to run into issues with speed, performance and infrastructure management.

Solution:

Ensure Monitoring, Analysis & Optimization

Use AWS Application Management Services

Page 32: SCALING ON AWS – FROM MVP TO 100 MILLION USERS by: Muhammad Umair Cloudifie: Cloud for Start-ups @cloudifie.

AWS Deployment & Management Services

Convenience Control

Abstract high level services More automation granularity

Page 33: SCALING ON AWS – FROM MVP TO 100 MILLION USERS by: Muhammad Umair Cloudifie: Cloud for Start-ups @cloudifie.

Divide & Rule

Service Oriented Architecture (SOA)

Move services into their own tiers/modules.

Treat each of these as separate pieces of infrastructure & SCALE them

independently.

Page 34: SCALING ON AWS – FROM MVP TO 100 MILLION USERS by: Muhammad Umair Cloudifie: Cloud for Start-ups @cloudifie.

Loose coupling sets you free

Looser the components are coupled, the bigger they SCALE

Independent components & black box design Decouple interactions User tested services with built-in redundancy & scaling

Controller A

Controller B

Tightly Coupled

Controller A Controller BQQLoosely Coupled

Page 35: SCALING ON AWS – FROM MVP TO 100 MILLION USERS by: Muhammad Umair Cloudifie: Cloud for Start-ups @cloudifie.

AWS Services

Amazon CloudSearch Amazon

SESAmazon SQS

Elastic Transcoder

Amazon SWFAmazon SNS

Page 36: SCALING ON AWS – FROM MVP TO 100 MILLION USERS by: Muhammad Umair Cloudifie: Cloud for Start-ups @cloudifie.

Next Big Move

SOA + Loose Coupling = Win WinShift functionality to NoSQL

Page 37: SCALING ON AWS – FROM MVP TO 100 MILLION USERS by: Muhammad Umair Cloudifie: Cloud for Start-ups @cloudifie.

Amazon SES

Amazon SQS

Amazon SNS

DynamoDB

Amazon CloudSearch

Page 38: SCALING ON AWS – FROM MVP TO 100 MILLION USERS by: Muhammad Umair Cloudifie: Cloud for Start-ups @cloudifie.

We are good to go for

Million+ Users

Page 39: SCALING ON AWS – FROM MVP TO 100 MILLION USERS by: Muhammad Umair Cloudifie: Cloud for Start-ups @cloudifie.

5-10 Million Users

Use Federation & Sharding for database Scaling

Federation: Splitting into multiple DBs based on functionality like Users DB, Products DB etc.

Sharding: Splitting one dataset across multiple hosts

User Shard ID

1234 A

1235 B

1236 C

1237 D

Page 40: SCALING ON AWS – FROM MVP TO 100 MILLION USERS by: Muhammad Umair Cloudifie: Cloud for Start-ups @cloudifie.

10-100 Million Users

Application Fine Tuning

More decoupling & SoA

Scale out from Multi-AZ to Multi-Regions

Build custom solutions

Page 41: SCALING ON AWS – FROM MVP TO 100 MILLION USERS by: Muhammad Umair Cloudifie: Cloud for Start-ups @cloudifie.

Thank You

so very much