Drupal Camp Austin 2011 (gist)
Responsive design
- mediaqueri.es
- Progressive CSS
- Feature detection (JS - modernize)
- front-end reverse proxy ignorance
- polyfill... JS shim that makes ie work
- mediaquery polyfills
- Responsive modules
- respondjs
- responsive_images
- responder
- script loaders
- themes
- responsive video: fitvidjs
- front end performance
- ~97% perceived response time is front
- Responsive images, datauri, ...
- jdrop.org
- Stevesounders.com/mobileperf
- Blaze.io/mobile
Practical Performance Tuning
miscellaneous
- psr0 module (may not be autoload compatible)
- Composer (package management)
- drush make version package injection and drupal modules
- worker queue - drupal queue with drush in long running mode to pick up jobs (worker pool) - use reddis for queue (in place of beanstalkd for reporting and queryability)
Pantheon (David Strauss)
- Moved to Chef Solo, no more Bcfg2
- Nginx + PHP-FPM
- Cassandra? based file system for public/private files (distributed + redundant)
- Valhalla?
- Probably going to move to S3 or Rackspace analog for cheaper rates (redundancy on instance storage is very expensive $1/GB x 3)
- SASL API communication
- Hidden Jenkins job runner
- Running Fedora, primarily for system.d.
Examiner
- use mongodb for storage (no MySQL - motivated by trying to avoid cacheing)
- mongodb writes are a bear... they have run out of indexes and are in constant tuning mode for performance
- interesting scale problem with 1000x usage spikes - autoscale is difficult
- use hadoop for (batched) "live jobs" that need to compute complex royalty rules
Code Smell (Larry Garfield)
- and (ie object_validate_and_save)
*
- drupal_get_form (retrieve, populate a form0
- Solr::addDocuments wraps _documentToXML private method, so you can’t see the object XML without adding to the index.
- God objects - classes that do too much
- parameters or returns of multiple types
- throw exceptions
- return object or FALSE
- _registry_check_code() -> constants, strings, variable types
- Volunteer to cleanup this function
- Overly complex code leads to overly complex bugs.
- Run-time type identification
- Changing keys by object type = bad
- Polymorphism (procedural)
- Polymorphism (OO)
- 4 Unit Testing (263)
- SimpleTest in core are not unit tests unless 1 Drupal = unit
- This is system testing and is valuable, but not unit testing.
- DrupalUnitTestCase (~25)
- We should be doing more of this, but...
- Globals, hooks, etc don’t handle it well
- If you can’t unit test your code, your code is wrong.
- Avoid globals, avoid statics
- Dependency injection, construct objects with what they need, don’t call other API midstream.
- Minimize singletons, another form a global. Hard function calls are a form of singleton.
- 5 Documentation
- If you can’t document, you don’t know what you are doing.
- If you don’t document, another wont know what you are doing.
- Bad documentation:
- string $jail -> what is jail, what is valid, must define
- array $settings -> what goes in settings?
- Why things aren’t documented
- Lazy -> bad
- Indifference -> bad
- Lack of comprehension
- That’s OK, document that! (Here be dragons)
- Embarrassment
- That’s OK, document it! Very useful.
- What to document
- Every function
- Every method
- Every class
- Every object property
- Every constant
- Every parameter
- drupal.org/node/1354
-
6 Inappropriate intamacy
- coupling
- content coupling
- Common
- External
- Control
- Data-structured
- ?
- ?
- Otherwise difficult to refactor
- Solutions
- Well documented interfaces
- 7 Purity
- Pure functions always returns the same value given the same input.
- Side effects
- Changes global state, cannot be repeated, etc.
- Sometimes side effects are the goal
- ie save() -> that’s fine, but isolate save()
- drupal_theme_initialize()
- Lot’s of side effects
- cleaner approach
- class Theme -> more testable
- 8 Good smells
- Single purpose
- Self-contained
- Predictable
- Repeatable
- Unit testable
- Documented
aphorisims-api-design
coding horror -> code smells
java -> SmellsToRefactoings
joel spoelsky -> Wrong.html
signs you should not be coding
-
TheDailyWTF.com
- Good code
- Queue
- DBTNG (biased)
- File transfer for module update
- PHP Object patterns and practice, it’s a bit old
- Sitepoint book coming soon.
- Avoid older PHP tutorials
Project mgmt (from the Examiner)
- PERT - from military - provides more insight than gantry
- Focus on stakeholder needs rather than wants
- last 3 mo. Finally unhacked core
- a bad decision is better than indecision on a deadline
- a bad client is better than no client at all
- process and schedules: client should be just as accountable
- communication, mediate and translate, unblock -- calm from chaos
- minimize little shiny distractions -- context switching kills!
- manhole cover round and heavy - keep it from falling in and stop from easily walking away - for saftey
Drupal Commerce
- ecommerce framework - flexibility about what you can build with it
- eurocentres
- opendealsapp.com
- inline product form... in rsyzmar sandbox
- Ajax framework in d7 is really impressive with commerce
- zondervan??
- realmilkcheese.com
Profiling with Xhprof
- http://msonnabaum.github.com/xhprof-presentation/#1
- brianmercer ppa
- Module implements should go into pressflow - David Strauss... follow up.
- XHProf should run in production on a few requests...
- Helps to have non-file backend on multi-node setup.
- msonnabaum/XHProfLib
- Strongarm patch to fix variable cache performance issue
Devops bof
- git flow
- gitalyte?
- git tags? Are they locked and never supposed to change?
- drush make idea: [patch][104065] = ...
- Jenkins: DB backup, Dev to stage to prod jobs
- etc keeper - package commit hooks -
- backups and restore scripts -- testable in Jenkins
- update hook - reads from text file
- devel generate - integrations
- default content module - phase2.... will be.dropped
- queued Node access rebuild
- updatedb - revert features in hook_update
- drush deploy (like cap deploy) - video in London
- git reference cache
- camptocamp -- puppet conf -- apache2
- Vewee_fun - stevenmerill
- fastly
- tungsten?? MySQL