SlideShare ist ein Scribd-Unternehmen logo
1 von 33
Web frameworks don't matter
   Web frameworks don't matter




    Web frameworks don’t
           matter.
Some tips, tricks and patterns for designing, scaling and
       maintaining large scale web applications.

                                 Tomas (t0m) Doran

                                 Nordic perl Workshop 2010
                                 São Paulo.pm perl workshop 2010
Introduction
• t0m - Catalyst core team. Moose
  committer. 99 CPAN dists. Silly hair. Idiot ;)
• This is a rant talk about (web) application
  design.
• You get to listen to 3 hours of this today.
  (Sorry about that)
• Please stop me, ask questions, disagree etc.
  (It’ll be more fun, for all of us)
Application design

• Is hard!
• You won’t get it all right first time.
• The web parts are not the main parts
• Yes, even in a web application
Success
• You need to be flexible, requirements will
  change.
• You need to be flexible, your planned
  solutions won’t work
• You need to be flexible, the performance
  inflection points won’t be where you
  predict
Getting the data model right

   • Hint - You won’t..
   • Consistency is the key
   • KISS
   • No broken windows
Getting the data model right

   • You need a consistent and standalone
     model of your application
   • Routing URIs to actions isn’t a hard
     problem
   • Keeping the data from becoming a pile of
     shit is a hard problem
Loosely
              coupled

• You will throw parts of your codebase away
• Components can be tested / replaced
  independently
• Dependency injection
Dependency Injection
Dependency Injection
• Any of the components can be faked /
  mocked / replaced
• Testing becomes much easier (having a test
  MogileFS is a pain in the ass, really!)
• Write factories to build instances so
  dependency injection doesn’t cost.
• Bread::Board?
Efficiency

• Web stuff should be fast!
• Doing extra work on your web servers is
  bad news
• Lots of web processes probably not what
  you want
The PHP fallacy
 Even if extra context switching has zero overhead
       you serve people sooner if you queue.

    A     B       A   B     A     B       A   B

              A                       B


A finishes significantly before B in the lower diagram

        B finishes at the same time in both
Caching strategies

• Page fragments
• Objects and data structures
• Varnish/ESI, mod_cache/SSI
• memcached
• Materialized views (triggers!)
Simple web
 architecture
                                      Load balancer



                                Web server Web server
                                 Web server Web server
                                   Web server Web server
This is how you start and how
most people think about a web
          architecture
                                     Data store
Add a reverse
   proxy                                 Load balancer




                                        Reverse proxy



 Your users are not on a Gb/s      Web server Web server
             pipe.                  Web server Web server
                                      Web server Web server


  Don’t keep your expensive
application processes in IO wait
          sending bytes
                                        Data store
Cache
    expensive                          Load balancer

     lookups
                                      Reverse proxy



Memcache shown here, but this    Web server Web server      Memcache
                                  Web server Web server
   isn’t the only strategy          Web server Web server   Memcache


Materialized views in the data
store layer - denormalisation
      without the pain.
                                      Data store
Using a page
 assembly layer                             PAL




                                        Reverse proxy



                                    Web server Web server      Memcache

   Allows different chunks of        Web server Web server
                                       Web server Web server   Memcache
content to have different caching
           strategies.

Cache even authenticated users           Data store
          (mostly)
Complex
    web
architecture
                                                 PAL




                                             Reverse proxy



                                         Web server Web server      Memcache
Anything that is going to   Message
                                          Web server Web server
                                            Web server Web server   Memcache
   block is run as an        Queue


   asynchronous job
                            Job Server

                                              Data store
Cache stampede!

• Cache flushes can become terminal to your
  application.
• You need to ensure you can avoid this (or
  at least know it’s there)
• Implement switches to ‘cool down’ your
  app
Development,
deployment and testing
• You must use version control
• You must have version numbers
• You must have package management
• You must have a stage environment
Development,
deployment and testing

• You need tests!
• Even if you’re not doing TDD!
• The most likely bug to have is one you
  already fixed once.
Development,
deployment and testing

• Everyone in your team needs to be able to
  do everything
• No superstars, being run over by a bus
  more likely than you think
Development,
deployment and testing

• Test plans
• A-B testing
• Customer driven testing and deployment
Development,
deployment and testing

• You need a rollback plan
• API versioning
• Data migrations - be careful!!
The Zen swap

• Migrating continually updated data around
  with no downtime
• E.g. moving Zen machines between hosts,
  moving database info around.
• For database, relies on triggers
The Zen swap

• Modify time column on ‘from’ table.
• Copy (and munge) all the data, row by row,
  noting when you start
• Copy (and munge) all the data changed
  since you started
• Repeat until the set of dirty data is very
  small
The Zen swap
Old New   Old New   Old New   Old New
The Zen swap
• Stop the universe
• Do one final pass of the data
• Add triggers for reads/writes in the old
  column to use the new column
• Start the universe
• Needs transactional DDL to be seamless
• Even without, use to minimise downtime
Accidental complexity
• Premature generalisation is the root of all
  evil.
• Lack of polymorphism
• Insufficient use of delegation
• Commonality develops independently.You
  MUST refactor
Load and scalability
         testing
• Simple ab can tell you a lot
• NYTProf
• You need to test your system with your
  hardware and your data
• A little tuning can go a long way.
Health monitoring
• Log useful stuff from your app!
• Syslog
• Nagios
• Healthcheck pages
• Munin
• Splunk
Performance
          monitoring

• Per hit stats (db queries, memcache hits,
  times taken)
• Query comments
• Graphs are awesome (RRD is kinda hateful)
Conclusion

• Components rule!
• Expect change.
• Enforce consistency.
Thanks!

• Slides will be on slideshare later
• I can (and probably will) rant at length
  about any of this if you buy me a beer ;)
• Questions?

Weitere ähnliche Inhalte

Was ist angesagt?

Can you contain the future - Docker, Container Technologies, The Future, and You
Can you contain the future - Docker, Container Technologies, The Future, and YouCan you contain the future - Docker, Container Technologies, The Future, and You
Can you contain the future - Docker, Container Technologies, The Future, and YouColdFusionConference
 
The State of WebSockets in Django
The State of WebSockets in DjangoThe State of WebSockets in Django
The State of WebSockets in DjangoRami Sayar
 
Deploying Symfony | symfony.cat
Deploying Symfony | symfony.catDeploying Symfony | symfony.cat
Deploying Symfony | symfony.catPablo Godel
 
DevOps tools for everyone - Vagrant, Puppet and Webmin
DevOps tools for everyone - Vagrant, Puppet and WebminDevOps tools for everyone - Vagrant, Puppet and Webmin
DevOps tools for everyone - Vagrant, Puppet and Webminpostrational
 
Building a better web
Building a better webBuilding a better web
Building a better webFastly
 
ZendCon 2015 - Laravel Forge: Hello World to Hello Production
ZendCon 2015 - Laravel Forge: Hello World to Hello ProductionZendCon 2015 - Laravel Forge: Hello World to Hello Production
ZendCon 2015 - Laravel Forge: Hello World to Hello ProductionJoe Ferguson
 
Mitigating Security Threats with Fastly - Joe Williams at Fastly Altitude 2015
Mitigating Security Threats with Fastly - Joe Williams at Fastly Altitude 2015Mitigating Security Threats with Fastly - Joe Williams at Fastly Altitude 2015
Mitigating Security Threats with Fastly - Joe Williams at Fastly Altitude 2015Fastly
 
How do I Write Testable Javascript so I can Test my CF API on Server and Client
How do I Write Testable Javascript so I can Test my CF API on Server and ClientHow do I Write Testable Javascript so I can Test my CF API on Server and Client
How do I Write Testable Javascript so I can Test my CF API on Server and ClientColdFusionConference
 
Hack & Fix, Hands on ColdFusion Security Training
Hack & Fix, Hands on ColdFusion Security TrainingHack & Fix, Hands on ColdFusion Security Training
Hack & Fix, Hands on ColdFusion Security TrainingColdFusionConference
 
Single page apps with drupal 7
Single page apps with drupal 7Single page apps with drupal 7
Single page apps with drupal 7Chris Tankersley
 
My Database Skills Killed the Server
My Database Skills Killed the ServerMy Database Skills Killed the Server
My Database Skills Killed the ServerColdFusionConference
 
Advanced Caching Concepts @ Velocity NY 2015
Advanced Caching Concepts @ Velocity NY 2015Advanced Caching Concepts @ Velocity NY 2015
Advanced Caching Concepts @ Velocity NY 2015Rakesh Chaudhary
 
SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps
SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony AppsSymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps
SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony AppsPablo Godel
 
Converting Your Dev Environment to a Docker Stack - Cascadia
Converting Your Dev Environment to a Docker Stack - CascadiaConverting Your Dev Environment to a Docker Stack - Cascadia
Converting Your Dev Environment to a Docker Stack - CascadiaDana Luther
 
Converting Your Dev Environment to a Docker Stack - php[world]
Converting Your Dev Environment to a Docker Stack - php[world]Converting Your Dev Environment to a Docker Stack - php[world]
Converting Your Dev Environment to a Docker Stack - php[world]Dana Luther
 
Apache HTTPD 2.4 Reverse Proxy: The Hidden Gem
Apache HTTPD 2.4 Reverse Proxy: The Hidden GemApache HTTPD 2.4 Reverse Proxy: The Hidden Gem
Apache HTTPD 2.4 Reverse Proxy: The Hidden GemJim Jagielski
 
Ruby in the Browser - RubyConf 2011
Ruby in the Browser - RubyConf 2011Ruby in the Browser - RubyConf 2011
Ruby in the Browser - RubyConf 2011Ilya Grigorik
 

Was ist angesagt? (20)

Can you contain the future - Docker, Container Technologies, The Future, and You
Can you contain the future - Docker, Container Technologies, The Future, and YouCan you contain the future - Docker, Container Technologies, The Future, and You
Can you contain the future - Docker, Container Technologies, The Future, and You
 
The State of WebSockets in Django
The State of WebSockets in DjangoThe State of WebSockets in Django
The State of WebSockets in Django
 
Deploying Symfony | symfony.cat
Deploying Symfony | symfony.catDeploying Symfony | symfony.cat
Deploying Symfony | symfony.cat
 
DevOps tools for everyone - Vagrant, Puppet and Webmin
DevOps tools for everyone - Vagrant, Puppet and WebminDevOps tools for everyone - Vagrant, Puppet and Webmin
DevOps tools for everyone - Vagrant, Puppet and Webmin
 
Building a better web
Building a better webBuilding a better web
Building a better web
 
ZendCon 2015 - Laravel Forge: Hello World to Hello Production
ZendCon 2015 - Laravel Forge: Hello World to Hello ProductionZendCon 2015 - Laravel Forge: Hello World to Hello Production
ZendCon 2015 - Laravel Forge: Hello World to Hello Production
 
Mitigating Security Threats with Fastly - Joe Williams at Fastly Altitude 2015
Mitigating Security Threats with Fastly - Joe Williams at Fastly Altitude 2015Mitigating Security Threats with Fastly - Joe Williams at Fastly Altitude 2015
Mitigating Security Threats with Fastly - Joe Williams at Fastly Altitude 2015
 
Web Leaps Forward
Web Leaps ForwardWeb Leaps Forward
Web Leaps Forward
 
How do I Write Testable Javascript so I can Test my CF API on Server and Client
How do I Write Testable Javascript so I can Test my CF API on Server and ClientHow do I Write Testable Javascript so I can Test my CF API on Server and Client
How do I Write Testable Javascript so I can Test my CF API on Server and Client
 
Hack & Fix, Hands on ColdFusion Security Training
Hack & Fix, Hands on ColdFusion Security TrainingHack & Fix, Hands on ColdFusion Security Training
Hack & Fix, Hands on ColdFusion Security Training
 
Single page apps with drupal 7
Single page apps with drupal 7Single page apps with drupal 7
Single page apps with drupal 7
 
My Database Skills Killed the Server
My Database Skills Killed the ServerMy Database Skills Killed the Server
My Database Skills Killed the Server
 
Advanced Caching Concepts @ Velocity NY 2015
Advanced Caching Concepts @ Velocity NY 2015Advanced Caching Concepts @ Velocity NY 2015
Advanced Caching Concepts @ Velocity NY 2015
 
Cfml features modern_coding
Cfml features modern_codingCfml features modern_coding
Cfml features modern_coding
 
SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps
SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony AppsSymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps
SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps
 
Converting Your Dev Environment to a Docker Stack - Cascadia
Converting Your Dev Environment to a Docker Stack - CascadiaConverting Your Dev Environment to a Docker Stack - Cascadia
Converting Your Dev Environment to a Docker Stack - Cascadia
 
Scaling Django
Scaling DjangoScaling Django
Scaling Django
 
Converting Your Dev Environment to a Docker Stack - php[world]
Converting Your Dev Environment to a Docker Stack - php[world]Converting Your Dev Environment to a Docker Stack - php[world]
Converting Your Dev Environment to a Docker Stack - php[world]
 
Apache HTTPD 2.4 Reverse Proxy: The Hidden Gem
Apache HTTPD 2.4 Reverse Proxy: The Hidden GemApache HTTPD 2.4 Reverse Proxy: The Hidden Gem
Apache HTTPD 2.4 Reverse Proxy: The Hidden Gem
 
Ruby in the Browser - RubyConf 2011
Ruby in the Browser - RubyConf 2011Ruby in the Browser - RubyConf 2011
Ruby in the Browser - RubyConf 2011
 

Ähnlich wie Web frameworks don't matter

Virtualizing Tier One Applications - Varrow
Virtualizing Tier One Applications - VarrowVirtualizing Tier One Applications - Varrow
Virtualizing Tier One Applications - VarrowAndrew Miller
 
Mobile gotcha
Mobile gotchaMobile gotcha
Mobile gotchaphegaro
 
Store
StoreStore
StoreESUG
 
Varrow Q4 Lunch & Learn Presentation - Virtualizing Business Critical Applica...
Varrow Q4 Lunch & Learn Presentation - Virtualizing Business Critical Applica...Varrow Q4 Lunch & Learn Presentation - Virtualizing Business Critical Applica...
Varrow Q4 Lunch & Learn Presentation - Virtualizing Business Critical Applica...Andrew Miller
 
Midwest PHP - Scaling Magento
Midwest PHP - Scaling MagentoMidwest PHP - Scaling Magento
Midwest PHP - Scaling MagentoMathew Beane
 
Succeding with the Apache SOA stack
Succeding with the Apache SOA stackSucceding with the Apache SOA stack
Succeding with the Apache SOA stackJohan Edstrom
 
Building Real World Applications using Windows Azure - Scott Guthrie, 2nd Dec...
Building Real World Applications using Windows Azure - Scott Guthrie, 2nd Dec...Building Real World Applications using Windows Azure - Scott Guthrie, 2nd Dec...
Building Real World Applications using Windows Azure - Scott Guthrie, 2nd Dec...Vikas Sahni
 
Building azure applications ireland
Building azure applications irelandBuilding azure applications ireland
Building azure applications irelandMichael Meagher
 
Super Sizing Youtube with Python
Super Sizing Youtube with PythonSuper Sizing Youtube with Python
Super Sizing Youtube with Pythondidip
 
Web20expo Scalable Web Arch
Web20expo Scalable Web ArchWeb20expo Scalable Web Arch
Web20expo Scalable Web Archroyans
 
Web20expo Scalable Web Arch
Web20expo Scalable Web ArchWeb20expo Scalable Web Arch
Web20expo Scalable Web Archguest18a0f1
 
Web20expo Scalable Web Arch
Web20expo Scalable Web ArchWeb20expo Scalable Web Arch
Web20expo Scalable Web Archmclee
 
The Future of Database Development
The Future of Database DevelopmentThe Future of Database Development
The Future of Database DevelopmentSteve Jones
 
Cloud Computing & Scaling Web Apps
Cloud Computing & Scaling Web AppsCloud Computing & Scaling Web Apps
Cloud Computing & Scaling Web AppsMark Slingsby
 
Custom coded projects
Custom coded projectsCustom coded projects
Custom coded projectsMarko Heijnen
 
Microservices for java architects it-symposium-2015-09-15
Microservices for java architects it-symposium-2015-09-15Microservices for java architects it-symposium-2015-09-15
Microservices for java architects it-symposium-2015-09-15Derek Ashmore
 
Cloud-native Data: Every Microservice Needs a Cache
Cloud-native Data: Every Microservice Needs a CacheCloud-native Data: Every Microservice Needs a Cache
Cloud-native Data: Every Microservice Needs a Cachecornelia davis
 

Ähnlich wie Web frameworks don't matter (20)

Virtualizing Tier One Applications - Varrow
Virtualizing Tier One Applications - VarrowVirtualizing Tier One Applications - Varrow
Virtualizing Tier One Applications - Varrow
 
Mobile gotcha
Mobile gotchaMobile gotcha
Mobile gotcha
 
Store
StoreStore
Store
 
Varrow Q4 Lunch & Learn Presentation - Virtualizing Business Critical Applica...
Varrow Q4 Lunch & Learn Presentation - Virtualizing Business Critical Applica...Varrow Q4 Lunch & Learn Presentation - Virtualizing Business Critical Applica...
Varrow Q4 Lunch & Learn Presentation - Virtualizing Business Critical Applica...
 
PaaS with Java
PaaS with JavaPaaS with Java
PaaS with Java
 
Midwest PHP - Scaling Magento
Midwest PHP - Scaling MagentoMidwest PHP - Scaling Magento
Midwest PHP - Scaling Magento
 
Succeding with the Apache SOA stack
Succeding with the Apache SOA stackSucceding with the Apache SOA stack
Succeding with the Apache SOA stack
 
Performance stack
Performance stackPerformance stack
Performance stack
 
Building Real World Applications using Windows Azure - Scott Guthrie, 2nd Dec...
Building Real World Applications using Windows Azure - Scott Guthrie, 2nd Dec...Building Real World Applications using Windows Azure - Scott Guthrie, 2nd Dec...
Building Real World Applications using Windows Azure - Scott Guthrie, 2nd Dec...
 
Building azure applications ireland
Building azure applications irelandBuilding azure applications ireland
Building azure applications ireland
 
Os Solomon
Os SolomonOs Solomon
Os Solomon
 
Super Sizing Youtube with Python
Super Sizing Youtube with PythonSuper Sizing Youtube with Python
Super Sizing Youtube with Python
 
Web20expo Scalable Web Arch
Web20expo Scalable Web ArchWeb20expo Scalable Web Arch
Web20expo Scalable Web Arch
 
Web20expo Scalable Web Arch
Web20expo Scalable Web ArchWeb20expo Scalable Web Arch
Web20expo Scalable Web Arch
 
Web20expo Scalable Web Arch
Web20expo Scalable Web ArchWeb20expo Scalable Web Arch
Web20expo Scalable Web Arch
 
The Future of Database Development
The Future of Database DevelopmentThe Future of Database Development
The Future of Database Development
 
Cloud Computing & Scaling Web Apps
Cloud Computing & Scaling Web AppsCloud Computing & Scaling Web Apps
Cloud Computing & Scaling Web Apps
 
Custom coded projects
Custom coded projectsCustom coded projects
Custom coded projects
 
Microservices for java architects it-symposium-2015-09-15
Microservices for java architects it-symposium-2015-09-15Microservices for java architects it-symposium-2015-09-15
Microservices for java architects it-symposium-2015-09-15
 
Cloud-native Data: Every Microservice Needs a Cache
Cloud-native Data: Every Microservice Needs a CacheCloud-native Data: Every Microservice Needs a Cache
Cloud-native Data: Every Microservice Needs a Cache
 

Mehr von Tomas Doran

Empowering developers to deploy their own data stores
Empowering developers to deploy their own data storesEmpowering developers to deploy their own data stores
Empowering developers to deploy their own data storesTomas Doran
 
Dockersh and a brief intro to the docker internals
Dockersh and a brief intro to the docker internalsDockersh and a brief intro to the docker internals
Dockersh and a brief intro to the docker internalsTomas Doran
 
Sensu and Sensibility - Puppetconf 2014
Sensu and Sensibility - Puppetconf 2014Sensu and Sensibility - Puppetconf 2014
Sensu and Sensibility - Puppetconf 2014Tomas Doran
 
Steamlining your puppet development workflow
Steamlining your puppet development workflowSteamlining your puppet development workflow
Steamlining your puppet development workflowTomas Doran
 
Building a smarter application stack - service discovery and wiring for Docker
Building a smarter application stack - service discovery and wiring for DockerBuilding a smarter application stack - service discovery and wiring for Docker
Building a smarter application stack - service discovery and wiring for DockerTomas Doran
 
Chasing AMI - Building Amazon machine images with Puppet, Packer and Jenkins
Chasing AMI - Building Amazon machine images with Puppet, Packer and JenkinsChasing AMI - Building Amazon machine images with Puppet, Packer and Jenkins
Chasing AMI - Building Amazon machine images with Puppet, Packer and JenkinsTomas Doran
 
Deploying puppet code at light speed
Deploying puppet code at light speedDeploying puppet code at light speed
Deploying puppet code at light speedTomas Doran
 
Thinking through puppet code layout
Thinking through puppet code layoutThinking through puppet code layout
Thinking through puppet code layoutTomas Doran
 
Docker puppetcamp london 2013
Docker puppetcamp london 2013Docker puppetcamp london 2013
Docker puppetcamp london 2013Tomas Doran
 
"The worst code I ever wrote"
"The worst code I ever wrote""The worst code I ever wrote"
"The worst code I ever wrote"Tomas Doran
 
Test driven infrastructure development (2 - puppetconf 2013 edition)
Test driven infrastructure development (2 - puppetconf 2013 edition)Test driven infrastructure development (2 - puppetconf 2013 edition)
Test driven infrastructure development (2 - puppetconf 2013 edition)Tomas Doran
 
Test driven infrastructure development
Test driven infrastructure developmentTest driven infrastructure development
Test driven infrastructure developmentTomas Doran
 
London devops - orc
London devops - orcLondon devops - orc
London devops - orcTomas Doran
 
London devops logging
London devops loggingLondon devops logging
London devops loggingTomas Doran
 
Message:Passing - lpw 2012
Message:Passing - lpw 2012Message:Passing - lpw 2012
Message:Passing - lpw 2012Tomas Doran
 
Webapp security testing
Webapp security testingWebapp security testing
Webapp security testingTomas Doran
 
Webapp security testing
Webapp security testingWebapp security testing
Webapp security testingTomas Doran
 
Dates aghhhh!!?!?!?!
Dates aghhhh!!?!?!?!Dates aghhhh!!?!?!?!
Dates aghhhh!!?!?!?!Tomas Doran
 
Messaging, interoperability and log aggregation - a new framework
Messaging, interoperability and log aggregation - a new frameworkMessaging, interoperability and log aggregation - a new framework
Messaging, interoperability and log aggregation - a new frameworkTomas Doran
 

Mehr von Tomas Doran (20)

Empowering developers to deploy their own data stores
Empowering developers to deploy their own data storesEmpowering developers to deploy their own data stores
Empowering developers to deploy their own data stores
 
Dockersh and a brief intro to the docker internals
Dockersh and a brief intro to the docker internalsDockersh and a brief intro to the docker internals
Dockersh and a brief intro to the docker internals
 
Sensu and Sensibility - Puppetconf 2014
Sensu and Sensibility - Puppetconf 2014Sensu and Sensibility - Puppetconf 2014
Sensu and Sensibility - Puppetconf 2014
 
Steamlining your puppet development workflow
Steamlining your puppet development workflowSteamlining your puppet development workflow
Steamlining your puppet development workflow
 
Building a smarter application stack - service discovery and wiring for Docker
Building a smarter application stack - service discovery and wiring for DockerBuilding a smarter application stack - service discovery and wiring for Docker
Building a smarter application stack - service discovery and wiring for Docker
 
Chasing AMI - Building Amazon machine images with Puppet, Packer and Jenkins
Chasing AMI - Building Amazon machine images with Puppet, Packer and JenkinsChasing AMI - Building Amazon machine images with Puppet, Packer and Jenkins
Chasing AMI - Building Amazon machine images with Puppet, Packer and Jenkins
 
Deploying puppet code at light speed
Deploying puppet code at light speedDeploying puppet code at light speed
Deploying puppet code at light speed
 
Thinking through puppet code layout
Thinking through puppet code layoutThinking through puppet code layout
Thinking through puppet code layout
 
Docker puppetcamp london 2013
Docker puppetcamp london 2013Docker puppetcamp london 2013
Docker puppetcamp london 2013
 
"The worst code I ever wrote"
"The worst code I ever wrote""The worst code I ever wrote"
"The worst code I ever wrote"
 
Test driven infrastructure development (2 - puppetconf 2013 edition)
Test driven infrastructure development (2 - puppetconf 2013 edition)Test driven infrastructure development (2 - puppetconf 2013 edition)
Test driven infrastructure development (2 - puppetconf 2013 edition)
 
Test driven infrastructure development
Test driven infrastructure developmentTest driven infrastructure development
Test driven infrastructure development
 
London devops - orc
London devops - orcLondon devops - orc
London devops - orc
 
London devops logging
London devops loggingLondon devops logging
London devops logging
 
Message:Passing - lpw 2012
Message:Passing - lpw 2012Message:Passing - lpw 2012
Message:Passing - lpw 2012
 
Webapp security testing
Webapp security testingWebapp security testing
Webapp security testing
 
Webapp security testing
Webapp security testingWebapp security testing
Webapp security testing
 
Dates aghhhh!!?!?!?!
Dates aghhhh!!?!?!?!Dates aghhhh!!?!?!?!
Dates aghhhh!!?!?!?!
 
Messaging, interoperability and log aggregation - a new framework
Messaging, interoperability and log aggregation - a new frameworkMessaging, interoperability and log aggregation - a new framework
Messaging, interoperability and log aggregation - a new framework
 
Zero mq logs
Zero mq logsZero mq logs
Zero mq logs
 

Web frameworks don't matter

  • 1. Web frameworks don't matter Web frameworks don't matter Web frameworks don’t matter. Some tips, tricks and patterns for designing, scaling and maintaining large scale web applications. Tomas (t0m) Doran Nordic perl Workshop 2010 São Paulo.pm perl workshop 2010
  • 2. Introduction • t0m - Catalyst core team. Moose committer. 99 CPAN dists. Silly hair. Idiot ;) • This is a rant talk about (web) application design. • You get to listen to 3 hours of this today. (Sorry about that) • Please stop me, ask questions, disagree etc. (It’ll be more fun, for all of us)
  • 3. Application design • Is hard! • You won’t get it all right first time. • The web parts are not the main parts • Yes, even in a web application
  • 4. Success • You need to be flexible, requirements will change. • You need to be flexible, your planned solutions won’t work • You need to be flexible, the performance inflection points won’t be where you predict
  • 5. Getting the data model right • Hint - You won’t.. • Consistency is the key • KISS • No broken windows
  • 6. Getting the data model right • You need a consistent and standalone model of your application • Routing URIs to actions isn’t a hard problem • Keeping the data from becoming a pile of shit is a hard problem
  • 7. Loosely coupled • You will throw parts of your codebase away • Components can be tested / replaced independently • Dependency injection
  • 9. Dependency Injection • Any of the components can be faked / mocked / replaced • Testing becomes much easier (having a test MogileFS is a pain in the ass, really!) • Write factories to build instances so dependency injection doesn’t cost. • Bread::Board?
  • 10. Efficiency • Web stuff should be fast! • Doing extra work on your web servers is bad news • Lots of web processes probably not what you want
  • 11. The PHP fallacy Even if extra context switching has zero overhead you serve people sooner if you queue. A B A B A B A B A B A finishes significantly before B in the lower diagram B finishes at the same time in both
  • 12. Caching strategies • Page fragments • Objects and data structures • Varnish/ESI, mod_cache/SSI • memcached • Materialized views (triggers!)
  • 13. Simple web architecture Load balancer Web server Web server Web server Web server Web server Web server This is how you start and how most people think about a web architecture Data store
  • 14. Add a reverse proxy Load balancer Reverse proxy Your users are not on a Gb/s Web server Web server pipe. Web server Web server Web server Web server Don’t keep your expensive application processes in IO wait sending bytes Data store
  • 15. Cache expensive Load balancer lookups Reverse proxy Memcache shown here, but this Web server Web server Memcache Web server Web server isn’t the only strategy Web server Web server Memcache Materialized views in the data store layer - denormalisation without the pain. Data store
  • 16. Using a page assembly layer PAL Reverse proxy Web server Web server Memcache Allows different chunks of Web server Web server Web server Web server Memcache content to have different caching strategies. Cache even authenticated users Data store (mostly)
  • 17. Complex web architecture PAL Reverse proxy Web server Web server Memcache Anything that is going to Message Web server Web server Web server Web server Memcache block is run as an Queue asynchronous job Job Server Data store
  • 18. Cache stampede! • Cache flushes can become terminal to your application. • You need to ensure you can avoid this (or at least know it’s there) • Implement switches to ‘cool down’ your app
  • 19. Development, deployment and testing • You must use version control • You must have version numbers • You must have package management • You must have a stage environment
  • 20. Development, deployment and testing • You need tests! • Even if you’re not doing TDD! • The most likely bug to have is one you already fixed once.
  • 21. Development, deployment and testing • Everyone in your team needs to be able to do everything • No superstars, being run over by a bus more likely than you think
  • 22. Development, deployment and testing • Test plans • A-B testing • Customer driven testing and deployment
  • 23. Development, deployment and testing • You need a rollback plan • API versioning • Data migrations - be careful!!
  • 24. The Zen swap • Migrating continually updated data around with no downtime • E.g. moving Zen machines between hosts, moving database info around. • For database, relies on triggers
  • 25. The Zen swap • Modify time column on ‘from’ table. • Copy (and munge) all the data, row by row, noting when you start • Copy (and munge) all the data changed since you started • Repeat until the set of dirty data is very small
  • 26. The Zen swap Old New Old New Old New Old New
  • 27. The Zen swap • Stop the universe • Do one final pass of the data • Add triggers for reads/writes in the old column to use the new column • Start the universe • Needs transactional DDL to be seamless • Even without, use to minimise downtime
  • 28. Accidental complexity • Premature generalisation is the root of all evil. • Lack of polymorphism • Insufficient use of delegation • Commonality develops independently.You MUST refactor
  • 29. Load and scalability testing • Simple ab can tell you a lot • NYTProf • You need to test your system with your hardware and your data • A little tuning can go a long way.
  • 30. Health monitoring • Log useful stuff from your app! • Syslog • Nagios • Healthcheck pages • Munin • Splunk
  • 31. Performance monitoring • Per hit stats (db queries, memcache hits, times taken) • Query comments • Graphs are awesome (RRD is kinda hateful)
  • 32. Conclusion • Components rule! • Expect change. • Enforce consistency.
  • 33. Thanks! • Slides will be on slideshare later • I can (and probably will) rant at length about any of this if you buy me a beer ;) • Questions?

Hinweis der Redaktion