Sensible Scaling




                   Rowan Merewood
Sensible Scaling




  “If your application doesn't scale, it's your fault not mine.”
  – Rasmus Lerdorf (@rasmus)

                                                Rowan Merewood
Who?
Who?
●
    @rowan_m
Who?
●
    @rowan_m

●
    Software Engineer
    & Team Lead
Who?
●
    @rowan_m

●
    Software Engineer
    & Team Lead
●
    @ibuildings &
    @techportal
Why?
Why?
  ●
      I've built small apps
Why?
  ●
      I've built small apps
  ●
      and pretty large ones
Why?
  ●
      I've built small apps
  ●
      and pretty large ones

  ●
      I've seen massive
      over-engineering
Why?
  ●
      I've built small apps
  ●
      and pretty large ones

  ●
      I've seen massive
      over-engineering
  ●
      and platforms that
      cannot scale
TDD Principles
TDD Principles
●
    Write only enough
    code to pass the test
TDD Principles
●
    Write only enough
    code to pass the test
●
    Do not over-engineer
TDD Principles
●
    Write only enough
    code to pass the test
●
    Do not over-engineer

●
    Don't give away work
    for free!
Build for now
Build for now
       ●
           Don't be afraid to
           throw code away
Build for now
       ●
           Don't be afraid to
           throw code away
       ●
           XP's spikes
Build for now
       ●
           Don't be afraid to
           throw code away
       ●
           XP's spikes

       ●
           Take advantage of
           current tech.
           without tying
           yourself to it
Who are your users?
Who are your users?
●
    Lots of short visits?
Who are your users?
●
    Lots of short visits?
●
    Anonymous or
    session-based?
Who are your users?
●
    Lots of short visits?
●
    Anonymous or
    session-based?
●
    Long, complex
    interactions?
Who are your users?
●
    Lots of short visits?
●
    Anonymous or
    session-based?
●
    Long, complex
    interactions?
●
    Subscribers or
    free users?
Monitor and Analyse




http://community.plus.net/blog/2011/10/24/a-record-setting-manchester-derby/
Monitor and Analyse
                                        ●
                                            Predict usage
                                            patterns




http://community.plus.net/blog/2011/10/24/a-record-setting-manchester-derby/
Monitor and Analyse
                                        ●
                                            Predict usage
                                            patterns
                                        ●
                                            Plan for peaks and
                                            troughs




http://community.plus.net/blog/2011/10/24/a-record-setting-manchester-derby/
Profiling
Profiling
●
    You do not know
    what is slow
Profiling
●
    You do not know
    what is slow
●
    Ensure you measure
    more than just code!
Profiling
Profiling
●
    PHP - Xdebug – Derick Rethans (@derickr)
    ●
        Kcachegrind, Webgrind, etc.
Profiling
●
    PHP - Xdebug – Derick Rethans (@derickr)
    ●
        Kcachegrind, Webgrind, etc.
●
    PHP – XHProf
Profiling
●
    PHP - Xdebug – Derick Rethans (@derickr)
    ●
        Kcachegrind, Webgrind, etc.
●
    PHP – XHProf
●
    JavaScript – Firebug
Profiling
●
    PHP - Xdebug – Derick Rethans (@derickr)
    ●
        Kcachegrind, Webgrind, etc.
●
    PHP – XHProf
●
    JavaScript – Firebug
●
    JavaScript – Venkman
Profiling
●
    PHP - Xdebug – Derick Rethans (@derickr)
    ●
        Kcachegrind, Webgrind, etc.
●
    PHP – XHProf
●
    JavaScript – Firebug
●
    JavaScript – Venkman

●
    General page display - YSlow
Profiling
●
    CPU Load – top & /proc/loadavg
Profiling
●
    CPU Load – top & /proc/loadavg
●
    Disk IO – iotop
Profiling
●
    CPU Load – top & /proc/loadavg
●
    Disk IO – iotop
●
    Memory – free
Profiling
●
    CPU Load – top & /proc/loadavg
●
    Disk IO – iotop
●
    Memory – free
●
    Network – netstat
Profiling
●
    CPU Load – top & /proc/loadavg
●
    Disk IO – iotop
●
    Memory – free
●
    Network – netstat

●
    Monitoring – watch & time
Profiling under load
Profiling under load
          ●
              Code bottlenecks !=
              Platform bottlenecks
Profiling under load
          ●
              Code bottlenecks !=
              Platform bottlenecks
          ●
              Test in production,
              if possible
Profiling under load
          ●
              Code bottlenecks !=
              Platform bottlenecks
          ●
              Test in production,
              if possible
          ●
              Use multiple VMs
              (Vagrant can help
              automate this)
Profiling under load
          ●
              Code bottlenecks !=
              Platform bottlenecks
          ●
              Test in production,
              if possible
          ●
              Use multiple VMs
              (Vagrant can help
              automate this)
          ●
              Use siege & ab
Finding bottlenecks
Finding bottlenecks
Right           Wrong
Finding bottlenecks
          Right           Wrong
●
    Database
Finding bottlenecks
              Right           Wrong
●
    Database
●
    Disk IO
Finding bottlenecks
              Right           Wrong
●
    Database
●
    Disk IO
●
    External services
Finding bottlenecks
              Right           Wrong
●
    Database
●
    Disk IO
●
    External services
●
    Application work
Finding bottlenecks
              Right               Wrong
●
    Database            ●
                            Autoloaders
●
    Disk IO
●
    External services
●
    Application work
Finding bottlenecks
              Right                Wrong
●
    Database            ●
                            Autoloaders
●
    Disk IO             ●
                            Config files
●
    External services
●
    Application work
Finding bottlenecks
              Right                Wrong
●
    Database            ●
                            Autoloaders
●
    Disk IO             ●
                            Config files
●
    External services   ●
                            Logging
●
    Application work
Finding bottlenecks
              Right                Wrong
●
    Database            ●
                            Autoloaders
●
    Disk IO             ●
                            Config files
●
    External services   ●
                            Logging
●
    Application work    ●
                            Object instantiation
Finding bottlenecks
              Right                Wrong
●
    Database            ●
                            Autoloaders
●
    Disk IO             ●
                            Config files
●
    External services   ●
                            Logging
●
    Application work    ●
                            Object instantiation
                        ●
                            Frameworks
Finding bottlenecks
              Right                   Wrong
●
    Database            ●
                            Autoloaders
●
    Disk IO             ●
                            Config files
●
    External services   ●
                            Logging
●
    Application work    ●
                            Object instantiation
                        ●
                            Frameworks
                            Ask Jo (@juokas)
                            about Doctrine!
Tell users it's slow
Tell users it's slow
          ●
              User experience !=
              Raw speed
Tell users it's slow
          ●
              User experience !=
              Raw speed
          ●
              Keep the UI
              responsive
Tell users it's slow
          ●
              User experience !=
              Raw speed
          ●
              Keep the UI
              responsive
          ●
              Set expectations
Tell users it's slow
          ●
              User experience !=
              Raw speed
          ●
              Keep the UI
              responsive
          ●
              Set expectations

          ●
              Adapt to changes
              (@blongden)
Fail gracefully
Fail gracefully
●
    Actively choose
    to time-out
Fail gracefully
●
    Actively choose
    to time-out
●
    Prioritise
    core/profitable
    functionality
Fail gracefully
●
    Actively choose
    to time-out
●
    Prioritise
    core/profitable
    functionality

●
    Have a
    BIG RED BUTTON
Separate functionality
Separate functionality
 Admin            Batch
Separate functionality
           Admin           Batch
●
    Different users ==
    diff. requirements
Separate functionality
           Admin           Batch
●
    Different users ==
    diff. requirements

●
    No cache
Separate functionality
           Admin           Batch
●
    Different users ==
    diff. requirements

●
    No cache
●
    “Master” storage
Separate functionality
           Admin           Batch
●
    Different users ==
    diff. requirements

●
    No cache
●
    “Master” storage

●
    Security
Separate functionality
           Admin                     Batch
●
    Different users ==   ●
                             Not time critical
    diff. requirements

●
    No cache
●
    “Master” storage

●
    Security
Separate functionality
           Admin                     Batch
●
    Different users ==   ●
                             Not time critical
    diff. requirements   ●
                             CPU/RAM hungry

●
    No cache
●
    “Master” storage

●
    Security
Separate functionality
           Admin                     Batch
●
    Different users ==   ●
                             Not time critical
    diff. requirements   ●
                             CPU/RAM hungry

●
    No cache             ●
                             nice / ionice
●
    “Master” storage

●
    Security
Separate functionality
           Admin                     Batch
●
    Different users ==   ●
                             Not time critical
    diff. requirements   ●
                             CPU/RAM hungry

●
    No cache             ●
                             nice / ionice
●
    “Master” storage     ●
                             Network rate limiting

●
    Security
Separate functionality
           Admin                     Batch
●
    Different users ==   ●
                             Not time critical
    diff. requirements   ●
                             CPU/RAM hungry

●
    No cache             ●
                             nice / ionice
●
    “Master” storage     ●
                             Network rate limiting

●
    Security             ●
                             Read only?
Configure hardware correctly
Configure hardware correctly
              ●
                  What is required for
                  1 request?
Configure hardware correctly
              ●
                  What is required for
                  1 request?
              ●
                  How many
                  concurrent requests?
Configure hardware correctly
              ●
                  What is required for
                  1 request?
              ●
                  How many
                  concurrent requests?

              ●
                  Is it a linear scale?
Configure hardware correctly
              ●
                  What is required for
                  1 request?
              ●
                  How many
                  concurrent requests?

              ●
                  Is it a linear scale?

              ●
                  Ask your
                  hosting company
Aim for services
Aim for services
Obey the “Law of Demeter”
Obey the “Law of Demeter”
●
    Talk to your friends,
    don't talk to
    strangers
Obey the “Law of Demeter”
●
    Talk to your friends,
    don't talk to
    strangers

●
    Promotes
    loose coupling
Obey the “Law of Demeter”
           Good




           Bad
Obey the “Law of Demeter”
                       Good
●   $person->requestPayment($amount);



                       Bad
Obey the “Law of Demeter”
                       Good
●   $person->requestPayment($amount);



                        Bad
●
    $wallet = $person->getWallet();
●
    $wallet->getMoney($amount);
Obey the “Law of Demeter”
           Good




           Bad
Obey the “Law of Demeter”
           Good




           Bad
Obey the “Law of Demeter”
           Good




           Bad
Create immutable objects
Create immutable objects
●
    Objects that cannot change after creation
Create immutable objects
●
    Objects that cannot change after creation
●
    Copy On Write (COW - � ← unicode cow)
Create immutable objects
●
    Objects that cannot change after creation
●
    Copy On Write (COW - � ← unicode cow)
●
    More memory-hungry, but easy to roll back
Create immutable objects
●
    Objects that cannot change after creation
●
    Copy On Write (COW - � ← unicode cow)
●
    More memory-hungry, but easy to roll back
●
    Value objects should be immutable
Create immutable objects
●
    Objects that cannot change after creation
●
    Copy On Write (COW - � ← unicode cow)
●
    More memory-hungry, but easy to roll back
●
    Value objects should be immutable

●
    Think of them like a response from a service
Identify “single server” factors
Identify “single server” factors
●
    File uploads / user content
Identify “single server” factors
●
    File uploads / user content
●
    IP restrictions / server access
Identify “single server” factors
●
    File uploads / user content
●
    IP restrictions / server access
●
    Licensing?
Create services
Create services
Your API should be:
Create services
    Your API should be:
●
    Independent of
    application state
Create services
    Your API should be:
●
    Independent of
    application state
●
    Loosely coupled
Create services
    Your API should be:
●
    Independent of
    application state
●
    Loosely coupled
●
    Accepting/returning
    immutable objects
Use caches
Use caches
     ●
         REST-ful services
         over HTTP let you
         cache easily
Use caches
     ●
         REST-ful services
         over HTTP let you
         cache easily
     ●
         Internal caching is
         trickier, but “out-of-
         the-box” with most
         frameworks
Use caches
                            ●
                                REST-ful services
                                over HTTP let you
                                cache easily
                            ●
                                Internal caching is
                                trickier, but “out-of-
                                the-box” with most
                                frameworks



Proxy other people's services through your own cache!
Use queues
Use queues
●
    Full blown job server:
    Gearman
Use queues
●
    Full blown job server:
    Gearman
●
    AMQP
    implementation:
    RabbitMQ
Use queues
●
    Full blown job server:
    Gearman
●
    AMQP
    implementation:
    RabbitMQ
●
    Light-weight sockets:
    0MQ
Use the right storage
Use the right storage
Use the right storage

           Consistency    Availability




                  Partitioning
Use the right storage

           Consistency            Availability




          Enforced consistency   Eventual consistency
                (RDBMS)               (NoSQL)


                       Partitioning
Scale your storage
Scale your storage
●
    Master/slave
    replication
Scale your storage
●
    Master/slave
    replication
●
    Table partitioning
Scale your storage
●
    Master/slave
    replication
●
    Table partitioning
●
    Row partitioning
Scale your storage
●
    Master/slave
    replication
●
    Table partitioning
●
    Row partitioning

●
    rsync
Scale your storage
●
    Master/slave
    replication
●
    Table partitioning
●
    Row partitioning

●
    rsync
●
    NFS
Scale your storage
●
    Master/slave
    replication
●
    Table partitioning
●
    Row partitioning

●
    rsync
●
    NFS
●
    GlusterFS
Now you can use the cloud
Now you can use the cloud
●
    Full service –
    orchestra.io
Now you can use the cloud
●
    Full service
    orchestra.io
●
    Infrastructure mgmt.
    Scalr
Now you can use the cloud
●
    Full service
    orchestra.io
●
    Infrastructure mgmt.
    Scalr
●
    Manually
    $your_code_here
Now you can use the cloud
●
    Full service
    orchestra.io
●
    Infrastructure mgmt.
    Scalr
●
    Manually
    $your_code_here

●
    Automate!
    Chef & Puppet
Review
Review
   ●
       Start with only what
       you need
Review
   ●
       Start with only what
       you need
   ●
       Identify the
       problems
Review
   ●
       Start with only what
       you need
   ●
       Identify the
       problems
   ●
       Pull the problem out
       to a service
Review
   ●
       Start with only what
       you need
   ●
       Identify the
       problems
   ●
       Pull the problem out
       to a service
   ●
       Distribute
Thank you!
●   Feedback:

    http://joind.in/6324



●   Photos & Transformers:
    Nina Merewood
●   Legal?
    Takara & Hasbro
●   ElePHPant smuggling:
    Johannes Schlüter (@phperror)
●   Vintage photo nonsense:
    http://pixlr.com/o-matic/

Sensible scaling

  • 1.
    Sensible Scaling Rowan Merewood
  • 2.
    Sensible Scaling “If your application doesn't scale, it's your fault not mine.” – Rasmus Lerdorf (@rasmus) Rowan Merewood
  • 3.
  • 4.
    Who? ● @rowan_m
  • 5.
    Who? ● @rowan_m ● Software Engineer & Team Lead
  • 6.
    Who? ● @rowan_m ● Software Engineer & Team Lead ● @ibuildings & @techportal
  • 7.
  • 8.
    Why? ● I've built small apps
  • 9.
    Why? ● I've built small apps ● and pretty large ones
  • 10.
    Why? ● I've built small apps ● and pretty large ones ● I've seen massive over-engineering
  • 11.
    Why? ● I've built small apps ● and pretty large ones ● I've seen massive over-engineering ● and platforms that cannot scale
  • 12.
  • 13.
    TDD Principles ● Write only enough code to pass the test
  • 14.
    TDD Principles ● Write only enough code to pass the test ● Do not over-engineer
  • 15.
    TDD Principles ● Write only enough code to pass the test ● Do not over-engineer ● Don't give away work for free!
  • 16.
  • 17.
    Build for now ● Don't be afraid to throw code away
  • 18.
    Build for now ● Don't be afraid to throw code away ● XP's spikes
  • 19.
    Build for now ● Don't be afraid to throw code away ● XP's spikes ● Take advantage of current tech. without tying yourself to it
  • 20.
  • 21.
    Who are yourusers? ● Lots of short visits?
  • 22.
    Who are yourusers? ● Lots of short visits? ● Anonymous or session-based?
  • 23.
    Who are yourusers? ● Lots of short visits? ● Anonymous or session-based? ● Long, complex interactions?
  • 24.
    Who are yourusers? ● Lots of short visits? ● Anonymous or session-based? ● Long, complex interactions? ● Subscribers or free users?
  • 25.
  • 26.
    Monitor and Analyse ● Predict usage patterns http://community.plus.net/blog/2011/10/24/a-record-setting-manchester-derby/
  • 27.
    Monitor and Analyse ● Predict usage patterns ● Plan for peaks and troughs http://community.plus.net/blog/2011/10/24/a-record-setting-manchester-derby/
  • 28.
  • 29.
    Profiling ● You do not know what is slow
  • 30.
    Profiling ● You do not know what is slow ● Ensure you measure more than just code!
  • 31.
  • 32.
    Profiling ● PHP - Xdebug – Derick Rethans (@derickr) ● Kcachegrind, Webgrind, etc.
  • 33.
    Profiling ● PHP - Xdebug – Derick Rethans (@derickr) ● Kcachegrind, Webgrind, etc. ● PHP – XHProf
  • 34.
    Profiling ● PHP - Xdebug – Derick Rethans (@derickr) ● Kcachegrind, Webgrind, etc. ● PHP – XHProf ● JavaScript – Firebug
  • 35.
    Profiling ● PHP - Xdebug – Derick Rethans (@derickr) ● Kcachegrind, Webgrind, etc. ● PHP – XHProf ● JavaScript – Firebug ● JavaScript – Venkman
  • 36.
    Profiling ● PHP - Xdebug – Derick Rethans (@derickr) ● Kcachegrind, Webgrind, etc. ● PHP – XHProf ● JavaScript – Firebug ● JavaScript – Venkman ● General page display - YSlow
  • 37.
    Profiling ● CPU Load – top & /proc/loadavg
  • 38.
    Profiling ● CPU Load – top & /proc/loadavg ● Disk IO – iotop
  • 39.
    Profiling ● CPU Load – top & /proc/loadavg ● Disk IO – iotop ● Memory – free
  • 40.
    Profiling ● CPU Load – top & /proc/loadavg ● Disk IO – iotop ● Memory – free ● Network – netstat
  • 41.
    Profiling ● CPU Load – top & /proc/loadavg ● Disk IO – iotop ● Memory – free ● Network – netstat ● Monitoring – watch & time
  • 42.
  • 43.
    Profiling under load ● Code bottlenecks != Platform bottlenecks
  • 44.
    Profiling under load ● Code bottlenecks != Platform bottlenecks ● Test in production, if possible
  • 45.
    Profiling under load ● Code bottlenecks != Platform bottlenecks ● Test in production, if possible ● Use multiple VMs (Vagrant can help automate this)
  • 46.
    Profiling under load ● Code bottlenecks != Platform bottlenecks ● Test in production, if possible ● Use multiple VMs (Vagrant can help automate this) ● Use siege & ab
  • 47.
  • 48.
  • 49.
    Finding bottlenecks Right Wrong ● Database
  • 50.
    Finding bottlenecks Right Wrong ● Database ● Disk IO
  • 51.
    Finding bottlenecks Right Wrong ● Database ● Disk IO ● External services
  • 52.
    Finding bottlenecks Right Wrong ● Database ● Disk IO ● External services ● Application work
  • 53.
    Finding bottlenecks Right Wrong ● Database ● Autoloaders ● Disk IO ● External services ● Application work
  • 54.
    Finding bottlenecks Right Wrong ● Database ● Autoloaders ● Disk IO ● Config files ● External services ● Application work
  • 55.
    Finding bottlenecks Right Wrong ● Database ● Autoloaders ● Disk IO ● Config files ● External services ● Logging ● Application work
  • 56.
    Finding bottlenecks Right Wrong ● Database ● Autoloaders ● Disk IO ● Config files ● External services ● Logging ● Application work ● Object instantiation
  • 57.
    Finding bottlenecks Right Wrong ● Database ● Autoloaders ● Disk IO ● Config files ● External services ● Logging ● Application work ● Object instantiation ● Frameworks
  • 58.
    Finding bottlenecks Right Wrong ● Database ● Autoloaders ● Disk IO ● Config files ● External services ● Logging ● Application work ● Object instantiation ● Frameworks Ask Jo (@juokas) about Doctrine!
  • 59.
  • 60.
    Tell users it'sslow ● User experience != Raw speed
  • 61.
    Tell users it'sslow ● User experience != Raw speed ● Keep the UI responsive
  • 62.
    Tell users it'sslow ● User experience != Raw speed ● Keep the UI responsive ● Set expectations
  • 63.
    Tell users it'sslow ● User experience != Raw speed ● Keep the UI responsive ● Set expectations ● Adapt to changes (@blongden)
  • 64.
  • 65.
    Fail gracefully ● Actively choose to time-out
  • 66.
    Fail gracefully ● Actively choose to time-out ● Prioritise core/profitable functionality
  • 67.
    Fail gracefully ● Actively choose to time-out ● Prioritise core/profitable functionality ● Have a BIG RED BUTTON
  • 68.
  • 69.
  • 70.
    Separate functionality Admin Batch ● Different users == diff. requirements
  • 71.
    Separate functionality Admin Batch ● Different users == diff. requirements ● No cache
  • 72.
    Separate functionality Admin Batch ● Different users == diff. requirements ● No cache ● “Master” storage
  • 73.
    Separate functionality Admin Batch ● Different users == diff. requirements ● No cache ● “Master” storage ● Security
  • 74.
    Separate functionality Admin Batch ● Different users == ● Not time critical diff. requirements ● No cache ● “Master” storage ● Security
  • 75.
    Separate functionality Admin Batch ● Different users == ● Not time critical diff. requirements ● CPU/RAM hungry ● No cache ● “Master” storage ● Security
  • 76.
    Separate functionality Admin Batch ● Different users == ● Not time critical diff. requirements ● CPU/RAM hungry ● No cache ● nice / ionice ● “Master” storage ● Security
  • 77.
    Separate functionality Admin Batch ● Different users == ● Not time critical diff. requirements ● CPU/RAM hungry ● No cache ● nice / ionice ● “Master” storage ● Network rate limiting ● Security
  • 78.
    Separate functionality Admin Batch ● Different users == ● Not time critical diff. requirements ● CPU/RAM hungry ● No cache ● nice / ionice ● “Master” storage ● Network rate limiting ● Security ● Read only?
  • 79.
  • 80.
    Configure hardware correctly ● What is required for 1 request?
  • 81.
    Configure hardware correctly ● What is required for 1 request? ● How many concurrent requests?
  • 82.
    Configure hardware correctly ● What is required for 1 request? ● How many concurrent requests? ● Is it a linear scale?
  • 83.
    Configure hardware correctly ● What is required for 1 request? ● How many concurrent requests? ● Is it a linear scale? ● Ask your hosting company
  • 84.
  • 85.
  • 86.
    Obey the “Lawof Demeter”
  • 87.
    Obey the “Lawof Demeter” ● Talk to your friends, don't talk to strangers
  • 88.
    Obey the “Lawof Demeter” ● Talk to your friends, don't talk to strangers ● Promotes loose coupling
  • 89.
    Obey the “Lawof Demeter” Good Bad
  • 90.
    Obey the “Lawof Demeter” Good ● $person->requestPayment($amount); Bad
  • 91.
    Obey the “Lawof Demeter” Good ● $person->requestPayment($amount); Bad ● $wallet = $person->getWallet(); ● $wallet->getMoney($amount);
  • 92.
    Obey the “Lawof Demeter” Good Bad
  • 93.
    Obey the “Lawof Demeter” Good Bad
  • 94.
    Obey the “Lawof Demeter” Good Bad
  • 95.
  • 96.
    Create immutable objects ● Objects that cannot change after creation
  • 97.
    Create immutable objects ● Objects that cannot change after creation ● Copy On Write (COW - � ← unicode cow)
  • 98.
    Create immutable objects ● Objects that cannot change after creation ● Copy On Write (COW - � ← unicode cow) ● More memory-hungry, but easy to roll back
  • 99.
    Create immutable objects ● Objects that cannot change after creation ● Copy On Write (COW - � ← unicode cow) ● More memory-hungry, but easy to roll back ● Value objects should be immutable
  • 100.
    Create immutable objects ● Objects that cannot change after creation ● Copy On Write (COW - � ← unicode cow) ● More memory-hungry, but easy to roll back ● Value objects should be immutable ● Think of them like a response from a service
  • 101.
  • 102.
    Identify “single server”factors ● File uploads / user content
  • 103.
    Identify “single server”factors ● File uploads / user content ● IP restrictions / server access
  • 104.
    Identify “single server”factors ● File uploads / user content ● IP restrictions / server access ● Licensing?
  • 105.
  • 106.
  • 107.
    Create services Your API should be: ● Independent of application state
  • 108.
    Create services Your API should be: ● Independent of application state ● Loosely coupled
  • 109.
    Create services Your API should be: ● Independent of application state ● Loosely coupled ● Accepting/returning immutable objects
  • 110.
  • 111.
    Use caches ● REST-ful services over HTTP let you cache easily
  • 112.
    Use caches ● REST-ful services over HTTP let you cache easily ● Internal caching is trickier, but “out-of- the-box” with most frameworks
  • 113.
    Use caches ● REST-ful services over HTTP let you cache easily ● Internal caching is trickier, but “out-of- the-box” with most frameworks Proxy other people's services through your own cache!
  • 114.
  • 115.
    Use queues ● Full blown job server: Gearman
  • 116.
    Use queues ● Full blown job server: Gearman ● AMQP implementation: RabbitMQ
  • 117.
    Use queues ● Full blown job server: Gearman ● AMQP implementation: RabbitMQ ● Light-weight sockets: 0MQ
  • 118.
  • 119.
  • 120.
    Use the rightstorage Consistency Availability Partitioning
  • 121.
    Use the rightstorage Consistency Availability Enforced consistency Eventual consistency (RDBMS) (NoSQL) Partitioning
  • 122.
  • 123.
    Scale your storage ● Master/slave replication
  • 124.
    Scale your storage ● Master/slave replication ● Table partitioning
  • 125.
    Scale your storage ● Master/slave replication ● Table partitioning ● Row partitioning
  • 126.
    Scale your storage ● Master/slave replication ● Table partitioning ● Row partitioning ● rsync
  • 127.
    Scale your storage ● Master/slave replication ● Table partitioning ● Row partitioning ● rsync ● NFS
  • 128.
    Scale your storage ● Master/slave replication ● Table partitioning ● Row partitioning ● rsync ● NFS ● GlusterFS
  • 129.
    Now you canuse the cloud
  • 130.
    Now you canuse the cloud ● Full service – orchestra.io
  • 131.
    Now you canuse the cloud ● Full service orchestra.io ● Infrastructure mgmt. Scalr
  • 132.
    Now you canuse the cloud ● Full service orchestra.io ● Infrastructure mgmt. Scalr ● Manually $your_code_here
  • 133.
    Now you canuse the cloud ● Full service orchestra.io ● Infrastructure mgmt. Scalr ● Manually $your_code_here ● Automate! Chef & Puppet
  • 134.
  • 135.
    Review ● Start with only what you need
  • 136.
    Review ● Start with only what you need ● Identify the problems
  • 137.
    Review ● Start with only what you need ● Identify the problems ● Pull the problem out to a service
  • 138.
    Review ● Start with only what you need ● Identify the problems ● Pull the problem out to a service ● Distribute
  • 139.
    Thank you! ● Feedback: http://joind.in/6324 ● Photos & Transformers: Nina Merewood ● Legal? Takara & Hasbro ● ElePHPant smuggling: Johannes Schlüter (@phperror) ● Vintage photo nonsense: http://pixlr.com/o-matic/