I've read much of the MySQL Cluster docs and some tutorials yet I still have some things not clear, and the major of them right now are:
Regarding question #2, an update of a row is in the following syntax:
UPDATE db_accounts.tbl_items SET items=items+%lld WHERE id_account=%u
"id_account" is an index (unique).
MySQL Cluster is an in-memory database (although some columns can be stored on disk, indexed columns cannot). If the plug gets pulled, your data goes away. The recovery process for a node re-joining the cluster is that it pulls the data it lost from a surviving node (requiring good fast links between nodes) and then carefully applies replication events until it catches up and can actively participate. If a recent backup is available, it can be rebuilt from that instead of another node, but the principle is the same: the node has to be repopulated with data from scratch.
MySQL Cluster is basically a distributed hash table. The NDB node that holds a particular row of data is determined by a hash algorithm applied to the primary key. Performance increases by adding nodes, assuming that your data spreads nicely across the nodes. Performance can be badly affected if queries have to touch multiple nodes - ie. complex joins - but is lightning fast for retrieving a specific row given its primary key.
Obviously, given that the nodes are distributed, a slow or congested network will badly affect performance.
Even if your MySQL Cluster table is in-memory, by default any writes are asynchronously checkpointed to disk (can turn this off on a per-table basis).
If the entire Cluster failed (power to the data center lost) then when you bring it back up the data will be retrieved from those disk checkpoints. Downside is that as they were created asynchronously you may be missing a handful of updates.
If a single data node fails then as well as recovering from its local disk copy, it catches up by applying the latest updates from its peer data node.
To add further high availability of your data you can use MySQL asynchronous replication to a second site (on the other side of the world if required).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With