Drupal 8 Lessons From the Field: Part 3 - The Drupal Backend

26
Pavithra Raman - Team Lead, Solution Architect Enhancing Back End Drupal Development & Performance Drupal 8 Lessons From the Field

Transcript of Drupal 8 Lessons From the Field: Part 3 - The Drupal Backend

Page 1: Drupal 8 Lessons From the Field: Part 3 - The Drupal Backend

Pavithra Raman - Team Lead, Solution Architect

Enhancing Back End Drupal Development & Performance

Drupal 8 Lessons From the Field

Page 2: Drupal 8 Lessons From the Field: Part 3 - The Drupal Backend

Agenda

Recap: Importance of Speed & Performance

Common Causes & Effects

Best practices & Checkpoints

Page 3: Drupal 8 Lessons From the Field: Part 3 - The Drupal Backend

Recap: Importance of Speed & Performance

END USER EXPERIENCEExpect fast page loads / reloadsFaster interactionsChannels no longer restricted to websitesDecoupled and mobile applicationsIntegration with 3rd party for richer and personalized journey

Page 4: Drupal 8 Lessons From the Field: Part 3 - The Drupal Backend

Impacts

END USER EXPERIENCEMore wait time - customers move onLesser or irrelevant information - seek another sourceWebsite only - leads only via SEO/ADsSEO - affectedMulti-channel experience affected -mobile/tablet based audience left behind

Page 5: Drupal 8 Lessons From the Field: Part 3 - The Drupal Backend

But why is it happening ?

Page 6: Drupal 8 Lessons From the Field: Part 3 - The Drupal Backend

Fight the good fight, but compromise

Designer/Marketer Developer

?

● Customer experience

● Larger Media assets

● More features

● Goal: Visually attractive

and engaging experience

● Server side performance

● Content generation

● Reduce response time

● Goal: Cacheable and

scalable content/asset

creation & delivery

Page 7: Drupal 8 Lessons From the Field: Part 3 - The Drupal Backend

Drupal - very powerful Content Management / Digital

Experience System

Lot of features

Content

Taxonomy

Media

Templating engine

User management

API First

Panelizers

Workflow

e-commerce

and many many more ….

With great power comes great responsibility

Page 8: Drupal 8 Lessons From the Field: Part 3 - The Drupal Backend

Common Causes

Biggest/Obvious causes- Drupal Architecture- Site planning- Business logic via customizations- Caching missing- Drupal configuration- Server Architecture

Page 9: Drupal 8 Lessons From the Field: Part 3 - The Drupal Backend

Common Causes

Smaller/Hidden causes ( we might miss these )- MySQL slow queries- Information architecture- 3rd Party integrations- Content Display / Theme ( What ? )- Slow Complex code (CPU/RAM

spikes)

Page 10: Drupal 8 Lessons From the Field: Part 3 - The Drupal Backend

Effects

- Number requests dropped - Slow Drupal requests- PHP max timeout- Server CPU/RAM maxing out- MySQL server overload- Impacts on the front end delivery- Easy target for DDoS attacks- Unusable content editorial

Page 11: Drupal 8 Lessons From the Field: Part 3 - The Drupal Backend

Oh… I will just solve it using decoupled

Node.js Server side rendering is faster you know

Page 12: Drupal 8 Lessons From the Field: Part 3 - The Drupal Backend

Uhhh.. Well….❏ Yes, but not completely.

❏ Content creation is still happening via the Drupal UI for

many of these applications.

❏ Any custom logic or 3rd party integrations to connect

other sources might be invoked via the Drupal layer

❏ You still need fast performing APIs

Page 13: Drupal 8 Lessons From the Field: Part 3 - The Drupal Backend

13 ©2016 Acquia Inc. — Confidential and Proprietary

Best practices & Checkpoints

Understand end user experience

Business requirements Custom Logic

3rd party integration

Editorial add-ons

Ideal experience benchmarks

Information architecture

Module selection

Library selection

Function reuse

Content reuse

Drupal setup

Customizations as per Drupal Coding standards

Caching

Performance test / PHP profiling with development

Front End + Theming

Drupal Request profiling

MySQL slow query log

Load Testing

Acquia Insight

Requirements Architecture Implementation Testing / QA

Page 14: Drupal 8 Lessons From the Field: Part 3 - The Drupal Backend

Does the experience require any complex

front end components like display effects,

asynchronous content refresh, rich media

experience, etc.

Does the application need any complex data

processing, presentation logic, dynamic

components ?

Does the 3rd party integration provide you with

hi-speed APIs? Does this 3rd party add

more load to your code? Does your

application have to do more processing on

the Drupal layer?

Requirements Review SamplesFor the content editorial experience, do we

need any add-ons for image processing,

WYSIWYG editors, in-line editors, heavy

media/assets uploaded, complex and heavy

data structures for content?

From the perspective of various users, content

consumers, content editors, media

managers, decoupled applications

connecting to the Drupal backend what are

the response benchmarks?

Page 15: Drupal 8 Lessons From the Field: Part 3 - The Drupal Backend

- Maintain Drupal core and contributed modules at

latest stable version

- Custom modules as per Drupal Code-standards

- Drupal API + Hooks

- PHP, OOPS, Symphony

- JS

- CSS

- Select modules as per current and future requirements

Architecture Best Practices

Page 16: Drupal 8 Lessons From the Field: Part 3 - The Drupal Backend

- Client side caching

- Varnish cache

- Drupal Internal Dynamic Page cache

- Drupal Internal Page cache

- Page cache max time ( dependent on

content update frequency )

- Memcache

- APC - opcode cache

- Uninstall unused modules

Implementation Best Practices- Optimized Images/Media

- Responsive images/pages via different

images

- Aggregation and compression of JS/CSS

- Bigpipe

- Lazy Loading

- Clean twig templates

Page 17: Drupal 8 Lessons From the Field: Part 3 - The Drupal Backend

Tools: Unit testing - Dev

- XDebug + XHProf - PHP profiler

- Devel module

- Automated tests: Behat, Drupal

- Google Pagespeed Insights

- Acquia Insight

What to test for ( against ideal benchmarks )

- Resource utilization ( CPU, RAM, PHP

procs, cache)

- Cache hit ratio

- MySQL utilization / Slow queries

- OutOfMemory = OOM errors

- Response time

Testing & TuningPre-Production: Before Go Live

Test on Production-like setup

- Resource utilization

- Cache hit ratio

- Database performance

- Load Tests

- Acquia Insight

Page 18: Drupal 8 Lessons From the Field: Part 3 - The Drupal Backend

GO LIVE !! Server deployment

Drupal Optimized Server setup

Caching

Logs

Production Optimized Drupal

Configuration

Page 19: Drupal 8 Lessons From the Field: Part 3 - The Drupal Backend

- Front end asset / page cache using

- Varnish/CDN

- Load Balancing for easy scaling

- Web server optimized for Drupal

- PHP with

- APCu for PHP code cache

- memcache ext +

- Dedicated or co-hosted memcached

for Drupal cache tables

- MySQL optimized for Drupal

- Read/Write optimized storage

- Dedication Cron server if required

Production - Checklist- Disable Database Logging

- Enable syslog ( to send logs to server

logging system )

- Disable non-production required modules

- ex. modules enabled for testing

- Views UI, Config UI

- Page cache settings

- Page + Blocks + Views + Others

- API cache & security setup

- Aggregate & compress - JS + CSS

Page 20: Drupal 8 Lessons From the Field: Part 3 - The Drupal Backend

Questions

Page 21: Drupal 8 Lessons From the Field: Part 3 - The Drupal Backend

Thank You

Page 22: Drupal 8 Lessons From the Field: Part 3 - The Drupal Backend

200-500ms“Good” TTFB (Time To First Byte)

https://www.rackaid.com/blog/time-to-first-byte/

Page 23: Drupal 8 Lessons From the Field: Part 3 - The Drupal Backend

1s to 3s“Good” TTLB (Time To Last Byte)

https://yoast.com/page-speed-ranking-factor/

Page 24: Drupal 8 Lessons From the Field: Part 3 - The Drupal Backend

Page weight

http://www.httparchive.org/interesting.php (October 16th)

Page 25: Drupal 8 Lessons From the Field: Part 3 - The Drupal Backend

Page weight

http://www.httparchive.org/interesting.php (October 16th)

Average LTE

speed is 5-

12Mbps

This page would

take 2-5 seconds

to download!

Page 26: Drupal 8 Lessons From the Field: Part 3 - The Drupal Backend

Images

http://www.httparchive.org/interesting.php (October 16th)

54%