Sharding Pinterest: How we scaled our MySQL fleet (2015)

Sharding Pinterest: How we scaled our MySQL fleet (2015)

We created a 64 bit ID that contains the shard ID, the type of the containing data, and where this data is in the table (local ID). Object tables, such as Pins, users, boards and comments, have an ID (the local ID, an auto-incrementing primary key) and a blob of data that contains a JSON with all the object’s data. CREATE TABLE pins (
local_id INT PRIMARY KEY AUTO_INCREMENT,
data TEXT,
ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB;For example, a Pin object looks like this:
{“details”: “New Star Wars character”, “link”: “http://webpage.com/asdf”, “user_id”: 241294629943640797, “board_id”: 241294561224164665, …}To create a new Pin, we gather all the data and create a JSON blob.

Source: medium.com