Gorilla keeps its compressed data in blocks of at most two hours, because a query on compressed data decompresses a block from its first value.
Decompression is a linear pass. Compression needs less memory and adds latency, so the blocks are kept short.
A query finds a series in three steps, all in memory:
- The key is hashed to a shard. The shard manager knows which node holds that shard.
- The shard map points to a time series map, and the series there points to its blocks.
- Each block leads to the block two hours later. These blocks are immutable.
Points are appended to a log file, and every 64 KB is flushed to GlusterFS. A flush that fails loses data, and that is accepted.
Every two hours the compressed block is persisted. A restarted instance rebuilds its current block from the log files and loads the older blocks.
A second cluster runs with no consistency guarantee. When one fails, reads go to the other. After 26 hours without a problem both hold the same data.