4 ms·
Just be careful if you use these as keys for a distributed system that is susceptible to hotspotting. GCP's Cloud Spanner [1] has this problem and has a good do
by advisedwang 6y ago
Just be careful if you use these as keys for a distributed system that is susceptible to hotspotting. GCP's Cloud Spanner [1] has this problem and has a good document explaining it.
As always - understand what is going on in your stack and apply design with that in mind. There are no universals!
[1] https://cloud.google.com/spanner/docs/schema-design#primary-key-prevent-hotspots https://cloud.google.com/spanner/docs/schema-design#primary-...
- crescentfresh 6y agoI had to pause when they use the term "anti-pattern". It may be an anti-pattern for cloud spanner but it's not an anti-pattern in other distributed systems, for example cassandra.
- zug_zug 6y agoRight. This spanner thing is new to me, but looking at it, I don't see why spanner doesn't/couldn't shard by modulo / checksum to reduce this risk. And I think other systems do
- electricshampo1 6y agoIt shards it this way (by primary key ranges) to support efficient range scans.
- zug_zug 6y agoGood point. I guess it would be cool if you could choose the sharding method per-table. I haven't put too much thought into this, but off the top of my head I can imagine a number of different methods suitable for different situations.
- majormajor 6y agoThe very next word after "anti-pattern" is if. "The following table definition that uses a timestamp-based primary key as the first key part is an anti-pattern if the table will see a high rate of insertion:" Once your data gets big enough there's no easy one-size-fits-all. You gotta look at how you're going to be using the system.