CLOUD COMPUTING &LAMP APPLICATIONS                Gabriele Mittica   www.gabrielemittica.com - @gabrielemittica           ...
LAMP & Scalability•   Applications deployed on LAMP platforms are not usually designed to be scalable                     ...
Common scalability
HOW TO SCALE?
Scalability and High Availability
Static filesWe can’t host static files (uploads,            The goal is make our web instancesimages, css…) on the web ins...
Cache and sessionsWe need a dedicate service where host     •   session.save_handler =cache and sessions, in order to make...
Database scalability•   Multi A-Z                            •   Master / Slave (Read Replica)When you provision a Multi-A...
Database scalability• MySQL native driver?  •   Available from PHP >=5.3  •   Compile PHP with mysqlnd support      • --wi...
Database scalability{                                         The simple JSON configuration is divided in two main    "mya...
Load balancing•   ELB – Elastic Load Balancer    •    Distributed load balancer on AWS regions (eu-                 When a...
Load balancing•   If you ran 10 servers execute    commands could be hard. You    can use tools to run command    on a ser...
jMeter              App  instances          instances  1 billion of monthly pageviewsAverage 400 concurrent connections   ...
before   after
More code onhttp://www.slideshare.net/corleycloud/corley-scalability-19163383
THANKYOUhttp://www.corley.it
Cloud computing & lamp applications
Cloud computing & lamp applications
Cloud computing & lamp applications
Cloud computing & lamp applications
Cloud computing & lamp applications
Upcoming SlideShare
Loading in...5
×

Cloud computing & lamp applications

1,839

Published on

How to scale with AWS web applications based on LAMP.

Published in: Technology, Business
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,839
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
27
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Cloud computing & lamp applications

  1. 1. CLOUD COMPUTING &LAMP APPLICATIONS Gabriele Mittica www.gabrielemittica.com - @gabrielemittica Corley srl - www.corley.it Cloud Conference 2013
  2. 2. LAMP & Scalability• Applications deployed on LAMP platforms are not usually designed to be scalable Disk Access MySQL Network Traffic
  3. 3. Common scalability
  4. 4. HOW TO SCALE?
  5. 5. Scalability and High Availability
  6. 6. Static filesWe can’t host static files (uploads, The goal is make our web instancesimages, css…) on the web instance full dedicated to host the logic of the application, with no relationships to static files.• Move static files to a dedicated service like S3• S3 is a scalable service that grants the 99,999999999% of file durability With AWS, you can upload files from your instances to a S3 bucket with AWS• We can use a CDN and create several SDK for php subdomains as media.mywebsite.tld, (http://aws.amazon.com/sdkforphp/) upload.mywebsite.tld, etc.
  7. 7. Cache and sessionsWe need a dedicate service where host • session.save_handler =cache and sessions, in order to make memcachethem always • session.save_path =• Use an hosted cache system (as "tcp://1.cache.group.doma Memcache) instead of local ones (as in.tld:11211" APC)• PHP has a native handler to use manage sessions with Memcache• We can use a Elasicache or DynamoDB to host both cache and sessions
  8. 8. Database scalability• Multi A-Z • Master / Slave (Read Replica)When you provision a Multi-AZ DB The master database is regarded as theInstance, Amazon RDS automatically authoritative source, and the slavecreates a primary DB instance and databases are synchronized to it.synchronously replicates the data to astandby instance in a different Use the master instance to write andAvailability Zone (AZ). slave ones to read data.+ easy to manage + easy to scale- pay double - hard to manage
  9. 9. Database scalability• MySQL native driver? • Available from PHP >=5.3 • Compile PHP with mysqlnd support • --with-mysqli=mysqlnd --with-pdo=mysqlnd --with-mysql=mysqlnd • WARN mysql extension is deprecated as of PHP 5.5.0• Delegate to “mysqlnd_ms” the master/slave management • http://www.php.net/manual/en/book.mysqlnd-ms.php
  10. 10. Database scalability{ The simple JSON configuration is divided in two main "myapp": { "master": { section "master_0": { "host": "localhost", • Master "port": "3306" } • Slaves }, "slave": { "slave_0": { “myapp” is the hostname that we use instead the real "host": "192.168.2.27", mysql host address. "port": "3306" } } Eg. } • mysql_connect(“myapp”, “user”, “passwd”);} • new Mysqli(“myapp”, “user”, “passwd”); • new PDO(“mysql:dbname=testdb;host=myapp”);
  11. 11. Load balancing• ELB – Elastic Load Balancer • Distributed load balancer on AWS regions (eu- When a server starts, it has to create a valid west-1, 2, 3 you have to select in how many region environment in order to provides web pages. you are available) Strategies? Compile and bundle all softwares in one instance • Watch EC2 status thanks to a ping strategy image • Page check every x minutes/seconds • all software becomes old very quickly and • Turn on/off EC2 instances automatically thanks to when you have to release an update you alarms (CloudWatch raise alarms) have to compile a new image and update - It • Receive Alarms from CloudWatch and engage scale is a long and complex operation operations • You can raise CPU alarms, Network Alarms, VM status Use EC2_USER_DATA feature provided by AWS alarms and many others in order to increase or decrease • You can run a shell script when your the actual number of EC2 instances bootstraps. It is more flexible • Scale strategy is not simple and you have to because you can create a skeleton (PHP + understand how your application works libraries) and download all software runtime • CPU is the simplest way but remember that the during the boot operation bandwidth is limited by network interfaces and bottlenecks can obfuscate the CPU alarm and your application stucks in weird and strange situations.
  12. 12. Load balancing• If you ran 10 servers execute commands could be hard. You can use tools to run command on a server list • Capistrano (Ruby) https://github.com/capistrano/capistra no • Fabric (Python) https://github.com/fabric/fabric Use CLOTH for AWS EC2 instanceshttps://github.com/garethr/cloth
  13. 13. jMeter App instances instances 1 billion of monthly pageviewsAverage 400 concurrent connections 60 $ on the cloud
  14. 14. before after
  15. 15. More code onhttp://www.slideshare.net/corleycloud/corley-scalability-19163383
  16. 16. THANKYOUhttp://www.corley.it
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×