Share
Embed
Scaling Up to Your First 10 Million Users
Re-delivered from re:Invent 2019 session Scaling Up to Your First 10 Million Users. This session I shared about how do you start your application using AWS, how to combine AWS services, best practices in choosing the right architecture.
Original AWS re:Invent Presentation can be watched here.
https://www.youtube.com/watch?v=kKjm4ehYiMs
Petra Novandi Barus
June 08, 2020
Transcript
91 slides
-
© 2020, Amazon Web Services, Inc. or its Affiliates. Scaling
Up to Your First 10 Million Users Petra Novandi Barus Senior Developer Advocate, Indonesia -
© 2020, Amazon Web Services, Inc. or its Affiliates. It’snot
the single thing that fixes everything -
What do we need first? © 2019, Amazon Web Services,
Inc. or its affiliates. All rightsreserved. -
Amazon global edgenetwork © 2019, Amazon Web Services, Inc. or
its affiliates. All rights reserved. 24 region 76 availability zones 210+ points of presence -
Robust, fully featured technology infrastructure © 2019, Amazon Web Services,
Inc. or its affiliates. All rightsreserved. -
AWS building blocks Amazon CloudFront Amazon Route 53 Amazon S3
Amazon DynamoDB AWS Lambda Amazon SQS Amazon SNS Amazon SES Elastic Load Balancing AWS Step Functions Amazon EFS . . . Highly scalable, available with the right architecture Amazon EC2 Amazon EBS Amazon RDS Amazon VPC © 2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved. -
Considerations? © 2019, Amazon Web Services, Inc. or its affiliates.
All rightsreserved. -
Build Measure Learn © 2019, Amazon Web Services, Inc. or
its affiliates. All rightsreserved. -
Identify and avoid undifferentiated heavy lifting Guiding Tenets © 2019,
Amazon Web Services, Inc. or its affiliates. All rightsreserved. Serverless vs managed vs run it yourself Security first -
So let’s start fromday . . © 2019, Amazon Web
Services, Inc. or its affiliates. All rights reserved. -
You User © 2019, Amazon Web Services, Inc. or its
affiliates. All rightsreserved. -
One user VPC User Elastic IP address © 2019, Amazon
Web Services, Inc. or its affiliates. All rights reserved. Instance -
• Choose multiple plans that include bundled compute, storage, and
networking • Benefit from low and predictable price • Spin up fully configured server in seconds • Manage from intuitive Lightsail console • Scale with access to AWS services • Automate with Lightsail API & AWS Command Line Amazon Lightsail: Easiest way to get started on AWS © 2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved. -
Users >1 © 2019, Amazon Web Services, Inc. or its
affiliates. All rightsreserved. -
Database instance VPC Users >1 User Elastic IP address ©
2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved. Amazon EC2 instance -
Database options Fully managed Self-managed Amazon RDS © 2019, Amazon
Web Services, Inc. or its affiliates. All rightsreserved. Amazon Redshift Amazon DynamoDB Amazon EC2 -
Amazon Aurora © 2019, Amazon Web Services, Inc. or its
affiliates. All rightsreserved. • MySQL or PostgreSQL compatible • Automatic storage scaling (up to 64 TB) • Up to 15 read replicas • Continuous (incremental) backups to Amazon S3 • Six-way replications across three zones • Serverless options Amazon Aurora -
Start with SQL databases © 2019, Amazon Web Services, Inc.
or its affiliates. All rightsreserved. -
Why start withSQL? © 2019, Amazon Web Services, Inc. or
its affiliates. All rightsreserved. • Established and well-known technology • Lots of existing code, communities, books, and tools • You aren’t going to break SQL DBs in your first millions of 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 yourstack -
> 5 TB in year one? © 2019, Amazon Web
Services, Inc. or its affiliates. All rightsreserved. Incredibly data intensiveworkload? OK! You might needNoSQL -
Why else might you need NoSQL? © 2019, Amazon Web
Services, Inc. or its affiliates. All rightsreserved. • Super low-latency applications • Metadata-driven datasets • Highly nonrelational data • Need schema-less data constructs* • Rapid ingest of data (thousands of records/sec) • Massive amounts of data (again, in the TB range) • *Need!= “It’s easier to do dev without schemas” -
Users >100 © 2019, Amazon Web Services, Inc. or its
affiliates. All rightsreserved. -
VPC Amazon RDS instance Users >100 User © 2019, Amazon
Web Services, Inc. or its affiliates. All rightsreserved. Elastic IP address Amazon EC2 instance -
Users >1000 © 2019, Amazon Web Services, Inc. or its
affiliates. All rights reserved. -
horizontally © 2019, Amazon Web Services, Inc. or its affiliates.
All rightsreserved. vertically -
• 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 t3.nano m5.2xlarge c5.9xlarge “We’re gonna need a bigger box” © 2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved. -
User VPC Users >1000 Availability zone Web instance Amazon RDS
DB instance standby (Multi-AZ) Availability zone Web instance Amazon RDS DB instance active (Multi- AZ) © 2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved. -
Sharing the load © 2019, Amazon Web Services, Inc. or
its affiliates. All rights reserved. -
Application LoadBalancer © 2019, Amazon Web Services, Inc. or its
affiliates. All rightsreserved. • Highly available • 1 - 65535 • Health checks • Session stickiness • Monitoring / logging • Content-based routing • Container-based apps • WebSockets • HTTP/2 Recommended -
Users >10,000 © 2019, Amazon Web Services, Inc. or its
affiliates. All rightsreserved. -
VPC Availability zone User Users >10,000 Amazon RDS DB instance
active (Multi-AZ) Web instance Amazon RDS DB instance standby (Multi-AZ) Availability zone Web instance Web instance Web instance Web instance Web instance © 2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved. Web instance Web instance -
VPC Availability zone User Users >10,000 Amazon RDS DB instance
active (Multi-AZ) Web instance Amazon RDS DB instance standby (Multi-AZ) Availability zone Web instance Web instance Web instance Web instance Web instance © 2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved. Web instance Web instance DB instance read replica DB instance read replica DB instance read replica DB instance read replica -
Shift some loadaround User VPC Availability zone Web instances Amazon
RDS DB instance active (Multi-AZ) Availability zone Web instances Amazon RDS DB instance standby (Multi-AZ) © 2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved. -
Amazon Simple Storage Service (Amazon S3) © 2019, Amazon Web
Services, Inc. or its affiliates. All rightsreserved. • Object-based storage • Highly durable • Great for static assets • “Infinitely scalable” • Objects up to 5 TB in size • Encryption at rest and in transit -
Amazon CloudFront © 2019, Amazon Web Services, Inc. or its
affiliates. All rightsreserved. • 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) • Optimized for AWS -
Amazon CloudFront Response Time Server Load Response Time Server Load
Response Time Server Load No CDN CDN for static content CDN for static & dynamic content 80 70 60 50 40 30 20 10 0 Volume of Data Delivered (Gbps) © 2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved. -
Shift some more loadaround Amazon RDS DB instance active (Multi-AZ)
User VPC Availability zones Web instances © 2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved. -
Amazon ElastiCache © 2019, Amazon Web Services, Inc. or its
affiliates. All rightsreserved. • 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 Memcached • Multi-AZ possible with Redis -
Shift even more load around Amazon RDS DB instance active
(Multi-AZ) User VPC Availability zones Web instances © 2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved. -
Amazon DynamoDB © 2019, Amazon Web Services, Inc. or its
affiliates. All rightsreserved. • Managed NoSQL database • Provisioned throughput • Fast, predictable performance • Fully distributed, fault tolerant • JSON support • Items up to 400 KB • Time-to-live (TTL) • Streams and triggers • AWS Application Auto Scaling • Global tables AWS Database Migration Service (AWS DMS)! -
Auto Scaling! © 2019, Amazon Web Services, Inc. or its
affiliates. All rightsreserved. -
Sunday Monday Tuesday Wednesday Thursday Friday Saturday Typical weekly traffic
to Amazon.com © 2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved. -
Sunday Monday Tuesday Wednesday Thursday Friday Saturday © 2019, Amazon
Web Services, Inc. or its affiliates. All rightsreserved. Provisioned capacity Typical weekly traffic to Amazon.com -
November © 2019, Amazon Web Services, Inc. or its affiliates.
All rightsreserved. November traffic to Amazon.com -
Provisioned capacity © 2019, Amazon Web Services, Inc. or its
affiliates. All rightsreserved. November November traffic to Amazon.com -
76% 24% November Provisioned capacity © 2019, Amazon Web Services,
Inc. or its affiliates. All rightsreserved. November traffic to Amazon.com -
© 2019, Amazon Web Services, Inc. or its affiliates. All
rightsreserved. November November traffic to Amazon.com -
Auto Scaling lets you dothis! © 2019, Amazon Web Services,
Inc. or its affiliates. All rightsreserved. -
Auto Scaling © 2019, Amazon Web Services, Inc. or its
affiliates. All rightsreserved. • Automatic resizing of compute clusters • Define min/max pool sizes • Amazon CloudWatch metrics drive scaling • On-Demand or Spot Instances -
Amazon RDS DB instance read replica Amazon RDS DB instance
read replica Amazon RDS DB instance active (Multi- AZ) Auto Scaling group Users >500,000 VPC User Web instance Amazon RDS DB instance standby (Multi-AZ) Availability zone Web instance Web instance Amazon ElastiCache Auto Scaling group Web instance Availability zone Web instance © 2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved. Web instance Amazon ElastiCache -
Use automation © 2019, Amazon Web Services, Inc. or its
affiliates. All rightsreserved. -
AWS Systems Manager: Automate Operational Tasks © 2019, Amazon Web
Services, Inc. or its affiliates. All rightsreserved. AWS Systems Manager • In the cloud and on premises • Managed remote access • Automate common tasks • Basic and advanced parameter store -
AWS infrastructure automation Convenience Control Do it yourself Higher-level services
© 2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved. AWS Cloud Development Kit -
AWS Code Services Convenience Control AWS Code Pipeline © 2019,
Amazon Web Services, Inc. or its affiliates. All rightsreserved. Develop Source Test Build Deploy Software Release Steps AWS Cloud9 AWS CodeCommit AWS CodeBuild AWS DeviceFarm AWS CodeDeploy -
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 © 2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved. -
Amazon CloudWatch © 2019, Amazon Web Services, Inc. or its
affiliates. All rightsreserved. -
There are further improvements to be made in breaking apart
our web/app layer © 2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved. -
The monolithic architecture User interface Business logic Data access ©
2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved. -
The service-oriented architecture Presentation tier © 2019, Amazon Web Services,
Inc. or its affiliates. All rightsreserved. Logic tier Data tier -
SOAing Move services into their own tiers • Treat them
separately • Scale them independently It offers flexibility and greater understanding of each component © 2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved. -
Serverless = winning Don’t reinvent the wheel • API •
Queuing • Transcoding • Search • Databases • Monitoring • Logging • Compute • Machine learning © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. -
Loose coupling – Amazon SQS and Amazon SNS • Reliable
(multi-AZ) • Scalable (unlimited messages) • Secure (queue authentication) • Simple (simple APIs) • FIFO now supported T opic Queue subscribed to topic Message Get message Put message Publish notification © 2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved. Instance Instance -
• Functions triggered by events • Node.js (JavaScript), Java, Python,
and C# • Serverless • Implicit scaling Push: event notification Pull: DynamoDB stream Pull: Amazon Kinesis stream © 2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved. Event-driven compute – AWSLambda -
Serverless Web application © 2019, Amazon Web Services, Inc. or
its affiliates. All rightsreserved. -
© 2019, Amazon Web Services, Inc. or its affiliates. All
rights reserved. -
The microservicesarchitecture © 2019, Amazon Web Services, Inc. or its
affiliates. All rightsreserved. -
The microservicesarchitecture © 2019, Amazon Web Services, Inc. or its
affiliates. All rightsreserved. -
AWS X-Ray © 2019, Amazon Web Services, Inc. or its
affiliates. All rightsreserved. • Identify performance bottlenecks and errors • Pinpoint issues to specific service(s) in your application • Identify impact of issues on users of the application • Visualize the service call graph of your application -
Visualize service call graph © 2019, Amazon Web Services, Inc.
or its affiliates. All rightsreserved. -
Visualize service callgraph © 2019, Amazon Web Services, Inc. or
its affiliates. All rightsreserved. -
Users >1,000,000 © 2019, Amazon Web Services, Inc. or its
affiliates. All rightsreserved. -
Users >1million © 2019, Amazon Web Services, Inc. or its
affiliates. All rightsreserved. 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 (SOA) • Serving content smartly (Amazon S3/CloudFront) • Caching off DB • Moving state off tiers that auto scale -
Users >1million VPC User Web Auto Scalinggroup Web Instance Web
Instance Web Instance Web Instance Amazon RDS DB Instance Read Replica Amazon RDS DB Instance Active (Multi- AZ) Amazon RDS DB Instance Read Replica Amazon ElastiCache Worker Auto Scalinggroup Worker Instance Worker Instance App Scaling group App Instance © 2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved. App Instance -
The next big steps © 2019, Amazon Web Services, Inc.
or its affiliates. All rightsreserved. -
Users >5 million–10million © 2019, Amazon Web Services, Inc. or
its affiliates. All rightsreserved. Database issues? Solutions • 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) -
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 Products DB Forums DB Users DB © 2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved. -
Sharded horizontal scaling User ShardID 002345 A 002346 B 002347
C 002348 B 002349 A C B A • More complex at the application layer • No practical limit on scalability • Operation complexity/sophistication • Shard by function or key space • RDBMS or NoSQL © 2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved. -
Shifting functionality toNoSQL • Similar in a sense to federation
• NoSQL versus 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 tables © 2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved. -
A quickreview © 2019, Amazon Web Services, Inc. or its
affiliates. All rightsreserved. -
A quickreview © 2019, Amazon Web Services, Inc. or its
affiliates. All rightsreserved. • Multi-AZ your infrastructure • Make use of self-scaling services—Application Load Balancer, Amazon S3,AWS Lambda, Amazon SNS, Amazon SQS, AWS Step Functions, and others • Build in redundancy at every level • Start with SQL. Seriously • Cache data both inside and outside your infrastructure • Use automation tools in your infrastructure -
Aquick review continued © 2019, Amazon Web Services, Inc. or
its affiliates. All rightsreserved. • Make sure you have good metrics/monitoring/logging • 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 -
10+ million users! © 2019, Amazon Web Services, Inc. or
its affiliates. All rightsreserved. -
To infinity . .. © 2019, Amazon Web Services, Inc.
or its affiliates. All rightsreserved. -
User >10million © 2019, Amazon Web Services, Inc. or its
affiliates. All rightsreserved. • More fine-tuning of your application • More SOA of features/functionality • Build serverless whenever possible • Going from multi-AZ to multi-region • Deep analysis of your entire stack -
Next steps? © 2019, Amazon Web Services, Inc. or its
affiliates. All rightsreserved. Read! aws.amazon.com/documentation aws.amazon.com/architecture aws.amazon.com/well-architected aws.amazon.com/solutions aws.amazon.com/quickstart Start using AWS aws.amazon.com/free -
Join Our User Group! © 2019, Amazon Web Services, Inc.
or its affiliates. All rightsreserved. https://t.me/AWSUserGroupID -
© 2020, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. Amazon Confidential and Trademark. Thank You! Petra Novandi Barus Senior Developer Advocate, Indonesia