Talking to the right shard
In this chapter, we have chosen to represent database shards as PostgreSQL schema names. So, if our basic schema is named myapp
, shard 1 would be myapp1
, shard 15 would be myapp15
, and so on. This is what we call the logical shard name.
Beyond this, shards should be independent of each other such that they can be relocated to another PostgreSQL server arbitrarily. However, if shards can be moved at will, how do we find them? Much like LVM has a physical drive, logical shards have a corresponding physical shard. The physical shard is the server where the logical shard currently resides. Think of it like this diagram:
Elements ...
Get PostgreSQL 9 High Availability Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.