SlideShare a Scribd company logo
1 of 81
Download to read offline
Scaling a Web
        Application

    (mostly PHP/MySQL
     and almost mostly
         harmless)
     Duleepa “Dups” Wijayawardhana
        MySQL Community Team
"                                         "                   !
                            !"#$%&#'()*#+(,-.$/#+*0#,-$1#-2
Who the hell am I?
• PHP/MySQL Developer since the last
  century :)
• MySQL Community Relations Manager in
  North America
• Former Web Developer for MySQL.com
• Various positions at BioWare Corp.
  2001-2007
Who the hell am I?/2


                        MySQL Expert




PHP Expert
               ME
Who the hell am I?/3
My Agenda
• All about Scaling
• Scaling your application
• Scaling your database, especially MySQL
Your Agenda/1
• Are you a Sysadmin?
• Are you a PHP Developer?
• Are you a MySQL DBA?
• Are you all of the above?
• Are you having scaling problems?
• Are you anticipating having scaling
  problems?
Your Agenda/2

• Do you think you have PHP Issues?
• Do you think you have MySQL Issues?
• Are you just here because all the other
  tutorials didn’t seem fun?
• Who is sitting here wondering if their
  server is even up right now and whether
  they even have a job after this finishes?
Your Agenda/3


• Are you here to learn the one thing
  that will make your sites/applications
  scale unbelievably? The AMAZING,
  INCREDIBLE, silver bullet?
The Cheesy Answer
Famous scaling stories

• World of Warcraft on release, too much load,
  unprepared, system down.
• Twitter, initially continuous scaling problems
• YouTube, had to come up with new scaling
  methods to succeed.
• LiveJournal, created new technologies to stay up
• Facebook, expanded existing technologies to stay
  alive, incl. technologies from LiveJournal.
Not so famous scaling stories

• Your company site gets Slashdoted
• Your personal web site gets quoted on CNN
• You accidentally post a video which goes viral
• You decide to run a competition for drunk people
  to phone in on St. Patrick’s Day and you run the
  site on a $5/month hosted web service and some
  New York magazine picks it up as a story...
Scaling in General/1
• Scaling Definition:
 • To make something run better on a
   given set of parameters
 • Something = ?
 • Run = ?
 • Better = ?
 • Parameters =?
Scaling in General/2

• Scaling is an Art
• There is no
  one Answer
• But are you all
  knowing?
Scaling in General/3
• Scaling is about the art of asking
  questions
• The Right Questions will lead to The
  Right Answers (eventually)
Scaling in General/4
• Some bad questions:
 • “how can I set up my server for
   faster responses?”
   • better: “what is slowing down my
     queries?”
 • “how can I merge these two results
   faster in Java?”
   • better: “how do I make a JOIN?”
When to Scale

• At the beginning?
• When you hit a problem?
• When your site is down?
Question 1: Who Cares?!

• Seriously... who cares?
 • Who’s complaining?
 • What do they care about?
 • Why do they care?
Question 2: How fast?
• How fast do you need it done?
 • Timelines are very important to
   asking the right scaling questions
• How fast do you need it to get?
 • Obviously you need to understand
   what’s required!
Question 3: How much?

• How much are you willing to spend?
• How much effort are you willing to
  expend?
Question 4: Is it Enough?

• Have you defined success criteria to
  any scaling exercise?
• Have you done enough?
• When will what you have done be
  done?
Real Life Can Teach!

• Typically you describe the potential of a website as
  needing to withstand a hurricane.
• Let’s look at a real hurricane for lessons!
Hurricane!/1
• Your website: Enjoying normal weather on the
  coast of Louisiana
Hurricane!/2
• Off the coast a Hurricane is forming (someone is
  preparing to slashdot you)
Hurricane!/3
• What are the factors in surviving a really big
  Hurricane in real life?
  • Knowing its path
  • Knowing its relative strength
  • Strong pre-existing levies
  • Knowledge of the weakest points in your Levies
  • A good evacuation plan
  • A good implementation plan
Hurricane!/4
• What are the factors in surviving a really big
  Hurricane in real life?
  • Preventing abuse/looting
  • Damage control plans
  • Good leadership / project management
  • Fast Response Times
  • Good Luck
Hurricane!/5
• Knowing trajectory / Knowing its relative strength
 • Monitoring
• Strong pre-existing levies
 • Solid pre-existing infrastructure which can scale
• A good evacuation/implementation plan / Know
  your weak points
  • Know your pain points in the application
  • Have a Scaling Plan
Hurricane!/6
• Preventing abuse/looting
 • Make sure that a scaling issue does not lead to a
    security nightmare
• Damage control plans
 • Have a good disaster recovery plan if your
    scaling plan is wrong
• Good leadership / project management / Fast
  Response Times
  • What more can I say? Preparedness leads to
    success!
Hurricane!/7
System Profile?
• A list of each major system in an application
• Do it on a white-board with your systems
  engineers.
• If you do not understand each of your major
  systems, you are about to be in for a world of
  pain.
Sample System Profile/1

• Step 1: List your current systems from the
  point at which a user clicks the browser to when
  they receive the page on their screen.
   • always start from the customers perspective
   • who cares? The customer cares, you care
      about the customer!
Sample System Profile/2

• Step 2: List current system load scenarios.
  Do for each system with low, medium, high, super-
  high loads.
   • e.g. Web Servers, with low load 2 redundant
      servers enough, medium, 4, high, 8, super-high
      12.
   • Identify dependencies.
Sample System Profile/3

• Step 3: List application nodes. Identify key
  application areas and the load scenarios you
  expect on each area.
   • Important to identify, database throughput,
      data transfered, bandwidth.
   • If you don’t have load information for your
      application, you need to get it.
Sample System Profile/4

• Step 4: Go back to the System Load
  Analysis. Now with an application analysis go
  back and see if you had the System Load analysis
  correct.
Sample System Profile/5

• Step 5: Prepare for the worst. At this point
  you want to figure out what happens when things
  go completely out of bounds, can you scale each
  node?
Sample System Profile/6

• Step 6: Create a plan for scaling. You know
  how each part of your application is going to be
  affected by traffic and load, now plan for it.
   • Sounds simple.
   • Tough reality.
How to identify pain points

• Pain Point: Any point in the flow that is critical to
  the application.
    • Web server uptime should not be a pain
       point.
    • A transaction system which allows only 10
       concurrent connections when you expect to
       have hundreds... that’s a whole lot of pain.
    • Identify “Single Points of Failure”: SPoFs
How to identify pain points/2

• Load testers?
• Run monitoring solutions, especially on your
  database to see what is being hit (more later)
• Use debuggers such as xDebug for PHP and
  application profilers
• Profile your queries.
How to identify pain points/3

• Remember anything which slows the user’s
  experience is a pain point: do not forget about
  javascript and performance.
Scaling in general: Summary

• Sacrifice smart: Be prepared to sacrifice
  performance for availability.
• Grow smart: don’t expand without a plan.
• Scale smart: adding more servers is not necessarily
  scaling.
• Be smart: if you don’t have a plan, it will be worse.
Part 2: Application Scaling

• Typically this is looked at last.
• Should be looked at first.
• Application Architecture is key.
• Optimizing Frameworks is KEY!
• Ignoring Frameworks is.... your decision!
Application Scaling/1

• Step 1: Code Profiling
• Typically ignored, tend to be easier to scale
  numbers of servers, databases i.e. resources.
• Run an application through:
   • Load testers
   • Profilers (debuggers)
   • Memory footprint
   • Code audit
An example of profiling to help
       performance




 A profile of mysql.com in April 2008
   with xDebug and kCacheGrind
Application Scaling/3
                   Load Testing
• Tons of tools
• http://en.wikipedia.org/wiki/
  Category:Load_testing_tools
• Pylot (open source python-based tool)
  http://www.pylot.org/
• Create test cases, be as realistic as possible
Application Scaling/4
                   Load Testing
• Pylot Summary:
Application Scaling/5
Load Testing - Zend Framework




      Avg. 13.4 Requests/Second
Application Scaling/6
Load Testing - Zend Framework (Modified)




         Avg. 15.7 Requests/Second
Application Scaling/7
Load Testing - No Framework
Application Scaling/8

• Step 2: Query Profiling
• Application profiling and scaling should be done
  before doing server scaling.
• A query which works at 100 MB table may fail
  completely at 300GB but may just be a bad query
• Tools analyzing the Slow Query Log and   MySQL
  Query Analyzer can help.
Application Scaling/9

• Step 2: Query Profiling: Indexes
• Check to see what are your best performing
  index.
• Example, 100 million rows indexed by
  first_name(1), potentially randomly in a
  latin1 charset, you would have 100 million/26 = 3.8
  million rows to search through. Ineffective index.
• Adding a index on first_name is that a good
  solution?
Application Scaling/10

• Step 2: Query Profiling: Indexes
• Find the worst performing indexes
• http://forge.mysql.com/tools/tool.php?id=85
Application Scaling/11

• Step 2: Query Profiling: Explain
• A table from PlanetMySQL
 CREATE TABLE `entries` (
    `entry_id` int(10) unsigned NOT NULL AUTO_INCREMEN
    `title` varchar(255) NOT NULL DEFAULT '',
    ...
    KEY `title` (`title`(1))
 );
Application Scaling/12
• An Explain *without* the title index
mysql> explain select title from entries
ignore index (title) where title like 'a%' order by
title ASC limit 10G
           id: 1
  select_type: SIMPLE
        table: entries
         type: ALL
possible_keys: NULL
          key: NULL
      key_len: NULL
          ref: NULL
         rows: 18459
        Extra: Using where; Using filesort
Application Scaling/13
• An Explain *with* the title index
mysql> explain select title from entries where title
like 'a%' order by title ASC limit 10G

           id:   1
  select_type:   SIMPLE
        table:   entries
         type:   range
possible_keys:   title
          key:   title
      key_len:   5
          ref:   NULL
         rows:   706
        Extra:   Using where; Using filesort
Application Scaling/14

  • Results (Ignoring Index)
---------------------------------------------------------------------
| title
+--------------------------------------------------------------------
| A 'Simple' Protocol for Manual MySQL Slave Promotion to Master
| A (round-about) story about Jeffry P. Bezos
| ...
| A better backup procedure
+--------------------------------------------------------------------
10 rows in set (0.07 sec)
Application Scaling/15

 • Results (With Index)
+-----------------------------------------------------------------
| title
+-----------------------------------------------------------------
| A 'Simple' Protocol for Manual MySQL Slave Promotion to Master
| A (round-about) story about Jeffry P. Bezos
| ...
| A better backup procedure
+-----------------------------------------------------------------
10 rows in set (0.02 sec)
Application Scaling/16

• Is 0.05 seconds a big deal?
• Depends on the number of queries you have!
• What about a query which takes only 0.01
  seconds, is that a problem?
• Enter tools such as Query Analyzer!
Application Scaling/3
Application Scaling/17

• Step 3: Application Caching
• Caching is your friend.
• Cache any and all output that you can.
• Examine your application for caching potential
• Can reduce your use of databases dramatically and
  allow you to use cheap web server farms instead:
  Wikipedia, MySQL.com.
Application Scaling/18
• Step 3: Caching: MySQL
• MySQL Query Cache may not be your friend!
• If you configure your cache to be too big you
  might end up with a huge slow down in
  performance.
• http://blogs.sun.com/dlutz/entry/
  mysql_query_cache_sizing
• Wafflegrid: http://www.wafflegrid.com/wiki/
  index.php?title=WaffleFAQ
Application Scaling/19

• Step 4: Monitoring
• Build in monitoring into the application.
• If a person falls in the forest do you hear the PHP
  Fatal Error?
• Monitoring an application can help fix
  performance issues and identify pain points as you
  expand an application.
Application Scaling/20

• Step 5: Application Sharding
• Separate the application into multiple different
  types (video distribution, images etc.) Can
  increase performance.
• Better use of SAN hardware/storage solutions by
  pushing most accessed content on faster disks.
Application Scaling/21

• Step 6: Improving AJAX
• Profile with YSLOW, Firebug
• Consider CDNs
• Cache JS where possible
• If “web 2.0” DB gets more
  writes than reads sometimes
  -- DB Performance!
Part 3: Database Scaling
             (mostly MySQL)
• Different types of databases may help with
  performance depending on the job
• Database Architecture is critical
• Knowing your databases is even more so
Database Scaling/1

• Step 1: Memcached.
   • Developed by LiveJournal to cache key/value
      pairs in RAM of clusters of servers.
   • Incredibly fast.
   • Typically cache data coming from a DB in
      Memcache and then query Memcache from
      the application.
Database Scaling/2

• Step 1: Memcached.
 • It is not a “relational” database.
 • Help with replication lag.
 • Binary safe/cheap.
Database Scaling/3

• Step 2: Database Configuration
• Master/Slave
Database Scaling/4

• Master/Slave
• Good for high read/relatively low write
  applications.
• High content sites with limited user input (ie.
  writes) are good examples
• Con: There is replication lag, can be avoided using
  memcached
Database Scaling/5
• Sharding
Database Scaling/6

• Sharding
• Where you have many users and many writes and
  have the ability to shard on some ID/unique data.
• Pros: much easier to scale out; cheap to scale out;
  good redundancy with slaves
• Cons: much more complicated application; can be
  overkill, problems with data connections between
  shards.
Database Scaling/7

• MySQL Cluster (NDB)
• Database where data is shared amongst many
  nodes to create a true cluster. Great for database
  uptime. Used by Telcos.
Database Scaling/8

• MySQL Proxy
• MySQL Proxy is not a solution for scaling for
  speed.
• Alpha solution where proxy talks to your MySQL
  servers.
• Proxy gives you some interesting possibilities and
  potentially a look at the future
• Spider Storage Engine...
Database Scaling/9

• Step 3: MySQL Storage Engine
   • Different Storage engines
   • MyISAM, fast, no transaction, table-level
      locking. In general: good for read heavy, bad
      for write heavy web apps.
    • InnoDB faster reads on primary key lookup,
      row-level locking, transaction. In general: good
      for write heavy web apps.
Database Scaling/10

• Step 4: The Query
   • Test queries against a proper dataset size.
   • In MySQL, use EXPLAIN often and
      understand how to use indexes.
    • Sometimes a sub-selects may not be as fast as
      two selects. (smugmug!)
    • Monitoring tools: Query Analyzer, Slow Query
      Log.
Database Scaling/11

• Step 5: Schema Normalization
   • You can gain more performance by
      denormalizing your data.
   • Cons: you have to build in more data checks.
      Data integrity can become compromised very
      fast.
   • Maybe not the first thing to scale in an OLTP
      environment.
Database Scaling/12
• Step 6: Tuning the database
   • The various parameters in a MySQL database
      can have dramatic impact on your
      performance.
   • e.g. key_buffer_size, this can improve using
      indexes, but if it is too big then your system
      slows down as it starts to page and write to
      disk.
   • Start tweaking and monitoring :) or seek
      professional advice!
Database Scaling/13
• Step 7: MySQL 5.4?
   • Performance version of MySQL
   • Scales much better vertically than any
      previous official release of MySQL.
Database Scaling/14
• Step 8: Hardware time...
   • Improve performance by increasing RAM,
      faster Disk I/O depending on your situation
      and data served
   • Split the DB to serve frequently accessed data
      from faster disks.
   • Network issues?
   • Move masters to faster machines, more RAM.
   • OpenStorage? Flash Storage? SAN?
Last Words/Lessons Learned
• So does this all work? Some war stories :)
• Remember there is no silver bullet!
• Scaling Open Source means you have a million
  experts, ask your community, participate in the
  community!
• Where to find this presentation? The MySQL
  Librarian!
• Become part of the MySQL Community
Last Words/Lessons Learned
• How to find me:            • Non Sun-Fun:
 • dups@sun.com              • Tweet Rhapsody
                               http//tweetrhapsody.com
 • dups@dups.ca
                             • St. Patrick’s Day
 • http://blogs.sun.com/dups Confessionals
 • http://www.dups.ca          http//stpatsdrunkdial.com

 • Facebook: /duleepa
 • Twitter: @dups
 • LinkedIn, Flickr
Duleepa “Dups”
      Wijayawardhana
      dups@sun.com

Slides will be made available

More Related Content

What's hot

DevOps Days Vancouver 2014 Slides
DevOps Days Vancouver 2014 SlidesDevOps Days Vancouver 2014 Slides
DevOps Days Vancouver 2014 SlidesAlex Cruise
 
DevOps Picc12 Management Talk
DevOps Picc12 Management TalkDevOps Picc12 Management Talk
DevOps Picc12 Management TalkMichael Rembetsy
 
One Terrible Day at Google, and How It Made Us Better
One Terrible Day at Google, and How It Made Us BetterOne Terrible Day at Google, and How It Made Us Better
One Terrible Day at Google, and How It Made Us BetterRandy Shoup
 
Continuously Deploying Culture: Scaling Culture at Etsy - Velocity Europe 2012
Continuously Deploying Culture: Scaling Culture at Etsy - Velocity Europe 2012Continuously Deploying Culture: Scaling Culture at Etsy - Velocity Europe 2012
Continuously Deploying Culture: Scaling Culture at Etsy - Velocity Europe 2012Patrick McDonnell
 
Continuous Delivery antipatterns from the wild - Matthew Skelton - Continuous...
Continuous Delivery antipatterns from the wild - Matthew Skelton - Continuous...Continuous Delivery antipatterns from the wild - Matthew Skelton - Continuous...
Continuous Delivery antipatterns from the wild - Matthew Skelton - Continuous...Skelton Thatcher Consulting Ltd
 
Reactive Streams and the Wide World of Groovy
Reactive Streams and the Wide World of GroovyReactive Streams and the Wide World of Groovy
Reactive Streams and the Wide World of GroovySteve Pember
 
Agile Incident Response and Resolution in the Wold of Devops
Agile Incident Response and Resolution in the Wold of DevopsAgile Incident Response and Resolution in the Wold of Devops
Agile Incident Response and Resolution in the Wold of DevopsAtlassian
 
An introduction to Reactive applications, Reactive Streams, and options for t...
An introduction to Reactive applications, Reactive Streams, and options for t...An introduction to Reactive applications, Reactive Streams, and options for t...
An introduction to Reactive applications, Reactive Streams, and options for t...Steve Pember
 
Top Lessons Learned From The DevOps Handbook
Top Lessons Learned From The DevOps HandbookTop Lessons Learned From The DevOps Handbook
Top Lessons Learned From The DevOps HandbookXebiaLabs
 
DevOps - It's About How We Work
DevOps - It's About How We WorkDevOps - It's About How We Work
DevOps - It's About How We WorkRandy Shoup
 
Anatomy of Three Incidents -- Commonalities and Lessons
Anatomy of Three Incidents -- Commonalities and LessonsAnatomy of Three Incidents -- Commonalities and Lessons
Anatomy of Three Incidents -- Commonalities and LessonsRandy Shoup
 
DOES SFO 2016 - Topo Pal - DevOps at Capital One
DOES SFO 2016 - Topo Pal - DevOps at Capital OneDOES SFO 2016 - Topo Pal - DevOps at Capital One
DOES SFO 2016 - Topo Pal - DevOps at Capital OneGene Kim
 
Andrew rusling 21 experiments to increase velocity
Andrew rusling 21 experiments to increase velocityAndrew rusling 21 experiments to increase velocity
Andrew rusling 21 experiments to increase velocityScrum Australia Pty Ltd
 
Minimal Viable Architecture - Silicon Slopes 2020
Minimal Viable Architecture - Silicon Slopes 2020Minimal Viable Architecture - Silicon Slopes 2020
Minimal Viable Architecture - Silicon Slopes 2020Randy Shoup
 
Outsmarting Merge Edge Cases in Component Based Design
Outsmarting Merge Edge Cases in Component Based DesignOutsmarting Merge Edge Cases in Component Based Design
Outsmarting Merge Edge Cases in Component Based DesignPerforce
 
Distributed Release Management
Distributed Release ManagementDistributed Release Management
Distributed Release ManagementMike Brittain
 
Reactive Streams and the Wide World of Groovy
Reactive Streams and the Wide World of GroovyReactive Streams and the Wide World of Groovy
Reactive Streams and the Wide World of GroovySteve Pember
 
Debugging (Docker) containers in production
Debugging (Docker) containers in productionDebugging (Docker) containers in production
Debugging (Docker) containers in productionbcantrill
 
Badcamp 2015 - R.E.A.D: Four Steps for Selecting The Right Modules
Badcamp 2015 - R.E.A.D: Four Steps for Selecting The Right ModulesBadcamp 2015 - R.E.A.D: Four Steps for Selecting The Right Modules
Badcamp 2015 - R.E.A.D: Four Steps for Selecting The Right ModulesMichael Miles
 
Devops, the future is here, it's just not evenly distributed yet.
Devops, the future is here, it's just not evenly distributed yet.Devops, the future is here, it's just not evenly distributed yet.
Devops, the future is here, it's just not evenly distributed yet.Kris Buytaert
 

What's hot (20)

DevOps Days Vancouver 2014 Slides
DevOps Days Vancouver 2014 SlidesDevOps Days Vancouver 2014 Slides
DevOps Days Vancouver 2014 Slides
 
DevOps Picc12 Management Talk
DevOps Picc12 Management TalkDevOps Picc12 Management Talk
DevOps Picc12 Management Talk
 
One Terrible Day at Google, and How It Made Us Better
One Terrible Day at Google, and How It Made Us BetterOne Terrible Day at Google, and How It Made Us Better
One Terrible Day at Google, and How It Made Us Better
 
Continuously Deploying Culture: Scaling Culture at Etsy - Velocity Europe 2012
Continuously Deploying Culture: Scaling Culture at Etsy - Velocity Europe 2012Continuously Deploying Culture: Scaling Culture at Etsy - Velocity Europe 2012
Continuously Deploying Culture: Scaling Culture at Etsy - Velocity Europe 2012
 
Continuous Delivery antipatterns from the wild - Matthew Skelton - Continuous...
Continuous Delivery antipatterns from the wild - Matthew Skelton - Continuous...Continuous Delivery antipatterns from the wild - Matthew Skelton - Continuous...
Continuous Delivery antipatterns from the wild - Matthew Skelton - Continuous...
 
Reactive Streams and the Wide World of Groovy
Reactive Streams and the Wide World of GroovyReactive Streams and the Wide World of Groovy
Reactive Streams and the Wide World of Groovy
 
Agile Incident Response and Resolution in the Wold of Devops
Agile Incident Response and Resolution in the Wold of DevopsAgile Incident Response and Resolution in the Wold of Devops
Agile Incident Response and Resolution in the Wold of Devops
 
An introduction to Reactive applications, Reactive Streams, and options for t...
An introduction to Reactive applications, Reactive Streams, and options for t...An introduction to Reactive applications, Reactive Streams, and options for t...
An introduction to Reactive applications, Reactive Streams, and options for t...
 
Top Lessons Learned From The DevOps Handbook
Top Lessons Learned From The DevOps HandbookTop Lessons Learned From The DevOps Handbook
Top Lessons Learned From The DevOps Handbook
 
DevOps - It's About How We Work
DevOps - It's About How We WorkDevOps - It's About How We Work
DevOps - It's About How We Work
 
Anatomy of Three Incidents -- Commonalities and Lessons
Anatomy of Three Incidents -- Commonalities and LessonsAnatomy of Three Incidents -- Commonalities and Lessons
Anatomy of Three Incidents -- Commonalities and Lessons
 
DOES SFO 2016 - Topo Pal - DevOps at Capital One
DOES SFO 2016 - Topo Pal - DevOps at Capital OneDOES SFO 2016 - Topo Pal - DevOps at Capital One
DOES SFO 2016 - Topo Pal - DevOps at Capital One
 
Andrew rusling 21 experiments to increase velocity
Andrew rusling 21 experiments to increase velocityAndrew rusling 21 experiments to increase velocity
Andrew rusling 21 experiments to increase velocity
 
Minimal Viable Architecture - Silicon Slopes 2020
Minimal Viable Architecture - Silicon Slopes 2020Minimal Viable Architecture - Silicon Slopes 2020
Minimal Viable Architecture - Silicon Slopes 2020
 
Outsmarting Merge Edge Cases in Component Based Design
Outsmarting Merge Edge Cases in Component Based DesignOutsmarting Merge Edge Cases in Component Based Design
Outsmarting Merge Edge Cases in Component Based Design
 
Distributed Release Management
Distributed Release ManagementDistributed Release Management
Distributed Release Management
 
Reactive Streams and the Wide World of Groovy
Reactive Streams and the Wide World of GroovyReactive Streams and the Wide World of Groovy
Reactive Streams and the Wide World of Groovy
 
Debugging (Docker) containers in production
Debugging (Docker) containers in productionDebugging (Docker) containers in production
Debugging (Docker) containers in production
 
Badcamp 2015 - R.E.A.D: Four Steps for Selecting The Right Modules
Badcamp 2015 - R.E.A.D: Four Steps for Selecting The Right ModulesBadcamp 2015 - R.E.A.D: Four Steps for Selecting The Right Modules
Badcamp 2015 - R.E.A.D: Four Steps for Selecting The Right Modules
 
Devops, the future is here, it's just not evenly distributed yet.
Devops, the future is here, it's just not evenly distributed yet.Devops, the future is here, it's just not evenly distributed yet.
Devops, the future is here, it's just not evenly distributed yet.
 

Viewers also liked

Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)
Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)
Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)Michael Wales
 
Y!7 Simple Scalability
Y!7 Simple ScalabilityY!7 Simple Scalability
Y!7 Simple Scalabilitysteveathon
 
How To Build A Website And Stay Sane
How To Build A Website And Stay SaneHow To Build A Website And Stay Sane
How To Build A Website And Stay SaneJonathan Oxer
 
Scaling LAMP doesn't have to suck
Scaling LAMP doesn't have to suckScaling LAMP doesn't have to suck
Scaling LAMP doesn't have to suckStephen Corona
 
Memcached vs redis
Memcached vs redisMemcached vs redis
Memcached vs redisqianshi
 
Php 7 hhvm and co
Php 7 hhvm and coPhp 7 hhvm and co
Php 7 hhvm and coPierre Joye
 
Large-scale projects development (scaling LAMP)
Large-scale projects development (scaling LAMP)Large-scale projects development (scaling LAMP)
Large-scale projects development (scaling LAMP)Alexey Rybak
 
PHP Performance with APC + Memcached
PHP Performance with APC + MemcachedPHP Performance with APC + Memcached
PHP Performance with APC + MemcachedFord AntiTrust
 

Viewers also liked (9)

Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)
Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)
Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)
 
Y!7 Simple Scalability
Y!7 Simple ScalabilityY!7 Simple Scalability
Y!7 Simple Scalability
 
How To Build A Website And Stay Sane
How To Build A Website And Stay SaneHow To Build A Website And Stay Sane
How To Build A Website And Stay Sane
 
Large Scale PHP
Large Scale PHPLarge Scale PHP
Large Scale PHP
 
Scaling LAMP doesn't have to suck
Scaling LAMP doesn't have to suckScaling LAMP doesn't have to suck
Scaling LAMP doesn't have to suck
 
Memcached vs redis
Memcached vs redisMemcached vs redis
Memcached vs redis
 
Php 7 hhvm and co
Php 7 hhvm and coPhp 7 hhvm and co
Php 7 hhvm and co
 
Large-scale projects development (scaling LAMP)
Large-scale projects development (scaling LAMP)Large-scale projects development (scaling LAMP)
Large-scale projects development (scaling LAMP)
 
PHP Performance with APC + Memcached
PHP Performance with APC + MemcachedPHP Performance with APC + Memcached
PHP Performance with APC + Memcached
 

Similar to Scaling a Web Site - OSCON Tutorial

Jax Devops 2017 Succeeding in the Cloud – the guidebook of Fail
Jax Devops 2017  Succeeding in the Cloud – the guidebook of FailJax Devops 2017  Succeeding in the Cloud – the guidebook of Fail
Jax Devops 2017 Succeeding in the Cloud – the guidebook of FailSteve Poole
 
Performance Optimization of Cloud Based Applications by Peter Smith, ACL
Performance Optimization of Cloud Based Applications by Peter Smith, ACLPerformance Optimization of Cloud Based Applications by Peter Smith, ACL
Performance Optimization of Cloud Based Applications by Peter Smith, ACLTriNimbus
 
Scaling a High Traffic Web Application: Our Journey from Java to PHP
Scaling a High Traffic Web Application: Our Journey from Java to PHPScaling a High Traffic Web Application: Our Journey from Java to PHP
Scaling a High Traffic Web Application: Our Journey from Java to PHP120bi
 
Scaling High Traffic Web Applications
Scaling High Traffic Web ApplicationsScaling High Traffic Web Applications
Scaling High Traffic Web ApplicationsAchievers Tech
 
Making disaster routine
Making disaster routineMaking disaster routine
Making disaster routinePeter Varhol
 
Cleaning Code - Tools and Techniques for Large Legacy Projects
Cleaning Code - Tools and Techniques for Large Legacy ProjectsCleaning Code - Tools and Techniques for Large Legacy Projects
Cleaning Code - Tools and Techniques for Large Legacy ProjectsMike Long
 
Silicon Valley Code Camp 2015 - Advanced MongoDB - The Sequel
Silicon Valley Code Camp 2015 - Advanced MongoDB - The SequelSilicon Valley Code Camp 2015 - Advanced MongoDB - The Sequel
Silicon Valley Code Camp 2015 - Advanced MongoDB - The SequelDaniel Coupal
 
Shitlist-driven development and other tricks for working on large codebases
Shitlist-driven development and other tricks for working on large codebasesShitlist-driven development and other tricks for working on large codebases
Shitlist-driven development and other tricks for working on large codebasesFlorian Weingarten
 
Building data intensive applications
Building data intensive applicationsBuilding data intensive applications
Building data intensive applicationsAmit Kejriwal
 
Performance Tuning
Performance TuningPerformance Tuning
Performance TuningJannet Peetz
 
Ncerc rlmca202 adm m1 ssm
Ncerc rlmca202 adm m1 ssmNcerc rlmca202 adm m1 ssm
Ncerc rlmca202 adm m1 ssmssmarar
 
FutureOfTesting2008
FutureOfTesting2008FutureOfTesting2008
FutureOfTesting2008vipulkocher
 
iOSDC 2018 Presentation - Casual Talk
iOSDC 2018 Presentation - Casual TalkiOSDC 2018 Presentation - Casual Talk
iOSDC 2018 Presentation - Casual Talkkimi Ng
 
Software Defects and SW Reliability Assessment
Software Defects and SW Reliability AssessmentSoftware Defects and SW Reliability Assessment
Software Defects and SW Reliability AssessmentKristine Hejna
 
The 5 Minute MySQL DBA
The 5 Minute MySQL DBAThe 5 Minute MySQL DBA
The 5 Minute MySQL DBAIrawan Soetomo
 
USG Rock Eagle 2017 - PWP at 1000 Days
USG Rock Eagle 2017 - PWP at 1000 DaysUSG Rock Eagle 2017 - PWP at 1000 Days
USG Rock Eagle 2017 - PWP at 1000 DaysEric Sembrat
 
27.1.2014 Tampere. Perinteinen mobiilimaailma murroksessa. Tommi Teräsvirta: ...
27.1.2014 Tampere. Perinteinen mobiilimaailma murroksessa. Tommi Teräsvirta: ...27.1.2014 Tampere. Perinteinen mobiilimaailma murroksessa. Tommi Teräsvirta: ...
27.1.2014 Tampere. Perinteinen mobiilimaailma murroksessa. Tommi Teräsvirta: ...Tieturi Oy
 
Web Application Security And Getting Into Bug Bounties
Web Application Security And Getting Into Bug BountiesWeb Application Security And Getting Into Bug Bounties
Web Application Security And Getting Into Bug Bountieskunwaratul hax0r
 
A Perfect Launch, Every Time
A Perfect Launch, Every TimeA Perfect Launch, Every Time
A Perfect Launch, Every TimePantheon
 

Similar to Scaling a Web Site - OSCON Tutorial (20)

Jax Devops 2017 Succeeding in the Cloud – the guidebook of Fail
Jax Devops 2017  Succeeding in the Cloud – the guidebook of FailJax Devops 2017  Succeeding in the Cloud – the guidebook of Fail
Jax Devops 2017 Succeeding in the Cloud – the guidebook of Fail
 
Performance Optimization of Cloud Based Applications by Peter Smith, ACL
Performance Optimization of Cloud Based Applications by Peter Smith, ACLPerformance Optimization of Cloud Based Applications by Peter Smith, ACL
Performance Optimization of Cloud Based Applications by Peter Smith, ACL
 
Scaling a High Traffic Web Application: Our Journey from Java to PHP
Scaling a High Traffic Web Application: Our Journey from Java to PHPScaling a High Traffic Web Application: Our Journey from Java to PHP
Scaling a High Traffic Web Application: Our Journey from Java to PHP
 
Scaling High Traffic Web Applications
Scaling High Traffic Web ApplicationsScaling High Traffic Web Applications
Scaling High Traffic Web Applications
 
Making disaster routine
Making disaster routineMaking disaster routine
Making disaster routine
 
Cleaning Code - Tools and Techniques for Large Legacy Projects
Cleaning Code - Tools and Techniques for Large Legacy ProjectsCleaning Code - Tools and Techniques for Large Legacy Projects
Cleaning Code - Tools and Techniques for Large Legacy Projects
 
Silicon Valley Code Camp 2015 - Advanced MongoDB - The Sequel
Silicon Valley Code Camp 2015 - Advanced MongoDB - The SequelSilicon Valley Code Camp 2015 - Advanced MongoDB - The Sequel
Silicon Valley Code Camp 2015 - Advanced MongoDB - The Sequel
 
Shitlist-driven development and other tricks for working on large codebases
Shitlist-driven development and other tricks for working on large codebasesShitlist-driven development and other tricks for working on large codebases
Shitlist-driven development and other tricks for working on large codebases
 
Building data intensive applications
Building data intensive applicationsBuilding data intensive applications
Building data intensive applications
 
Performance Tuning
Performance TuningPerformance Tuning
Performance Tuning
 
Ncerc rlmca202 adm m1 ssm
Ncerc rlmca202 adm m1 ssmNcerc rlmca202 adm m1 ssm
Ncerc rlmca202 adm m1 ssm
 
FutureOfTesting2008
FutureOfTesting2008FutureOfTesting2008
FutureOfTesting2008
 
Working Effectively with PeopleSoft Support
Working Effectively with PeopleSoft SupportWorking Effectively with PeopleSoft Support
Working Effectively with PeopleSoft Support
 
iOSDC 2018 Presentation - Casual Talk
iOSDC 2018 Presentation - Casual TalkiOSDC 2018 Presentation - Casual Talk
iOSDC 2018 Presentation - Casual Talk
 
Software Defects and SW Reliability Assessment
Software Defects and SW Reliability AssessmentSoftware Defects and SW Reliability Assessment
Software Defects and SW Reliability Assessment
 
The 5 Minute MySQL DBA
The 5 Minute MySQL DBAThe 5 Minute MySQL DBA
The 5 Minute MySQL DBA
 
USG Rock Eagle 2017 - PWP at 1000 Days
USG Rock Eagle 2017 - PWP at 1000 DaysUSG Rock Eagle 2017 - PWP at 1000 Days
USG Rock Eagle 2017 - PWP at 1000 Days
 
27.1.2014 Tampere. Perinteinen mobiilimaailma murroksessa. Tommi Teräsvirta: ...
27.1.2014 Tampere. Perinteinen mobiilimaailma murroksessa. Tommi Teräsvirta: ...27.1.2014 Tampere. Perinteinen mobiilimaailma murroksessa. Tommi Teräsvirta: ...
27.1.2014 Tampere. Perinteinen mobiilimaailma murroksessa. Tommi Teräsvirta: ...
 
Web Application Security And Getting Into Bug Bounties
Web Application Security And Getting Into Bug BountiesWeb Application Security And Getting Into Bug Bounties
Web Application Security And Getting Into Bug Bounties
 
A Perfect Launch, Every Time
A Perfect Launch, Every TimeA Perfect Launch, Every Time
A Perfect Launch, Every Time
 

Recently uploaded

Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 

Recently uploaded (20)

Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 

Scaling a Web Site - OSCON Tutorial

  • 1. Scaling a Web Application (mostly PHP/MySQL and almost mostly harmless) Duleepa “Dups” Wijayawardhana MySQL Community Team " " ! !"#$%&#'()*#+(,-.$/#+*0#,-$1#-2
  • 2. Who the hell am I? • PHP/MySQL Developer since the last century :) • MySQL Community Relations Manager in North America • Former Web Developer for MySQL.com • Various positions at BioWare Corp. 2001-2007
  • 3. Who the hell am I?/2 MySQL Expert PHP Expert ME
  • 4. Who the hell am I?/3
  • 5. My Agenda • All about Scaling • Scaling your application • Scaling your database, especially MySQL
  • 6. Your Agenda/1 • Are you a Sysadmin? • Are you a PHP Developer? • Are you a MySQL DBA? • Are you all of the above? • Are you having scaling problems? • Are you anticipating having scaling problems?
  • 7. Your Agenda/2 • Do you think you have PHP Issues? • Do you think you have MySQL Issues? • Are you just here because all the other tutorials didn’t seem fun? • Who is sitting here wondering if their server is even up right now and whether they even have a job after this finishes?
  • 8. Your Agenda/3 • Are you here to learn the one thing that will make your sites/applications scale unbelievably? The AMAZING, INCREDIBLE, silver bullet?
  • 10. Famous scaling stories • World of Warcraft on release, too much load, unprepared, system down. • Twitter, initially continuous scaling problems • YouTube, had to come up with new scaling methods to succeed. • LiveJournal, created new technologies to stay up • Facebook, expanded existing technologies to stay alive, incl. technologies from LiveJournal.
  • 11. Not so famous scaling stories • Your company site gets Slashdoted • Your personal web site gets quoted on CNN • You accidentally post a video which goes viral • You decide to run a competition for drunk people to phone in on St. Patrick’s Day and you run the site on a $5/month hosted web service and some New York magazine picks it up as a story...
  • 12.
  • 13. Scaling in General/1 • Scaling Definition: • To make something run better on a given set of parameters • Something = ? • Run = ? • Better = ? • Parameters =?
  • 14. Scaling in General/2 • Scaling is an Art • There is no one Answer • But are you all knowing?
  • 15. Scaling in General/3 • Scaling is about the art of asking questions • The Right Questions will lead to The Right Answers (eventually)
  • 16. Scaling in General/4 • Some bad questions: • “how can I set up my server for faster responses?” • better: “what is slowing down my queries?” • “how can I merge these two results faster in Java?” • better: “how do I make a JOIN?”
  • 17. When to Scale • At the beginning? • When you hit a problem? • When your site is down?
  • 18. Question 1: Who Cares?! • Seriously... who cares? • Who’s complaining? • What do they care about? • Why do they care?
  • 19. Question 2: How fast? • How fast do you need it done? • Timelines are very important to asking the right scaling questions • How fast do you need it to get? • Obviously you need to understand what’s required!
  • 20. Question 3: How much? • How much are you willing to spend? • How much effort are you willing to expend?
  • 21. Question 4: Is it Enough? • Have you defined success criteria to any scaling exercise? • Have you done enough? • When will what you have done be done?
  • 22. Real Life Can Teach! • Typically you describe the potential of a website as needing to withstand a hurricane. • Let’s look at a real hurricane for lessons!
  • 23. Hurricane!/1 • Your website: Enjoying normal weather on the coast of Louisiana
  • 24. Hurricane!/2 • Off the coast a Hurricane is forming (someone is preparing to slashdot you)
  • 25. Hurricane!/3 • What are the factors in surviving a really big Hurricane in real life? • Knowing its path • Knowing its relative strength • Strong pre-existing levies • Knowledge of the weakest points in your Levies • A good evacuation plan • A good implementation plan
  • 26. Hurricane!/4 • What are the factors in surviving a really big Hurricane in real life? • Preventing abuse/looting • Damage control plans • Good leadership / project management • Fast Response Times • Good Luck
  • 27. Hurricane!/5 • Knowing trajectory / Knowing its relative strength • Monitoring • Strong pre-existing levies • Solid pre-existing infrastructure which can scale • A good evacuation/implementation plan / Know your weak points • Know your pain points in the application • Have a Scaling Plan
  • 28. Hurricane!/6 • Preventing abuse/looting • Make sure that a scaling issue does not lead to a security nightmare • Damage control plans • Have a good disaster recovery plan if your scaling plan is wrong • Good leadership / project management / Fast Response Times • What more can I say? Preparedness leads to success!
  • 30. System Profile? • A list of each major system in an application • Do it on a white-board with your systems engineers. • If you do not understand each of your major systems, you are about to be in for a world of pain.
  • 31. Sample System Profile/1 • Step 1: List your current systems from the point at which a user clicks the browser to when they receive the page on their screen. • always start from the customers perspective • who cares? The customer cares, you care about the customer!
  • 32. Sample System Profile/2 • Step 2: List current system load scenarios. Do for each system with low, medium, high, super- high loads. • e.g. Web Servers, with low load 2 redundant servers enough, medium, 4, high, 8, super-high 12. • Identify dependencies.
  • 33. Sample System Profile/3 • Step 3: List application nodes. Identify key application areas and the load scenarios you expect on each area. • Important to identify, database throughput, data transfered, bandwidth. • If you don’t have load information for your application, you need to get it.
  • 34. Sample System Profile/4 • Step 4: Go back to the System Load Analysis. Now with an application analysis go back and see if you had the System Load analysis correct.
  • 35. Sample System Profile/5 • Step 5: Prepare for the worst. At this point you want to figure out what happens when things go completely out of bounds, can you scale each node?
  • 36. Sample System Profile/6 • Step 6: Create a plan for scaling. You know how each part of your application is going to be affected by traffic and load, now plan for it. • Sounds simple. • Tough reality.
  • 37. How to identify pain points • Pain Point: Any point in the flow that is critical to the application. • Web server uptime should not be a pain point. • A transaction system which allows only 10 concurrent connections when you expect to have hundreds... that’s a whole lot of pain. • Identify “Single Points of Failure”: SPoFs
  • 38. How to identify pain points/2 • Load testers? • Run monitoring solutions, especially on your database to see what is being hit (more later) • Use debuggers such as xDebug for PHP and application profilers • Profile your queries.
  • 39. How to identify pain points/3 • Remember anything which slows the user’s experience is a pain point: do not forget about javascript and performance.
  • 40. Scaling in general: Summary • Sacrifice smart: Be prepared to sacrifice performance for availability. • Grow smart: don’t expand without a plan. • Scale smart: adding more servers is not necessarily scaling. • Be smart: if you don’t have a plan, it will be worse.
  • 41. Part 2: Application Scaling • Typically this is looked at last. • Should be looked at first. • Application Architecture is key. • Optimizing Frameworks is KEY! • Ignoring Frameworks is.... your decision!
  • 42. Application Scaling/1 • Step 1: Code Profiling • Typically ignored, tend to be easier to scale numbers of servers, databases i.e. resources. • Run an application through: • Load testers • Profilers (debuggers) • Memory footprint • Code audit
  • 43. An example of profiling to help performance A profile of mysql.com in April 2008 with xDebug and kCacheGrind
  • 44. Application Scaling/3 Load Testing • Tons of tools • http://en.wikipedia.org/wiki/ Category:Load_testing_tools • Pylot (open source python-based tool) http://www.pylot.org/ • Create test cases, be as realistic as possible
  • 45. Application Scaling/4 Load Testing • Pylot Summary:
  • 46. Application Scaling/5 Load Testing - Zend Framework Avg. 13.4 Requests/Second
  • 47. Application Scaling/6 Load Testing - Zend Framework (Modified) Avg. 15.7 Requests/Second
  • 49. Application Scaling/8 • Step 2: Query Profiling • Application profiling and scaling should be done before doing server scaling. • A query which works at 100 MB table may fail completely at 300GB but may just be a bad query • Tools analyzing the Slow Query Log and MySQL Query Analyzer can help.
  • 50. Application Scaling/9 • Step 2: Query Profiling: Indexes • Check to see what are your best performing index. • Example, 100 million rows indexed by first_name(1), potentially randomly in a latin1 charset, you would have 100 million/26 = 3.8 million rows to search through. Ineffective index. • Adding a index on first_name is that a good solution?
  • 51. Application Scaling/10 • Step 2: Query Profiling: Indexes • Find the worst performing indexes • http://forge.mysql.com/tools/tool.php?id=85
  • 52. Application Scaling/11 • Step 2: Query Profiling: Explain • A table from PlanetMySQL CREATE TABLE `entries` ( `entry_id` int(10) unsigned NOT NULL AUTO_INCREMEN `title` varchar(255) NOT NULL DEFAULT '', ... KEY `title` (`title`(1)) );
  • 53. Application Scaling/12 • An Explain *without* the title index mysql> explain select title from entries ignore index (title) where title like 'a%' order by title ASC limit 10G id: 1 select_type: SIMPLE table: entries type: ALL possible_keys: NULL key: NULL key_len: NULL ref: NULL rows: 18459 Extra: Using where; Using filesort
  • 54. Application Scaling/13 • An Explain *with* the title index mysql> explain select title from entries where title like 'a%' order by title ASC limit 10G id: 1 select_type: SIMPLE table: entries type: range possible_keys: title key: title key_len: 5 ref: NULL rows: 706 Extra: Using where; Using filesort
  • 55. Application Scaling/14 • Results (Ignoring Index) --------------------------------------------------------------------- | title +-------------------------------------------------------------------- | A 'Simple' Protocol for Manual MySQL Slave Promotion to Master | A (round-about) story about Jeffry P. Bezos | ... | A better backup procedure +-------------------------------------------------------------------- 10 rows in set (0.07 sec)
  • 56. Application Scaling/15 • Results (With Index) +----------------------------------------------------------------- | title +----------------------------------------------------------------- | A 'Simple' Protocol for Manual MySQL Slave Promotion to Master | A (round-about) story about Jeffry P. Bezos | ... | A better backup procedure +----------------------------------------------------------------- 10 rows in set (0.02 sec)
  • 57. Application Scaling/16 • Is 0.05 seconds a big deal? • Depends on the number of queries you have! • What about a query which takes only 0.01 seconds, is that a problem? • Enter tools such as Query Analyzer!
  • 59. Application Scaling/17 • Step 3: Application Caching • Caching is your friend. • Cache any and all output that you can. • Examine your application for caching potential • Can reduce your use of databases dramatically and allow you to use cheap web server farms instead: Wikipedia, MySQL.com.
  • 60. Application Scaling/18 • Step 3: Caching: MySQL • MySQL Query Cache may not be your friend! • If you configure your cache to be too big you might end up with a huge slow down in performance. • http://blogs.sun.com/dlutz/entry/ mysql_query_cache_sizing • Wafflegrid: http://www.wafflegrid.com/wiki/ index.php?title=WaffleFAQ
  • 61. Application Scaling/19 • Step 4: Monitoring • Build in monitoring into the application. • If a person falls in the forest do you hear the PHP Fatal Error? • Monitoring an application can help fix performance issues and identify pain points as you expand an application.
  • 62. Application Scaling/20 • Step 5: Application Sharding • Separate the application into multiple different types (video distribution, images etc.) Can increase performance. • Better use of SAN hardware/storage solutions by pushing most accessed content on faster disks.
  • 63. Application Scaling/21 • Step 6: Improving AJAX • Profile with YSLOW, Firebug • Consider CDNs • Cache JS where possible • If “web 2.0” DB gets more writes than reads sometimes -- DB Performance!
  • 64. Part 3: Database Scaling (mostly MySQL) • Different types of databases may help with performance depending on the job • Database Architecture is critical • Knowing your databases is even more so
  • 65. Database Scaling/1 • Step 1: Memcached. • Developed by LiveJournal to cache key/value pairs in RAM of clusters of servers. • Incredibly fast. • Typically cache data coming from a DB in Memcache and then query Memcache from the application.
  • 66. Database Scaling/2 • Step 1: Memcached. • It is not a “relational” database. • Help with replication lag. • Binary safe/cheap.
  • 67. Database Scaling/3 • Step 2: Database Configuration • Master/Slave
  • 68. Database Scaling/4 • Master/Slave • Good for high read/relatively low write applications. • High content sites with limited user input (ie. writes) are good examples • Con: There is replication lag, can be avoided using memcached
  • 70. Database Scaling/6 • Sharding • Where you have many users and many writes and have the ability to shard on some ID/unique data. • Pros: much easier to scale out; cheap to scale out; good redundancy with slaves • Cons: much more complicated application; can be overkill, problems with data connections between shards.
  • 71. Database Scaling/7 • MySQL Cluster (NDB) • Database where data is shared amongst many nodes to create a true cluster. Great for database uptime. Used by Telcos.
  • 72. Database Scaling/8 • MySQL Proxy • MySQL Proxy is not a solution for scaling for speed. • Alpha solution where proxy talks to your MySQL servers. • Proxy gives you some interesting possibilities and potentially a look at the future • Spider Storage Engine...
  • 73. Database Scaling/9 • Step 3: MySQL Storage Engine • Different Storage engines • MyISAM, fast, no transaction, table-level locking. In general: good for read heavy, bad for write heavy web apps. • InnoDB faster reads on primary key lookup, row-level locking, transaction. In general: good for write heavy web apps.
  • 74. Database Scaling/10 • Step 4: The Query • Test queries against a proper dataset size. • In MySQL, use EXPLAIN often and understand how to use indexes. • Sometimes a sub-selects may not be as fast as two selects. (smugmug!) • Monitoring tools: Query Analyzer, Slow Query Log.
  • 75. Database Scaling/11 • Step 5: Schema Normalization • You can gain more performance by denormalizing your data. • Cons: you have to build in more data checks. Data integrity can become compromised very fast. • Maybe not the first thing to scale in an OLTP environment.
  • 76. Database Scaling/12 • Step 6: Tuning the database • The various parameters in a MySQL database can have dramatic impact on your performance. • e.g. key_buffer_size, this can improve using indexes, but if it is too big then your system slows down as it starts to page and write to disk. • Start tweaking and monitoring :) or seek professional advice!
  • 77. Database Scaling/13 • Step 7: MySQL 5.4? • Performance version of MySQL • Scales much better vertically than any previous official release of MySQL.
  • 78. Database Scaling/14 • Step 8: Hardware time... • Improve performance by increasing RAM, faster Disk I/O depending on your situation and data served • Split the DB to serve frequently accessed data from faster disks. • Network issues? • Move masters to faster machines, more RAM. • OpenStorage? Flash Storage? SAN?
  • 79. Last Words/Lessons Learned • So does this all work? Some war stories :) • Remember there is no silver bullet! • Scaling Open Source means you have a million experts, ask your community, participate in the community! • Where to find this presentation? The MySQL Librarian! • Become part of the MySQL Community
  • 80. Last Words/Lessons Learned • How to find me: • Non Sun-Fun: • dups@sun.com • Tweet Rhapsody http//tweetrhapsody.com • dups@dups.ca • St. Patrick’s Day • http://blogs.sun.com/dups Confessionals • http://www.dups.ca http//stpatsdrunkdial.com • Facebook: /duleepa • Twitter: @dups • LinkedIn, Flickr
  • 81. Duleepa “Dups” Wijayawardhana dups@sun.com Slides will be made available