Skip to content

Latest commit

 

History

History
40 lines (28 loc) · 1.77 KB

MySQLSharding.md

File metadata and controls

40 lines (28 loc) · 1.77 KB

MySQL Sharding at Pinterest

  • MySQL is used to store lot of growing pins data at pinterest.
  • Read more

Shard Config Table

  • It maintains the configuration of which shard on which machine?
  • The config lives in ZooKeeper and, on update, is sent to services that maintain the MySQL shard.
[{“range”: (0,511), “master”: “MySQL001A”, “slave”: “MySQL001B”},
 {“range”: (512, 1023), “master”: “MySQL002A”, “slave”: “MySQL002B”},
    ...
 {“range”: (3584, 4095), “master”: “MySQL008A”, “slave”: “MySQL008B”}]

Recommendations

Title Remarks
Along with sharding, read/write only on master It simplifies everything and avoids lagged replication bugs.

Object ID (Pin ID etc.)

  • This is the ID, used for communicating to various systems (like client apps, microservices etc.)
Bits
Shard ID 16 (64k total shards possible)
Type ID (whether its PIN, board etc.) 10
Local ID (table ID where data is stored) 36
Reserve 2
Total 64

PINs Table

  • Local ID
  • JSON data