Cloud computing gives you a number of advantages, such as the ability to scale your web application or website on demand. If you have a new web application and want to use cloud computing, you might be asking yourself, "Where do I start?" Join us in this session to understand best practices for scaling your resources from zero to millions of users. We show you how to best combine different AWS services, how to make smarter decisions for architecting your application, and how to scale your infrastructure in the cloud.
12. US-WEST (Oregon)
EU (Ireland)
ASIA PACIFIC
(Tokyo)
US-WEST (N. California)
SOUTH
AMERICA (Sao
Paulo)
US-EAST (N. Virginia)
AWS GOVCLOUD (US)
ASIA PACIFIC
(Sydney)
ASIA PACIFIC
(Singapore)
CHINA (Beijing)
Regions
EU (Frankfurt)
INDIA (2016)
13. US-WEST (Oregon)
EU (Ireland)
ASIA PACIFIC
(Tokyo)
US-WEST (N. California)
SOUTH
AMERICA (Sao
Paulo)
US-EAST (N. Virginia)
AWS GOVCLOUD (US)
ASIA PACIFIC
(Sydney)
ASIA PACIFIC
(Singapore)
CHINA (Beijing)
Availability Zones
EU (Frankfurt)
INDIA (2016)
23. 1 User
• Amazon Route 53 for DNS
• A single Elastic IP
• A single Amazon EC2 instance
• With full stack on this host
• Web app
• Database
• Management
• And so on…
Amazon
EC2
instance
Elastic IP
User
Amazon
Route 53
24. “We’re gonna need a bigger box”
• Simplest approach
• Can now leverage PIOPS
• High I/O instances
• High memory instances
• High CPU instances
• High storage instances
• Easy to change instance sizes
• Will hit an endpoint eventually
c4.8xlarge
m3.2xlarge
t2.micro
25. “We’re gonna need a bigger box”
• Simplest approach
• Can now leverage PIOPS
• High I/O instances
• High memory instances
• High CPU instances
• High storage instances
• Easy to change instance sizes
• Will hit an endpoint eventually
c4.8xlarge
m3.2xlarge
t2.micro
26. 1 User
• We could potentially get
to a few hundred to a few
thousand depending on
application complexity
and traffic
• No failover
• No redundancy
• Too many eggs in one
basket
EC2
Instance
Elastic IP
User
Amazon
Route 53
27. 1 User
• We could potentially get
to a few hundred to a few
thousand depending on
application complexity
and traffic
• No failover
• No redundancy
• Too many eggs in one
basket
EC2
Instance
Elastic IP
User
Amazon
Route 53
29. Users > 1
First, let’s separate out our
single host into more than one.
• Web
• Database
Make use of a database
service?
Web
Instance
Database
Instance
Elastic IP
User
Amazon
Route 53
30. Self-managed Fully managed
Database server
on Amazon EC2
Your choice of
database running on
Amazon EC2
Bring Your Own
License (BYOL)
Amazon
DynamoDB
Managed NoSQL
database service
using SSD storage
Seamless scalability
Zero administration
Amazon RDS
Microsoft SQL Server
Oracle
MySQL
PostgreSQL
MariaDB
Amazon Aurora
BYOL or license
Included
Amazon
Redshift
Massively parallel,
petabyte-scale data
warehouse service
Fast, powerful, and
easy to scale
Database options
31. Self-managed Fully managed
Database server
on Amazon EC2
Your choice of
database running on
Amazon EC2
Bring Your Own
License (BYOL)
Amazon
DynamoDB
Managed NoSQL
database service
using SSD storage
Seamless scalability
Zero administration
Amazon RDS
Microsoft SQL Server
Oracle
MySQL
PostgreSQL
MariaDB
Amazon Aurora
BYOL or license
Included
Amazon
Redshift
Massively parallel,
petabyte-scale data
warehouse service
Fast, powerful, and
easy to scale
Database options
32. Amazon Aurora
• Automatic storage scaling (up to 64 TB)
• Up to 15 read-replicas
• Continuous (incremental) backups to
Amazon S3
• 6-way replication across 3 AZs
• MySQL Compatible
36. Why start with SQL?
• Established and well-worn technology.
• Lots of existing code, communities, books, and tools.
• You aren’t going to break SQL DBs in your first 10 million
users. No, really, you won’t.*
• Clear patterns to scalability.
*Unless you are doing something SUPER peculiar with the data or you have MASSIVE amounts of it.
…but even then SQL will have a place in your stack.
37. AH HA! You said
“massive
amounts,” and I
will have massive
amounts!
38. > 5 TB in year one?
Incredibly data intensive workload?
OK!
You might need NoSQL.
39. Why else might you need NoSQL?
• Super low-latency applications
• Metadata-driven datasets
• Highly nonrelational data
• Need schema-less data constructs*
• Massive amounts of data (again, in the TB range)
• Rapid ingest of data (thousands of records/sec)
*Need!= “It’s easier to do dev without schemas”
41. Users >100
First, let’s separate out our
single host into more than one:
• Web
• Database
Use Amazon RDS to make
your life easier
Web
instance
Elastic IP
RDS DB
instance
User
Amazon
Route 53
43. Users >1000
Next, let’s address our lack of
failover and redundancy issues:
Another web instance
• In another Availability Zone
RDS Multi-AZ
Elastic Load Balancing (ELB)
Web
Instance
RDS DB Instance
Active (Multi-AZ)
Availability Zone Availability Zone
Web
Instance
RDS DB Instance
Standby (Multi-AZ)
ELB
Balancer
User
Amazon
Route 53
47. Users > 10,000s–100,000s
RDS DB Instance
Active (Multi-AZ)
Availability Zone Availability Zone
RDS DB Instance
Standby (Multi-AZ)
ELB
Balancer
RDS DB Instance
Read Replica
RDS DB Instance
Read Replica
RDS DB Instance
Read Replica
RDS DB Instance
Read Replica
Web
Instance
Web
Instance
Web
Instance
Web
Instance
Web
Instance
Web
Instance
Web
Instance
Web
Instance
Amazon
Route 53User
50. RDS DB Instance
Active (Multi-AZ)
Availability Zone
ELB
Balancer
Amazon S3
Amazon
CloudFront
Amazon
Route 53
User
Shift some load around
Web Instances
• static content to Amazon S3
and Amazon CloudFront
Move…
51. Amazon Simple Storage Service (S3)
• Object-based storage
• Highly durable
• Great for static assets
• “Infinitely scalable”
• Objects up to 5 TB in size
• Optional encryption
52. Amazon CloudFront
• Cache content for faster delivery
• Lower load on origin
• Dynamic and static content
• Streaming video
• Custom SSL certificates
• Low TTLs (as short as 0 seconds)
• Free origin fetches?
• Optimized for AWS
54. Shift some load around
• static content to Amazon S3 and
Amazon CloudFront
Move…
• session/state to Amazon
DynamoDB
• DB caching to Amazon
ElastiCache RDS DB Instance
Active (Multi-AZ)
Availability Zone
ELB
Balancer
Amazon S3
Amazon
CloudFront
Amazon
Route 53
User
ElastiCache DynamoDB
Web Instances
55. Amazon DynamoDB
• Managed NoSQL database
• Provisioned throughput
• Fast, predictable performance
• Fully distributed, fault tolerant
• JSON support
• Items up to 400 KB
56. Amazon Elasticache
• Managed Memcached or Redis
• Scale from one to many nodes
• Self-healing (replaces dead instance)
• Single digit ms speeds (usually)
• Local to a single AZ for Memcache
• Multi-AZ possible with Redis
57. Shift some load around
Move…
• static content to Amazon S3
and Amazon CloudFront
• session/state to Amazon
DynamoDB
• DB caching to Amazon
ElastiCache
• dynamic content to Amazon
CloudFront
RDS DB Instance
Active (Multi-AZ)
Availability Zone
ELB
Balancer
Amazon S3
Amazon
CloudFrontUser
ElastiCache DynamoDB
Web Instances
Amazon
Route 53
58. Now that our web tier is
much more lightweight, we
can revisit the beginning
of our talk…
70. Users > 500,000+
Availability Zone
Amazon
Route 53
User
Amazon S3
Amazon
CloudFront
Availability Zone
ELB
Balancer
DynamoDB
RDS DB Instance
Read Replica
Web
Instance
Web
Instance
Web
Instance
ElastiCache RDS DB Instance
Read Replica
Web
Instance
Web
Instance
Web
Instance
ElastiCacheRDS DB Instance
Standby (Multi-AZ)
RDS DB Instance
Active (Multi-AZ)
71. Users > 500,000+
Availability Zone
Amazon
Route 53
User
Amazon S3
Amazon
CloudFront
Availability Zone
ELB
Balancer
DynamoDB
RDS DB Instance
Read Replica
Web
Instance
Web
Instance
Web
Instance
ElastiCache RDS DB Instance
Read Replica
Web
Instance
Web
Instance
Web
Instance
ElastiCacheRDS DB Instance
Standby (Multi-AZ)
RDS DB Instance
Active (Multi-AZ)
73. AWS application management solutions
Convenience Control
Higher-level services Do it yourself
AWS
Elastic Beanstalk
AWS
OpsWorks
AWS
CloudFormation
Amazon EC2
74. AWS CodeDeploy
• Deploys your code to a “fleet” of EC2 instances
• 1 – 10,000s of instances
• Automatically schedules updates (multiple AZs)
• Application and Deployment groups described in
YAML-formatted files
• Can reference Auto Scaling Groups
• AWS Management Console, CLI, or APIs
• Can be used with Chef recipes or Puppet scripts
75. Users >500,000+
• Monitoring, metrics, and logging
• If you can’t build it internally,
outsource it! (third-party SaaS)
• What are customers saying?
• Try to squeeze as much performance
out of each service/component
80. Now that’s a lot
of things to read!
This is NOT
where we
want to start!
81. This is NOT
where we
want to start!
This IS where
we want to start!
Now that’s a lot
of things to read!
82. SOAing
Move services into their own tiers.
• Treat them separately and scale
them independently.
Amazon and AWS do this extensively!
It offers flexibility and greater
understanding of each component
86. Loose coupling sets you free!
The looser they're coupled, the bigger they scale
• Independent components
• Design everything as a black box
• Decouple interactions
• Favor services with built-in redundancy and scalability rather than
building your own
S3 Bucket
Lambda
Push: Event
Notification
DynamoDB
Pull: DynamoDB
Stream
Amazon
Kinesis
Pull:
DynamoDB Stream
SQS
messages
Get
Message
Instance
Put
Message
Instance
Amazon SNS Topic
Publish
Notification
Queue Is Subscribed
to Topic
88. Users >1 million+
Reaching a million and above is going to require some bit
of all the previous things:
• Multi-AZ
• Elastic Load Balancing between tiers
• Auto Scaling
• Service Oriented Architecture
• Serving content smartly (Amazon S3/CloudFront )
• Caching off DB
• Moving state off tiers that auto scale
89. Users >1 million+
RDS DB Instance
Active (Multi-AZ)
Availability Zone
ELB
Balancer
RDS DB Instance
Read Replica
RDS DB Instance
Read Replica
Web
Instance
Web
Instance
Web
Instance
Web
Instance
Amazon
Route 53
User
Amazon S3
Amazon
CloudFront
DynamoDB
Amazon SQS
ElastiCache
Worker
Instance
Worker
Instance
Amazon
CloudWatch
Internal App
Instance
Internal App
Instance Amazon SES
Lambda
92. Users >5 million - 10 million
You’ll potentially start to run into issues with your database
around contention on the write master.
How can you solve it?
• Federation—splitting into multiple DBs based on function
• Sharding—splitting one dataset up across multiple hosts
• Moving some functionality to other types of DBs (NoSQL, Graph)
93. Database federation
• Split up databases by function/purpose
• Harder to do cross-function queries
• Essentially delays sharding/NoSQL
• Won’t help with single huge functions/tables
Forums DB
Users DB
Products
DB
94. Sharded horizontal scaling
• More complex at the application layer
• No practical limit on scalability
• Operation complexity/sophistication
• Shard by function or key space
• RDBMS or NoSQL
User ShardID
002345 A
002346 B
002347 C
002348 B
002349 A
CBA
95. Shifting functionality to NoSQL
• Similar in a sense to federation
• Again, think about the earlier points for when you
need NoSQL vs. SQL
• Leverage managed services like DynamoDB
Some use cases:
• Leaderboards/scoring
• Rapid ingest of clickstream/log data
• Temporary data needs (cart data)
• “Hot” tables
• Metadata/lookup tablesDynamoDB
97. A quick review
• Multi-AZ your infrastructure.
• Make use of self-scaling services—ELB, Amazon S3,
Amazon SNS, Amazon SQS, Amazon SWF, Amazon SES, and
more.
• Build in redundancy at every level.
• Start with SQL. Seriously.
• Cache data both inside and outside your infrastructure.
• Use automation tools in your infrastructure.
98. A quick review continued
• Make sure you have good metrics/monitoring/logging
tools in place
• Split tiers into individual services (SOA)
• Use Auto Scaling once you’re ready for it
• Don’t reinvent the wheel
• Move to NoSQL if and when it makes sense
99. Putting all this together
means we should now
easily be able to handle
11+ million users!
102. • More fine-tuning of your application
• More SOA of features/functionality
• Going from Multi-AZ to multi-region
• Possibly start to build custom solutions
• Deep analysis of your entire stack
User >11 million
107. Related Sessions
DVO303 - Scaling Infrastructure Operations with AWS Service Catalog,
AWS Config, and AWS CloudTrail
Friday, Oct 9, 9:00 AM - 10:00 AM – Lido 3001B
DVO201 - Scaling Your Web Applications with AWS Elastic Beanstalk
Friday, Oct 9, 9:00 AM - 10:00 AM – Titan 2306
CMP201 - All You Need To Know About Auto Scaling
Friday, Oct 9, 10:15 AM - 11:15 AM – San Polo 3506