53
VoltDB: Shard it! By Vitalii Torshyn

Voltdb: Shard It by V. Torshyn

  • Upload
    vtors

  • View
    687

  • Download
    0

Embed Size (px)

DESCRIPTION

VoltDB Shard It: Java Morning slides

Citation preview

Page 1: Voltdb: Shard It by V. Torshyn

VoltDB: Shard it!

By Vitalii Torshyn

Page 2: Voltdb: Shard It by V. Torshyn

VoltDB Designed for

● Network Activity Monitoring / Security● Real-Time Analytics/Monitoring● Telecom: billing, QoS, Policy

Management● Financial Services● Gaming

Page 3: Voltdb: Shard It by V. Torshyn

Agenda

#1: Academic issues: Shard, HP, VP

#2: What is Volt DB? Why ! VoltDB?

#3: Real VoltDB application

#4: Tips and Tweaks: you are not supposed to do that at all

Page 4: Voltdb: Shard It by V. Torshyn

Agenda

#1: Academic issues: Shard, HP, VP

#2: What is Volt DB? Why ! Volt DB?

#3: Simple Volt DB application

#4: Tips and Tweaks: you are not supposed to do that at all

Page 5: Voltdb: Shard It by V. Torshyn

Academic issues

What is:● Shard, Horizontal Partitioning● ACID complaint DBMS● In-memory and real time DB

Page 6: Voltdb: Shard It by V. Torshyn

Academic issues

What is:● Shard, Horizontal Partitioning● ACID compliant DBMS● In-memory and real time DB

Page 7: Voltdb: Shard It by V. Torshyn
Page 8: Voltdb: Shard It by V. Torshyn
Page 9: Voltdb: Shard It by V. Torshyn

Straight forward approach

Page 10: Voltdb: Shard It by V. Torshyn

What is Horizontal Partitioning

Page 11: Voltdb: Shard It by V. Torshyn

What is shard

Page 12: Voltdb: Shard It by V. Torshyn

Use over time for shard

Page 13: Voltdb: Shard It by V. Torshyn

Academic issuesWhat is:● Shard, Horizontal Partitioning● ACID compliant DBMS● In-memory and real time DB

Page 14: Voltdb: Shard It by V. Torshyn

ACID

● Atomicity● Consistency● Isolation● Durability

Page 15: Voltdb: Shard It by V. Torshyn

Academic issuesWhat is:● Shard, Horizontal Partitioning● ACID compliant DBMS● In-memory and real time database

Page 16: Voltdb: Shard It by V. Torshyn

In-memory/real time database

● Storage is option, not requirement● Key value? No!● Data access is cheap (no I/O)● Real time processing

Page 17: Voltdb: Shard It by V. Torshyn

Agenda

#1: Academic issues: Shard,HP,VP

#2: What is Volt DB? Why?! Volt DB?

#3: Simple Volt DB application

#4: Tips and Tweaks: you are not supposed to do that at all

Page 18: Voltdb: Shard It by V. Torshyn

db-engines.com: Ranking

Page 19: Voltdb: Shard It by V. Torshyn

What is VoltDB?●ACID compliant DBMS●In-memory database●Real time●Shared nothing architecture (SN)●SQL support●Java Stored procedures

Page 20: Voltdb: Shard It by V. Torshyn

C++ Engine:Indexing, Lookup, Mem. Management ...

Java over JNISP, Query Prepare, Transfer

Page 21: Voltdb: Shard It by V. Torshyn

Why Volt DB?● Low cost of scaling● Low latency● Automatic Cross-partition joins (no app. Code)

● Multi-master replication (HA, K-Safety)● No buffer management (In memory)● Lockless● Licensing (GPLv3, Enterprise)● Client libraries: Java, Python, C++, C#...

Page 22: Voltdb: Shard It by V. Torshyn

Requests execution

Page 23: Voltdb: Shard It by V. Torshyn

Access and Networking● RESTful HTTP/JSON API● Socket connections● Java API● JDBC

Page 24: Voltdb: Shard It by V. Torshyn

Is VoltDB fast enough?

● Sharding● High Speed Small transactions● No journaling required● Buffering is not required

Page 25: Voltdb: Shard It by V. Torshyn
Page 26: Voltdb: Shard It by V. Torshyn
Page 27: Voltdb: Shard It by V. Torshyn

Replication: K-Safety = 1

Page 28: Voltdb: Shard It by V. Torshyn
Page 29: Voltdb: Shard It by V. Torshyn

Replication: K-Safety = 1

Page 30: Voltdb: Shard It by V. Torshyn

Replication: Active-Passive

Page 31: Voltdb: Shard It by V. Torshyn

K-Factor: performance

Page 32: Voltdb: Shard It by V. Torshyn

Volt DB tools● csvloader — can load data from CSV file

● exporttofile — exports to CSV/TSV file ● sqlcmd — mysql like client ● voltadmin - administrative functions● voltdb — catalog (DB) management and server

Page 33: Voltdb: Shard It by V. Torshyn

Questions?

Page 34: Voltdb: Shard It by V. Torshyn

Volt DB: Super Chat

Page 35: Voltdb: Shard It by V. Torshyn

Agenda

#1: Academic issues: Shard,HP,VP

#2: What is Volt DB? Why?! Volt DB?

#3: Simple Volt DB application(Super Chat)

#4: Tips and Tweaks: you are not supposed to do that at all

Page 36: Voltdb: Shard It by V. Torshyn

Super Chat: flow

Page 37: Voltdb: Shard It by V. Torshyn

DB Schema file1: CREATE TABLE messages ( uid BIGINT NOT NULL, nick VARCHAR(64) NOT NULL, ip VARCHAR(16) NOT NULL, text VARCHAR(1024));

Page 38: Voltdb: Shard It by V. Torshyn

DB Schema file1: CREATE TABLE messages ( uid BIGINT NOT NULL, nick VARCHAR(64) NOT NULL, ip VARCHAR(16) NOT NULL, text VARCHAR(1024));

2: CREATE INDEX messages_idx ON messages (nick, ip);

Page 39: Voltdb: Shard It by V. Torshyn

DB Schema file1: CREATE TABLE messages ( uid BIGINT NOT NULL, nick VARCHAR(64) NOT NULL, ip VARCHAR(16) NOT NULL, text VARCHAR(1024));

2: CREATE INDEX messages_idx ON messages (nick, ip);3: PARTITION TABLE messages ON COLUMN nick;

Page 40: Voltdb: Shard It by V. Torshyn

DB Schema file1: CREATE TABLE messages ( uid BIGINT NOT NULL, nick VARCHAR(64) NOT NULL, ip VARCHAR(16) NOT NULL, text VARCHAR(1024));

2: CREATE INDEX messages_idx ON messages (nick, ip);3: PARTITION TABLE messages ON COLUMN nick;

4: CREATE PROCEDURE FROM CLASS vposter.procedures.AddMessage;

Page 41: Voltdb: Shard It by V. Torshyn

DB Schema file1: CREATE TABLE messages ( uid BIGINT NOT NULL, nick VARCHAR(64) NOT NULL, ip VARCHAR(16) NOT NULL, text VARCHAR(1024));

2: CREATE INDEX messages_idx ON messages (nick, ip);3: PARTITION TABLE messages ON COLUMN nick;

4: CREATE PROCEDURE FROM CLASS vposter.procedures.AddMessage;5: PARTITION PROCEDURE AddMessage ON TABLE messages COLUMN nick;

Page 42: Voltdb: Shard It by V. Torshyn

DB Schema file1: CREATE TABLE messages ( uid BIGINT NOT NULL, nick VARCHAR(64) NOT NULL, ip VARCHAR(16) NOT NULL, text VARCHAR(1024));

2: CREATE INDEX messages_idx ON messages (nick, ip);3: PARTITION TABLE messages ON COLUMN nick;

4: CREATE PROCEDURE FROM CLASS vposter.procedures.AddMessage;5: PARTITION PROCEDURE AddMessage ON TABLE messages COLUMN nick;

Page 43: Voltdb: Shard It by V. Torshyn

Simple Java Procedure

Page 44: Voltdb: Shard It by V. Torshyn

Putting All Togethersh $ javac -cp "$CLASS_PATH:/opt/voltdb-3.7/voltdb/*" java/vposter/procedures/AddMessage.java

sh$ voltdb compile --classpath=./java/ -o voltdb-catalog.jar /path/to/schema/schema-ddl.sql

# Finaly, run the serversh$ voltdb create catalog voltdb-catalog.jar

Page 45: Voltdb: Shard It by V. Torshyn

Questions?

Page 46: Voltdb: Shard It by V. Torshyn

Agenda

#1: Academic issues: Shard,HP,VP

#2: What is Volt DB? Why?! Volt DB?

#3: Simple Volt DB application(Super Chat)

#4: Tips and Tweaks: you are not supposed to do that at all

Page 47: Voltdb: Shard It by V. Torshyn

Tips and Tweaks

● Java Stored procedures● Schema file: restrictions and syntax● Client code vs Server code● TPS: Performance Testing● Deployment configuration

Page 48: Voltdb: Shard It by V. Torshyn

Java Stored procedures

● Minimize hard math. calculations, I.e. let's client do what it needs

● Minimize SQL queue, i.e. usage of lists/arrays as parameters is real optimization

● Do not return huge chunk of data● To Throw or Not To Throw● Use statuses (application and response)

Page 49: Voltdb: Shard It by V. Torshyn

Schema file: restrictions and syntax

● Use comments● Renaming columns/tables in DDL● Constraint LIMIT PARTITION ROWS● Standard constraints● Views as mechanism of aggregation

Page 50: Voltdb: Shard It by V. Torshyn

Client code vs Server code

● Let server aggregate data, let client process data

● Table-Of-Tables ● Optimize Insertions● Why SELECT * requests are

dangerous?

Page 51: Voltdb: Shard It by V. Torshyn

TPS: Performance Testing

● @STATISTICS usage● @EXPLAIN[PROC] usage● @SystemInformation

Page 52: Voltdb: Shard It by V. Torshyn

Questions?

Page 53: Voltdb: Shard It by V. Torshyn

Referencesl http://odbms.org/download/VoltDBTechnicalOverview.pdfl http://www.mysqlperformanceblog.com/2011/02/28/is-voltdb-really-as-scalable-as-they-claim/l http://voltdb.coml http://techledger.wordpress.com/2011/07/08/voltdb-faq/l http://highscalability.com/blog/2010/6/28/voltdb-decapitates-six-sql-urban-myths-and-delivers-internet.htmll http://www.perfdynamics.com/Manifesto/USLscalability.html#tth_sEc1l [email protected]:vtorshyn/voltdb-shardit-src.git