-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDrupalHugs.html
572 lines (413 loc) · 13.2 KB
/
DrupalHugs.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
<!DOCTYPE html>
<html>
<head>
<title>Drupal Hugs</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<style type="text/css">
body { font-family: 'Century'; }
h1, h2, h3 { font-weight: normal; }
ul { line-height: 1.4; }
pre { margin: 0.5em 0em 0em 0em; }
.remark-slide-content { font-size: 22pt; padding: 1em 2em 1em 2em; }
.remark-slide-content h2 { text-align: center; border-bottom: 1px solid black; }
.remark-slide-number { bottom: 2px; font-size: 14px; opacity: 1; }
div.toc table {
width: 800px;
text-align: left;
margin-left: auto;
margin-right: auto;
}
div.text20 { font-size: 20pt; }
div.text18 { font-size: 18pt; }
div.toc table tr:nth-child(odd) { background: #F5F5F5; }
div.toc table tr:nth-child(even) { background: #FFFFFF; }
div.toc table tr td { padding: 10px; }
div.chapter-header h3 { color: #999; margin: 0px 0px 10px 0px; }
div.chapter-header h2 { text-align: left; font-weight: bold; margin: 0px 0px 100px 0px; }
.console-small pre code .remark-code-line { font-size: 10pt; }
/* Two-column layout */
.left-column {
width: 49%;
float: left;
}
.right-column {
width: 49%;
float: right;
}
.right-column ~ p { clear: both; }
.right-column ~ ul { clear: both; }
/* acquia blue is either #29AAE1 or #27A9E0 */
/* what in the fuck is this? oh acquia. https://confluence.acquia.com/display/UX/Color */
/* ok, non-archived https://confluence.acquia.com/display/UX/ADL+Style+guidelines */
/* Header/Footer stuff */
div.acquia-header {
background-color: #29AAE1;
background: -webkit-gradient(linear, left top, right top, color-stop(0%,#29AAE1), color-stop(0%,#29AAE1), color-stop(0%,#F5F5F5), color-stop(10%,#F5F5F5), color-stop(25%,#29AAE1), color-stop(100%,#29AAE1));
position: fixed;
top: 0px;
left: 0px;
height: 25px;
width: 100%;
text-align: left;
}
div.acquia-footer {
background-color: #29AAE1;
position: absolute;
bottom: 0px;
left: 0px;
height: 30px;
width: 100%;
}
div.acquia-footer span {
font-size: 10pt;
position: absolute;
left: 15px;
bottom: 2px;
}
</style>
</head>
<body>
<textarea id="source">
layout: true
<div class="acquia-header"><img src="acquia_logo.png" style="height: 25px;"/></div>
<div class="acquia-footer"><span>Emily Slocombe and Pim van der Wal</span></div>
---
class: center, middle
name: section-begin
 
 
 
 
 
# Drupal just wants to
# _hug_
# your database
---
class: center, middle
name: section-begin

# And by _hug_ -- I mean bodyslam
???
Drupal can really abuse a database
---
class: center, top, toc
## Table of Contents
| |
| -------------------------- |
| What is Drupal? |
| Top complaints |
| MySQL at Acquia |
| Caching |
| Drupal things |
| Common tables |
| Common issues |
| Your role |
???
stuff
---
## What is Drupal?
* a Content Management System
* you probably have been on a drupal site, today even
* https://www.drupal.com/showcases
.center[<img src="showcase.png" width="60%">]
???
GET NEW SCREENSHOT !
As a very flexible CMS, it can either be really lean or bloated with modules.
We host thousands of Drupal sites, and they all look and perform very differently from each other.
* contrib and core modules. Sites are basically completely changed with how they look and run
---
## Drupal versions
* Initial release in 2000
* Drupal 6 (2008)
* Drupal 7 (2011)
* Drupal 8 (2015)
???
* Drupal 8 was released very recently. Most of the sites we host are on version 7.
* Acquia still hosts Drupal 6, 7 and 8 sites.
---
## Top complaints
* bad queries
* 'views'
* misinformation
???
* Bad queries, like those generated by views
* When people hear that I work with Drupal and they are aware at all of what the queries can look like, I often get semi-disgusted responses. Drupal views is a query builder and it doesn't always build the most beautiful queries.
* I also had one person 'inform me' that Drupal couldn't use InnoDB -- telling me the story of how their site broke when they tried. Whatever happened for them, completely ruined their opinion of Drupal. I've been with Drupal since version 5, and I can safely say I have never had it 'not work' on InnoDB.
---
## MySQL at Acquia
* all AWS EC2
* Percona Server 5.5 (working on upgrades)
* EBS backed MySQL (slowww disks)
* master-master (active-passive)
* dns-based failover
* thousands of db servers, 2.3 DBAs
???
* we are running with only one active in the master-master pair
* the dbs's are part of the operations team.
* the sites we run range from super small from like the 'librarians of nebraska fan site' to huge like major media news sites and I just made up that nebraska thing
---
## Caching
* Always avoid the database
- < drupal 8 defaults to no caching. Enable page cache
- all caching defaults to in-database
- use memcached for cache backend
* Cache layers at Acquia:
.center[]
???
* The biggest performance tip is 'Caching'
* Drupal basically loads websites from the database. Cache more, hit the database less.
* caching exists at each layer of the diagram
---
## Drupal things
* Views
* Blocks
* Panels
* Modules
* Custom fields
???
* these are the basic components of a drupal web page.
---
## Drupal things: a page

???
* here is a recent version of the acquia dot com page
---
## Drupal things: a page

???
* here are those basic drupal components on the acquia dot com web page
---
## Drupal things - Views Module
* Views is essentially a query builder
--
* Part of Drupal Core
--
* Allows non-programmers to generate SQL queries
--
* Defaults to left joins
--
* Views can use other views (sub queries)
???
there should be an example on the next slide of a views-style query with left joins... the classic... pagination!
---
## Drupal things - Views
* Pagination hurts

???
* Subquery
* 3 left joins
* No limit
---
## Drupal things - Views
* Pagination hurts
- Views Litepager (https://www.drupal.org/project/views_litepager)
- Views Load More (https://www.drupal.org/project/views_load_more)
???
Both modules do not show a count and do not allow to go to last page.
---
## Drupal things - Variables
* Drupal configuration table
* Always cached
* Variable contention

???
* Drupal variables are cached so a cache clear and lead each thread to recache the entire variable table
* Modules store aggregate js or css hash in variable table but if that is different per page it will get continuously updated
TODO: discuss this last one with Mark S
---
## Drupal things - Variables
* Cache stampede<br>
.center[]
???
advance to the next slide before everyone gets vertigo!
---
## Drupal things - Variables
* Cache stampede<br>
https://www.drupal.org/project/variables_that_suck_less
???
A cache clear causes the entire vaariable table to be loaded into cache.
---
## Drupal things - Custom fields
* Drupal 6: Custom fields grouped together in tables
* Drupal 7: A separate table per custom field
* Drupal 8: A separate table per custom field
???
Drupal 7 allows separate database engines to be used for custom fields. Drupal 8 does not since it wasn't being used.
---
## Drupal things - Custom fields
Drupal 7 and 8:
* Each custom field is stored in a separate table
* Updating 10 custom fields mean updating 10 records
* Lots of joins

---
## Common tables - Drupal 8 ERD
<img src="Drupal8_UPsitesWeb_Schema_10-19-2013.png" style="width: 100%;"/>
???
* this was how I tried to learn drupal back when I was at Nokia 6 or 7 years ago
* there are no foreign keys
* Joins are based on fake foreign keys!
---
## Common tables
* cache*
* cache_form
* field_*
* field_revision*
* node
* semaphore
* variable
* watchdog
---
## Common tables
* cache* -> memcached
* cache_form -> possibly compression
* field_*
* field_revision*
* node
* semaphore -> sometimes memcached
* variable -> investigate contents
* watchdog -> send to file
???
* cache_form records get way too big. Fixed in d8, working on a fix to d7
* watchdog not necessarily bad, but there a lot of customers that write every lasy bit of info, so it can get too much traffic.
---
## Common tables - cache_form
* cache_form table stores state between pages
- Filters, shopping cart, etc.
* Views store the views object
- In Drupal 7 they can add too much data, fixed in Drupal 8
* Drupal cron purge needs to run
???
* One customer wrote 1.3MB per cache_form record for each page visit. This contained a pre-generated filter for videos.
* Compression can help reduce the disk I/O for large records. Not a huge gain in general.
* Purge job choice between running frequently and causing locking issues or infrequent (once per day) and taking hours to run on busy sites.
---
## Common tables - cache_form
* Compression sometimes helps
<p style="text-align:center"><img src="compressed-denny.png" style="width: 45%"/></p>
---
## Common tables

???
many of our customers use New Relic. Here, they might choose to blame the database for a performance issue.
---
.center[<img src="database.jpg" height="100%">]
---
## Common tables

???
Here we see, perhaps, cache_form is having trouble
---
## Common issues - Capacity
* CPU / memory => EC2 instance upsize
- Bigger InnoDB buffer pool
- More CPU cores<p>
* Disk I/O issues
- InnoDB log file size
- Hard limit of disk I/O capacity
???
* CPU cores are limited to what the version of MySQL supports
* Log file size mostly addresses peak usage and not sustained higher usage
---
## Common issues - Furious flushing
<img src="furious-flushing-redolog.png" alt="Drawing" style="width: 375px;"/>
<img src="furious-flushing-iops.png" alt="Drawing" style="width: 375px;"/>
<img src="furious-flushing-readwrite.png" alt="Drawing" style="width: 375px;"/>
<img src="furious-flushing-innodbwrites.png" alt="Drawing" style="width: 375px;"/>
???
* Yes, 600 IOPS is non-RAID spinning rust EBS
---
## Common issues - Query Cache
<img src="qc1-qcusage.png" alt="Drawing" style="width: 375px;"/>
<img src="qc1-hitrate.png" alt="Drawing" style="width: 375px;"/>
<img src="qc1-prunes.png" alt="Drawing" style="width: 375px;"/>
<img src="qc1-temptables.png" alt="Drawing" style="width: 375px;"/>
???
* Drupal is supposed to be mostly reads, most customers have 99% reads
---
## Common issues - Query Cache
<img src="qc2-qcusage.png" alt="Drawing" style="width: 375px;"/>
<img src="qc2-hitrate.png" alt="Drawing" style="width: 375px;"/>
<img src="qc2-cpu.png" alt="Drawing" style="width: 375px;"/>
<img src="qc2-runningthreads.png" alt="Drawing" style="width: 375px;"/>
---
## Common issues: Traffic
* deploy with cache clear (drush cc all)
* crawlers
* lots of admin edits
* user registrations / auth traffic
* query cache
???
* due to the nature of drupal, certain types of traffic tend to bypass caches and go straight to the db
---
## Common issues: Traffic

---
## Common issues: Traffic
* deploy with cache clear (drush cc all)
- maint mode
* crawlers
- deflect upstream
* lots of admin edits -> semaphore, *revision
- perhaps make an edit web node, reserved
* user registrations / auth traffic
- fix everything and scale
* query cache (watch throughput and thread status)
- increase - yes, really, sometimes.
- zero + mutex
---
## Your role

---
## Your role
* not often fixing queries or adding indexes
- it is code, we can't easily change code
* monitor workload
- statsd
- new relic
- whatever
* provide useful feedback to developers
- more than just slow queries
* where are they being generated?
---
class: left, bottom, chapter-header
### I am sure there are none.
## questions?
---
class: left, bottom, chapter-header
### For not falling asleep
## Thank you!
---
## extra1 - cache_form cron fail

---
## extra2 - cache_form crawler fail

---
## extra3 - Long Transactions
<img src="trx-trx.png" alt="Drawing" style="width: 375px;"/>
<img src="trx-runningthreads.png" alt="Drawing" style="width: 375px;"/>
<img src="trx-historylist.png" alt="Drawing" style="width: 375px;"/>
<img src="trx-slow.png" alt="Drawing" style="width: 375px;"/>
<!--## Very Wise Words!
 
 
 
 
 
#### .center[Make Sure Your Backup Architecture Meets Your Business Requirements]
##### .center[(so we never have to do a recovery)]
-->
</textarea>
<script src="remark-latest.min.js" type="text/javascript">
</script>
<script type="text/javascript">
var slideshow = remark.create({
navigation: {
scroll: false,
touch: false,
click: false}
});
</script>
</body>
</html>