35
Get More Out of MySQL with TokuDB Tim Callaghan VP/Engineering, Tokutek [email protected] @tmcallaghan

Get More Out of MySQL with TokuDB

Embed Size (px)

DESCRIPTION

TokuDB is an ACID/transactional storage engine that makes MySQL even better by increasing performance, adding high compression, and allowing for true schema agility. All of these features are made possible by Tokutek's Fractal Tree indexes.

Citation preview

Page 1: Get More Out of MySQL with TokuDB

Get More Out of MySQL with TokuDB

Tim CallaghanVP/Engineering, Tokutek

[email protected]@tmcallaghan

Page 2: Get More Out of MySQL with TokuDB

Tokutek: Database Performance Engines

What is Tokutek?Tokutek® offers high performance and scalability for MySQL,

MariaDB and MongoDB. Our easy-to-use open source solutions are compatible with your existing code and application infrastructure.

Tokutek Performance Engines Remove Limitations• Improve insertion performance by 20X• Reduce HDD and flash storage requirements up to 90%• No need to rewrite code

Tokutek Mission: Empower your database to handle the Big Data

requirements of today’s applications

Page 3: Get More Out of MySQL with TokuDB

3

A Global Customer Base

Page 4: Get More Out of MySQL with TokuDB

Housekeeping

• This presentation will be available for replay following the event

• We welcome your questions; please use the console on the right of your screen and we will answer following the presentation

• A copy of the presentation is available upon request

Page 5: Get More Out of MySQL with TokuDB

Agenda

Lets answer the following questions, “How can you…?”

• Easily install and configure TokuDB.• Dramatically increase performance without rewriting

code.• Reduce the total cost of your servers and storage.• Simply perform online schema changes.• Avoid becoming the support staff for your

application.

• And Q+A

Page 6: Get More Out of MySQL with TokuDB

How easy is it to install and configure TokuDB forMySQL or MariaDB?

Page 7: Get More Out of MySQL with TokuDB

What is TokuDB?

• TokuDB = MySQL* Storage Engine + Patches**– * MySQL, MariaDB, Percona Server– ** Patches are required for full functionality

– TokuDB is more than a plugin

• Transactional, ACID + MVCC– Like InnoDB

• Drop-in replacement for MySQL

• Open Source– http://github.com/Tokutek/ft-engine

Page 8: Get More Out of MySQL with TokuDB

Where can I get TokuDB?

• Tokutek offers MySQL 5.5 and MariaDB 5.5 builds– www.tokutek.com

• MariaDB 5.5 and 10– www.mariadb.org– Also in MariaDB 5.5 from various package repositories

• Experimental Percona Server 5.6 builds– www.percona.com

Page 9: Get More Out of MySQL with TokuDB

Is it truly a “drop in replacement”?

• No Foreign Key support– you’ll need to drop them

• No Windows or OSX binaries– Virtual machines are helpful in evaluations

• No 32-bit builds

• Otherwise, yes

Page 10: Get More Out of MySQL with TokuDB

How do I get started?

• Start Fresh– create table <table> engine=tokudb;– mysqldump / load data infile

• Use your existing MySQL data folder– alter table <table-to-convert> engine=tokudb;

• Measure the differences– compression : load/convert your tables– performance : run your workload– online schema changes : add a column

Page 11: Get More Out of MySQL with TokuDB

Before you dive in – check you’re my.cnf

• TokuDB uses sensible server parameter defaults, but

• Be mindful of your memory– Reduce innodb_buffer_pool_size (InnoDB) and

key_cache_size (MyISAM)– Especially if converting tables

– tokudb_cache_size=?G– Defaults to 50% of RAM, I recommend 80%

– tokudb_directio=1

• Leave everything else alone

Page 12: Get More Out of MySQL with TokuDB

How can I dramatically increase performance without having to

rewrite code?

Page 13: Get More Out of MySQL with TokuDB

Where does the performance come from?

• Tokutek’s Fractal Tree® indexes– Much faster than B-trees in > RAM workloads

– InnoDB and MyISAM use B-trees– Significant IO reduction

– Messages defer IO on add/update/delete– All reads and writes are compressed

– Enables users to add more indexes– Queries go faster

• Lots of good webinar content on our website– www.tokutek.com/resources/webinars

Page 14: Get More Out of MySQL with TokuDB

How much can I reduce my IO?

Converted from InnoDB to TokuDB

Page 15: Get More Out of MySQL with TokuDB

How fast can I insert data into TokuDB?

• InnoDB’s B-trees– Fast until the index not longer fits in RAM

• TokuDB’s Fractal Tree indexes– Start fast, stay fast!

• iiBench benchmark– Insert 1 billion rows– 1000 inserts per batch– Auto-increment PK– 3 secondary indexes

Page 16: Get More Out of MySQL with TokuDB

How fast can I insert data into TokuDB?

Page 17: Get More Out of MySQL with TokuDB

How fast are mixed workloads?

• Fast, since > RAM mixed workloads generally contain…– Index maintenance (insert, update, delete)

– Fractal Tree indexes FTW!– Queries

– TokuDB enables richer indexing (more indexes)

• Sysbench benchmark– 16 tables, 50 million rows per table– Each Sysbench transaction contains

– 1 of each query : point, range, aggregation– indexed update, unindexed update, delete, insert

Page 18: Get More Out of MySQL with TokuDB

How fast are mixed workloads?

Page 19: Get More Out of MySQL with TokuDB

How do secondary indexes work?

• InnoDB and TokuDB “cluster” the primary key index– The key (PK) and all other columns are co-located in

memory and on disk

• Secondary indexes co-locate the “index key” and PK– When a candidate row is found a second lookup

occurs into the PK index– This means an additional IO is required

– MySQL’s “hidden join”

Page 20: Get More Out of MySQL with TokuDB

What is a clustered secondary index?

• “Covering” indexes remove this second lookup, but require putting the right columns into the index– create index idx_1 on t1 (c1, c2, c3, c4, c5, c6);– If c1/c2 are queried, only c3/c4/c5/c6 are covered

– No additional IO, but c7 isn’t covered

• TokuDB supports clustered secondary indexes– create clustering index idx_1 on t1 (c1, c2);– All columns in t1 are covered, forever

– Even if new columns are added to the table

Page 21: Get More Out of MySQL with TokuDB

What are clustered secondary indexes good at?

• Two words, “RANGE SCANS”

• Several rows (maybe thousands) are scanned without requiring additional lookups on the PK index

• Also, TokuDB blocks are much larger than InnoDB– TokuDB = 4MB blocks = sequential IO– InnoDB = 16KB blocks = random IO

• Can be orders of magnitude faster for range queries

Page 22: Get More Out of MySQL with TokuDB

Can SQL be optimized?

• Fractal Tree indexes support message injection– The actual work (and IO) can be deferred

• Example:– update t1 set k = k + 1 where pk = 5;– InnoDB follows read-modify-write pattern– If field “k” is not indexed, TokuDB avoids IO entirely

– An “increment” message is injected

• Current optimizations– “replace into”, “insert ignore”, “update”, “insert on

duplicate key update”

Page 23: Get More Out of MySQL with TokuDB

How can I reduce the total cost of my servers and storage?

Page 24: Get More Out of MySQL with TokuDB

How can I use less storage?

• Compression, compression, compression!

• All IO in TokuDB is compressed– Reads and writes– Usually ~5x compression (but I’ve seen 25x or more)

• TokuDB [currently] supports 3 compression algorithms– lzma = highest compression (and high CPU)– zlib = high compression (and much less CPU)– quicklz = medium compression (even less CPU)– pluggable architecture, lz4 and snappy “in the lab”

Page 25: Get More Out of MySQL with TokuDB

But doesn’t InnoDB support compression?

• Yes, but the compression achieved is far lower– InnoDB compresses 16K blocks, TokuDB is 64K or 128K– InnoDB requires fixed on-disk size, TokuDB is flexible

*log style data

Page 26: Get More Out of MySQL with TokuDB

But doesn’t InnoDB support compression?

• And InnoDB performance is severely impacted by it– Compression “misses” are costly

*iiBench workload

Page 27: Get More Out of MySQL with TokuDB

How do I compress my data in TokuDB?

create table t1 (c1 bigint not null primary key)

engine=tokudb

row_format=[tokudb_lzma | tokudb_zlib | tokudb_quicklz];

NOTE: Compression is not optional in TokuDB, we use compression to provide performance advantages as well as save space.

Page 28: Get More Out of MySQL with TokuDB

How can I perform online schema changes?

Page 29: Get More Out of MySQL with TokuDB

What is an “online” schema change?

My definition

“An online schema change is the ability to add or drop a column on an existing table without blocking further changes to the table or requiring substantial server resources (CPU, RAM, IO, disk) to accomplish the operation.”

P.S., I’d like for it to be instantaneous!

Page 30: Get More Out of MySQL with TokuDB

What do blocking schema changes look like?

Page 31: Get More Out of MySQL with TokuDB

How have online schema changes evolved?

• MySQL 5.5– Table is read-only while entire table is re-created

• “Manual” process– Take slave offline, apply to slave, catch up to master,

switch places, repeat• MySQL 5.6 (and ~ Percona’s pt-online-schema-change-tool)

– Table is rebuilt “in the background”– Changes are captured, and replayed on new table– Uses significant RAM, CPU, IO, and disk space

• TokuDB– alter table t1 add column new_column bigint;– Done!

Page 32: Get More Out of MySQL with TokuDB

What online schema changes can TokuDB handle?

• Add column• Drop column• Expand column

– integer types– varchar, char, varbinary

• Index creation

Page 33: Get More Out of MySQL with TokuDB

How can I avoid becoming the support staff for my application?

Page 34: Get More Out of MySQL with TokuDB

34

TokuDB is offered in 2 editions

• Community– Community support (Google Groups “tokudb-user”)

• Enterprise subscription– Commercial support

– Wouldn’t you rather be developing another application?– Extra features

– Hot backup, more on the way– Access to TokuDB experts– Input to the product roadmap

Where can I get TokuDB support?

Page 35: Get More Out of MySQL with TokuDB

35

Tokutek: Database Performance Engines

Any Questions?Download TokuDB at www.tokutek.com/products/downloads

Register for product updates, access to premium content, and invitations at www.tokutek.com

Join the Conversation