hyperdb, mysql performance, & flavors of mysql

16
Anthropomorphic Design Making a Better WordPress with Jazz Hands + =

Upload: evankkc

Post on 16-Jul-2015

263 views

Category:

Software


0 download

TRANSCRIPT

Page 1: HyperDB, MySQL Performance, & Flavors of MySQL

Anthropomorphic DesignMaking a Better WordPress with Jazz Hands

+ =

Page 2: HyperDB, MySQL Performance, & Flavors of MySQL

But seriously….

Page 3: HyperDB, MySQL Performance, & Flavors of MySQL

HyperDB, MySQL

Performance, & Flavors of

MySQLEvan Volgas

Page 4: HyperDB, MySQL Performance, & Flavors of MySQL

About me

• 10 years working with data — as an analyst, a

DBA, etc

• Currently a data engineer for WhatRunsWhere

• Data Engineer = DBA + Map Reduce + PTSD

from Apache Zookeeper

• Worked with WordPress off/on for about ~5 years

Page 5: HyperDB, MySQL Performance, & Flavors of MySQL

Disclaimers

I believe

• Google exists

• You can use it

• You don’t enjoy reading a bunch of code and

config files in a presentation any more than I do

• WordCamp needs more cowbell

Page 6: HyperDB, MySQL Performance, & Flavors of MySQL

What is

HyberDB?

• “Very advanced database class”

• Powers WordPress.com

• Supports replication, partitioning, load balancing,

etc

Page 7: HyperDB, MySQL Performance, & Flavors of MySQL

“Very advanced database class”

find 'hyperdb/' -name '*.php' | xargs wc -l

• HyperDB: 1,401 lines of PHP

• WordPress: 255,961 lines of PHP

• Hello Dolly: 81 lines of PHP

• Yoast’s Google Analytics 16,174 lines of PHP

Page 8: HyperDB, MySQL Performance, & Flavors of MySQL

Why’d you have to go and make

things so complicated

• The complexity of HyperDB has nothing to do with

the PHP code itself

• Implementing HyperDB itself is mostly

configuration

• To the extent that HyperDB is advanced, it’s

because MySQL has a lot of advanced stuff going

on underneath the hood

Page 9: HyperDB, MySQL Performance, & Flavors of MySQL

Who cares about MySQL?

An argument from fellow WordCamp ATL

presenter Tom McFarlin*

• Employers haven’t fully figured out what

WordPress *can* do

• WordPress makes it easy to be a software

implementer as opposed to a software

developer so in a lot of cases salaries probably

should be lower

• The WordPress community itself hasn’t

educated employers, customers, or software

implementors how classical software

development / engineering can fit into the

WordPress ecosystem

*https://tommcfarlin.com/wordpress-developer-

salary/

Page 10: HyperDB, MySQL Performance, & Flavors of MySQL

Tell me again why this matters

• We don’t need any more social media icons plugin

• Many of the things that are really pushing the

WordPress envelope are VERY database

intensive and their performance needs are poorly

understood

• There are a million things you can (and should) do

to optimize your WordPress website. When those

stop being enough, it’d be a good idea to know

some DB basics

Page 11: HyperDB, MySQL Performance, & Flavors of MySQL

HyperDB

• For practical extents and purposes, it’s kind of like a

giant wp-config.php that pertains to your database

• A lot of great resources for setting it up. If you

decide you want to try it, make sure you check out

https://www.digitalocean.com/community/tutorials/how-to-optimize-wordpress-

performance-with-mysql-replication-on-ubuntu-14-04

http://wpguru.co.uk/2010/07/testing-hyperdb/

http://codertalks.com/configuring-hyperdb-to-use-multiple-databases-for-buddypress-

multisite/

Page 12: HyperDB, MySQL Performance, & Flavors of MySQL

MySQL Lingo + Discussion

• Replication

• Statement vs Row-based

• Master vs Slave

• Partitioning

• Tends to either really help or really hurt you — very little in between

• NB: One of the reasons NoSQL has market adoption is because this is very painful

• Latency matters: https://gist.github.com/jboner/2841832

• Failover

• Load Balancing

• DB: HyperDB

• Web app: HA Proxy, Nginx, etc

Page 13: HyperDB, MySQL Performance, & Flavors of MySQL

MySQL Performance Basics

• innodb_buffer_pool_size: 70-80% of memory is common

• innodb_buffer_pool_instances: if you have a lot of memory, you might

run into bottlenecks where multiple threads are trying to access the buffer

pool. Splitting it up into multiple buffer pools can help

• innodb_file_per_table: if you are using < MySQL 5.6, turn this on. Trust

me.

• max_connections: if you ever think you need to tweak this, double check

that your connections are terminating properly

• log_bin: your master nodes needs this

• slow-query-log, slow-query-log-file, long_query_time: log your slow

queries. Don’t go crazy, but periodically log everything and analyze it

Page 14: HyperDB, MySQL Performance, & Flavors of MySQL

MySQL Best PracticesMonitor everything

• New Relic, Datadog, Zabbix, graphite/statsd/collectd

• http://www.percona.com/live/mysql-conference-

2013/sites/default/files/slides/percona-live-santa-clara-2013-presentation-

spilgames-mysql-statsd.pdf <— Interesting idea

Analyze your queries

• pt-query-digest, mysqldumpslow, plugins for third party monitoring

Learn how to reason about the Query Execution Plan

• http://www.sitepoint.com/using-explain-to-write-better-mysql-queries/

Schedule DB maintenance

Page 15: HyperDB, MySQL Performance, & Flavors of MySQL

Flavors of MySQL

• MySQL

• MariaDB

• https://mariadb.com/blog/how-install-and-run-

wordpress-mariadb

• Percona:

• https://www.digitalocean.com/community/tutorials/ho

w-to-install-a-fresh-percona-server-or-replace-mysql

Page 16: HyperDB, MySQL Performance, & Flavors of MySQL

Special Mention

Percona Toolkit

• http://www.percona.com/doc/percona-toolkit/2.2/

pt-query-digest --since '2014-11-01' --filter '$event->{arg} =~ m/^select/i' /var/log/mysql/slow-query.log >

/tmp/pt_slow_since_nov2014

Nginx + PHP-FPM

• http://www.raspipress.com/2014/06/tutorial-install-wordpress-on-a-

raspberry-pi-using-nginx/

Learn from people within WordPress and from outside of it

• good example: https://roots.io/twelve-factor-wordpress/