tstorage icon indicating copy to clipboard operation
tstorage copied to clipboard

Compress WAL file

Open weeco opened this issue 4 years ago • 6 comments

Another WAL related question: Is it expected to grow really fast? I don't scrape a lot of metrics (I'd guess 1000 metrics / 15s), but after 2 minutes the WAL file has already reached 11MB in file size.

Originally posted by @weeco in https://github.com/nakabonne/tstorage/issues/37#issuecomment-955668821

As noticed in the referenced issue the WAL file gets really big quickly. I wanted to create a separate issue for this to possibly introduce a more compressed way how the WAL file is written.

Maybe you can recommend a workaround to reduce the size of the WAL file. I assume smaller partitions could help with that?

weeco avatar Nov 02 '21 11:11 weeco

Thank you for the separated issue for that!


To be honest, the current WAL format prioritizes simplicity. I'm in the middle of looking for another format that reduces the size and doesn't slow down writing and recovery.

Originally posted by @nakabonne in https://github.com/nakabonne/tstorage/issues/37#issuecomment-955685599

nakabonne avatar Nov 02 '21 12:11 nakabonne

Maybe you can recommend a workaround to reduce the size of the WAL file. I assume smaller partitions could help with that?

As you mentioned, the smaller the size of the partition, the smaller the size per file. But in the end, your overall disk consumption will remain the same.

nakabonne avatar Nov 02 '21 12:11 nakabonne

But in the end, your overall disk consumption will remain the same.

Is that actually the case? If the lifetime of the WAL file is up to partitionRetention before it is rolled, we can reduce the max wal file size by reducing the partition retention as well right?

Since the WAL file is relatively large (compared to the disk files) it could be worth to reduce the partition retention is that right?

weeco avatar Nov 02 '21 13:11 weeco

Ah, you're right.

That workaround works well since all except for the first two partitions will be flushed to disk partitions and the WAL files for them will be deleted 👍

nakabonne avatar Nov 02 '21 13:11 nakabonne

Just to add some numbers:

My 1h partition is 16MB in size and 2 WAL files take 1GB space.

weeco avatar Nov 04 '21 22:11 weeco

Hmm... it is common to set PartitionDuration=1h so it's terrible to require 1GB for WAL.

nakabonne avatar Nov 05 '21 01:11 nakabonne