1. Custom Drupal Dev
Secure and Performant
Drupal4Gov - April 2016
Doug Green
douggreen@tag1consulting.com
Twitter: @dougjgreen
http://drupal.org/u/douggreen
4. Custom Development - caching
● Persistent cache_set/get, drupal_static()
● Render arrays #pre_render and #attached
● Profile with xhprof - “premature optimization is the root
of all evil” - Donald Knuth
● Drupal does a lot of double caching. It should be
avoided but is pretty unavoidable.
5. Custom Development - Database
● EFQ, Entity cache, entity_load (multiple)
● Database indexes
Remember the tree,
traverse one branch at a
time
7. Custom Development - Front End
● Decrease number and size of assets retrieved: JS /
CSS Aggregation, minify, compress, image sprites
● Retrieve user customized content with JS
● Use Image styles
● JS at bottom of page
● Use Chrome Developer to see page requests
8. Custom Development - use APIs
● You may be tempted to circumvent some APIs thinking
you can do it faster directly and you might not be wrong
to think that. Don’t do it. APIs give us security and
extensibility beyond what you might consider.
10. Questions & Answers
Doug Green
douggreen@tag1consulting.com
(sorry, we did not have enough time to cover security, so those slides were removed here)
Editor's Notes
Hi, I'm Doug Green. I work at Tag1 which specializes in performance, scalability and security -- especially for Drupal. Thanks for coming to listen to me talk"
Tell my Drupal Experience
I am a developer so we are mostly going to talk about Custom Development.
We are going to do a quick overview of Concepts, Settings, Custom Development, and Infrastructure.
But much of what I was going to discuss in this talk was already discussed in the first Performance talk by Tim Cullen from Acquilent so I made a last minute change to this presentation, and after performance we’re going to pivot to security
Once you determine a section of code is slow, you’ll either fix the root cause or cache it statically or persistently
Review mysql slow query log
Enable devel module and query display
Review watchdog
Fix PHP warnings that happen frequently, logging these is expensive and unnecessary
When appropriate, use count() or limit to 1 row
CDN
http://drupal.org/project/cdn
Delivers cached or static content, completely avoiding server load
Minimizes ping delays by spreading content physically across the globe
Varnish is not a CDN but is good
We are at the Q&A part of the presentation, so I wanted to open it up to questions from the audience about anything in the presentation or other related topics.