April 25, 2006
MySQL Cluster API: Hidden Magic
Second session of Tuesday morning at the MySQL UC is Johan Andersson's talk NBD API: Using MySQL CLuster's Hidden Magic. Sitting with Mikael (Ronstrom), one of the original cluster developers who came over to MySQL from Ericsson and is noting some additional details about this stuff (as noted in parens).
The NDBAPI is a transactional native C++ API to access cluster data nodes. Be aware, there is no (or very little) support for this on the forums.
(from Mikael) Using the API gives you monumentally better preformance than going through the MySQL server (which is also built on this API). Mikael can get over 110,000 reads/second on his lone development box running both the storage nodes on the same box (a Dual core 2.8 GHz machine with 2G RAM).
What does it give you?
- Direct access to data with minimum overhead
- synchronous and asynchronous modes of execution
(another note about no support on forums)
Batching and Modes of OperationJohan describes making inserts in synchronous individual inserts, batching them, and batching them asynchronously on a slide.
(Mikael notes using batches to process data is one place where you can get a huge performance boost).
Life of a Transaction
- start the transaction (nothing sent to NDB)
- define operations (read/write etc)
- define colums
- commit (or execute) the transaction - the point where data is actually sent down to the data nodes
- close transaction (even if it fails)
Johan shows a list of the main API classes. A pretty good list that's way too much to cover here. Hopefully slides will be somewhere.
Live ExampleWhat do you need to tap into the API:
- MySQL source code
- configure --with-ndb-docs --with-ndb-cluster --enabled-shared
- make; make install
- headers and libs in /usr/local/mysql/include and /usr/local/mysql/include/ndbapi
DDL operations must be through the MySQL server, can do it through the API but then won't be able to see the tables in the MySQL server.
Johan works through a code example of connecting to the cluster management node, creating a cluster object, connecting to the storage nodes, specifying an operation, committing that operation, and closing the transaction.
This is pretty cool stuff, but likely not something I'm going to be using anytime soon. It is helpful to see the API interface to the cluster to help understand how the internals of MySQL Cluster work.
Posted by mike at April 25, 2006 2:55 PM