Professional Documents
Culture Documents
MySQL Cluster - Voxxed Days Belgrade 2015
MySQL Cluster - Voxxed Days Belgrade 2015
Bogdan Kecman
MySQL Principal Technical Engineer
Bogdan.Kecman@oracle.com
1
Safe Harbor Statement
The following is intended to outline our general product direction. It is intended for information purposes only, and may
not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should
not be relied upon in making purchasing decisions. The development, release, and timing of any features or
functionality described for Oracle’s products remains at the sole discretion of Oracle.
2
Industry Leaders Rely on MySQL
Cloud
3
MySQL Powers The Web
”Many petabytes” of data. 11.2 Million Row changes & 2.5 billion
rows read /sec handled in MySQL
4
The #1 Database in the Cloud
SaaS
5
Architectural overview
6
Who’s Using MySQL Cluster?
MySQL Cluster Architecture
8
MySQL Cluster NODES (1/2)
• Fragmentation
• Table data is split among data nodes
• Synchronous replication
• Each fragment is stored NoOfReplicas times
• Heartbeating
• Automatic failover
• Online backups
• Online Updates
11
High Performance
• Performance boost
• In-memory
• Shared IO load
• As many SQL/API nodes as you like (up to 200)
• Direct access trough NDB API
• Performance killers
• Network (latency creates big problem)
• With 1gbit nic up to 10 data nodes works without problem
• With modern 10gbit nic up to 40 data nodes can run ok
• Joins
• Huge improvements in 7.4 but still joins on distributed data are always
going to suffer performance, especially on slower network
• Blobs
12
Scaling
• Up to 254 nodes
• Geographical Replication
• Multi channel replication (note it is always idempotent)
13
Accessing NDBCLUSTER data
• SQL (via MySQL connector/php,java,ruby,python..., odbc, MySQL C-API..)
• MEMCACHED (add ndbcluster driver to memcached server)
• ndbAPI (C/C++ API)
• ClusterJ, JPA, ClusterJPA, LDAP
Apps Apps Apps Apps Apps Apps Apps Apps Apps Apps Apps Apps
JPA
ClusterJPA
14
ClusterJ/JPA
httpd memcached
hash key
PHP/Perl memcached
to find data
Memcache
friends:12389 memcached
memcache key
NDB & Memcache Architecture: Memcache protocol + NDB storage
MySQL
Cluster
Application
memcached Data Node
key value
<town:maidenhead,SL6>
Application view
SQL view prefix key value
<town:maidenhead,SL6>
NdbTransaction * t = ndb->startTransaction();
if (t == NULL){
printerr(“could not start transaction\n”);
return (-1);
}
NDB API
Getting an NdbOperation Object
•An NdbOperation object is created with the getNdbOperation
•A table name or a NdbDictionary::Table* needs to be provided
NdbOperation * op = t->getNdbOperation(“tab1”);
if (op == NULL){
//handle error
}
NDB API
Defining the operation type
•insertTuple()
•readTuple()
•writeTuple()
•updateTuple()
•deleteTuple()
op->readTuple();
NDB API EXAMPLE (pk access)
NdbTransaction * trans = ndb->startTransaction();
if (trans == NULL){ printerr(“could not start transaction\n”); return (-1); }
NdbOperation * op = trans->getNdbOperation(“City”);
if (op == NULL) return -1;
op->readTuple();
int population = 0;
op->getValue(“Population”, (char*)&population);
char name[35];
op->getValue(“Name”, name);
if (trans->execute(NdbTransaction::Commit, NdbOperation::AbortOnError, 1)
== -1){
printerr(“transaction was not successful\n”);
return (-1);
}
trans->close();
printf(“The City %s has the population of %d\n”, name, population);
NDB API
Joining tables
•Joining tables with NDB API is way more complex then with SQL
•The basic principle is easy – nested FOR loops
•The method for retrieving the rows depends on the tables
involved and possible indexes
•It is very difficult to do dynamic optimization
•In principle the join method has to be decided when creating
the program (coding time)
SQL vs NDB API speed comparison (reads/second – note logarithmic Y axes)
Thank You!
Questions?
Bogdan Kecman
MySQL Principal Technical Engineer
Bogdan.Kecman@oracle.com 32