• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Scaling a Web Application in the Cloud
 

Scaling a Web Application in the Cloud

on

  • 1,471 views

 

Statistics

Views

Total Views
1,471
Views on SlideShare
1,449
Embed Views
22

Actions

Likes
5
Downloads
0
Comments
0

3 Embeds 22

http://www.imolug.org 20
http://a0.twimg.com 1
http://backup.imolug.org 1

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n

Scaling a Web Application in the Cloud Scaling a Web Application in the Cloud Presentation Transcript

  • Scalinga Web Application in the Cloud
  • Scalinga Web Application in the Cloud
  • ScalabilityAbility to either handle growing amounts ofwork in a graceful manner, or to be readilyenlarged as demands increase. John Engates, RackspaceScalability is about:• Traffic growth• Dataset growth
  • Scalability and performance are not the same
  • PerformanceHow much time is needed to accomplish a task.Performance is about:• Raw Speed (2 Ghz vs. 3 Ghz)• Programming language (C vs. Java)• Network bandwidth• etc ...
  • Scalability is the key to grow
  • Performance in the real world
  • Scalabilityin the real world
  • Scalinga Web Application in the Cloud
  • Why the Cloud? Scale for real
  • Why the Cloud? Scale for realNo hardware Low cost (if you’re small) issues
  • AWS Infrastructure
  • AWS Regions EU West AP JapanUS West US East AP Sing. A region is a set of multiple Data Centers
  • AWS Availability Zones EU West 1 2 AP JapanUS West US East 3 1 2 1 2 1 2 AP Sing. 3 3 4 1 2 Distinct locations, insulated from failure Low latency connectivity within same region
  • EC2 - Elastic Cloud ComputingElastic and Flexible way to launch Instances ofvirtual machines.
  • EC2 - Elastic Cloud ComputingElastic and Flexible way to launch Instances ofvirtual machines. Turn on new instances in few minutes
  • EC2 - Elastic Cloud ComputingElastic and Flexible way to launch Instances ofvirtual machines. Multiple instance types
  • EC2 Instance Types Small Medium (Hi CPU) LargeCPU (EC2 units) 1 5 4 RAM 1.7 GB 1.7 GB 7.5 GB Disk 160 GB 350 GB 850 GB Network 250 Mb/s 350 Mb/s 500 Mb/s Arch 32 bit 32 bit 64 bit Cost $0.085 / hour $0.17 / hour $0.34 / hour
  • Storage in the CloudInstance Local Storage:• Dies with the instance (low durability)EBS - Elastic Block Storage:• Persistent storage• Remote volume attached to instance• Reliable
  • Storage in the CloudS3 - Simple Storage Service:• Simple key/value storage• HTTP interface• Designed for durability and scalability 99.999999999% ($0.140 / GB / month) 99.99% ($0.093 / GB / month)
  • More AWS services ELB Elastic Load Balancer FPS SQS Payment Service Queue ServiceCloudFront CDN SNS Notifications Route 53 DNS and many more ...
  • Scalinga Web Application in the Cloud
  • Design for scaling It wont scaleif its not designed to scale.
  • Scalingthe Web Server
  • Easy Add another web serverand balance between them
  • Scaling the web server spreaker.com 46.137.165.48 Load BalancerWeb Server 1 ... Web Server N
  • Scaling the web serverElastic Load Balancer:• Supports http, https, tcp, ssl• Balance traffic across Availability Zones (same region)• Performes health checks on balanced instances• Scalable / High-Available• Low cost ($0.01 per GB in/out)
  • Scaling the web server spreaker.com 46.137.165.48 ELB Web Server 1 ... Web Server NAZ 1 AZ 2 EC2 Region
  • SessionsA session keeps a state between subsequentHTTP requests.
  • SessionsA session keeps a state between subsequentHTTP requests.Local sessions:• Stored on local disk / memory• No scalable• No fault tollerant• Load balancer with sticky sessions is a (bad) solution
  • SessionsCentralized sessions:• Stored on database, memcached, redis, ...• Scalable• Fault tollerant if the storage is distributed
  • SessionsCentralized sessions:• Stored on database, memcached, redis, ...• Scalable• Fault tollerant if the storage is distributedNo server-side sessions:• Save everything in a cookie and sign it for safety• More scalable
  • Scalingthe File Storage
  • Get a BIG disk
  • Get a BIGGER disk
  • Get a ... doh!
  • Scaling the storageIn a typical web application, time is spent:• 20% getting dynamic content (html)• 80% getting static content (images, js, css, swf, ...)
  • Scaling the storageIn a typical web application, time is spent:• 20% getting dynamic content (html)• 80% getting static content (images, js, css, swf, ...)In other words:• Keep dynamic data closer to EC2 (ex. database)• Keep static data closer to end-user
  • Scaling the static contentsMove your static content to S3 and distribute itvia CloudFront (CDN)
  • Scaling the static contentsMove your static content to S3 and distribute itvia CloudFront (CDN)Lifetime caching:• Set Cache-Control and Expires headers
  • Scaling the static contentsMove your static content to S3 and distribute itvia CloudFront (CDN)Lifetime caching:• Set Cache-Control and Expires headersVersioning:• You can’t invalidate clients and proxies cache• Add version numer to files (can be easily automatized)• ex. /js/v1/code.js or /js/code.js?v=r or ...
  • Scalingthe Database
  • Scaling the DatabaseNo database Nothing to scale
  • Scaling the DatabaseNo database Nothing to scaleNo SQL database MongoDB, CouchDB, Cassandra, ...• No SQL queries / Less expressive way to query• Designed to Scale• Designed to be High-Available
  • Scaling the DatabaseNo database Nothing to scale Move here as much data as you canNo SQL database MongoDB, CouchDB, Cassandra, ...• No SQL queries / Less expressive way to query• Designed to Scale• Designed to be High-Available
  • Scalinga Relation Database is Tricky
  • Scaling the SQL Database spreaker.com ELB Web Server 1 ... Web Server NReads ReadsWrites Writes Database EC2 Region
  • Scaling the SQL Database spreaker.com ELB Web Server 1 ... Web Server N Reads Writes Slave Master Database Database EC2 Region
  • Scaling the SQL Database spreaker.com ELB Web Server 1 ... Web Server N Reads Writes Slave Master Database Database EC2 Region
  • Scaling the SQL DatabaseMaster-Slave replication Scale reads but not writes
  • Scaling the SQL DatabaseMaster-Slave replication Scale reads but not writesAWS Relational Database Service (RDS):• Pre-configured instances of MySQL / Oracle• Multi-AZ master-slave replication
  • Scaling the SQL DatabaseMaster-Slave replication Scale reads but not writesAWS Relational Database Service (RDS):• Pre-configured instances of MySQL / Oracle• Multi-AZ master-slave replicationPostgreSQL and others:• Do replication by yourself• Data on RAID 0 over EBS• DRDB, PostgreSQL 9 Stream Replication, ...
  • Scaling the SQL Database Master Scaling writes / master Database Not that easyCommon approches:• Add more hardware (vertical scaling)• Master-Master replication• Sharding / Partitioning
  • ScalingHeavy Tasks
  • Example: audio encoding SequentialUpload Encode Publish
  • DecoupleDesign an asynchronous system:• Resource consuming operations can be done asynch• Users get a more responsive feedback• Easy to scale
  • DecoupleDesign an asynchronous system:• Resource consuming operations can be done asynch• Users get a more responsive feedback• Easy to scalePut job in a queue and run a worker that get themessage from queue and process itYou can use SQS, RabbitMQ, ...
  • Example: audio encoding AsynchronousUpload Store Encode Publish M M Queue Queue
  • Example: audio encoding Easier to scale !Upload Store Encode Publish M M Queue Queue
  • ElasticScaling
  • Design an infrastructure able to Auto Scaling
  • Design an infrastructure able to Auto ScalingScale up to handle growing traffic
  • Design an infrastructure able to Auto ScalingScale up to handle growing traffic Scale down to reduce costs
  • Design an infrastructure able to Auto Scaling Do it automaticallyScale up to handle (ex. CloudWatch) growing traffic Scale down to reduce costs
  • We do itTens Times / Day
  • Last but not the lest Design For Failure
  • Assume everything will fail(it’s just a matter of time)
  • Few HintsHigh-Availability:• No single point of Failures• Deploy redundant services• Deploy on multi-AZ (and multi-Region if possible)• Automatize as much as possibile• Warm Stand-by database cross-AZ
  • Few HintsHigh-Availability:• No single point of Failures• Deploy redundant services• Deploy on multi-AZ (and multi-Region if possible)• Automatize as much as possibile• Warm Stand-by database cross-AZDisaster Recovery:• Backup / Restore your data• Warm Stand-by database cross-Region
  • That’s not all but enough for today ;)