Pros/Cons of using compression on LXD containers on webserver w/HAProxy?

Using LXD + HAProxy to isolate various websites to their own containers (rather than going the Apache virtualhost route) and am wondering about whether or not it’s a good idea to use compression on the lxd zfs dataset.

The way I setup the LXD dataset is directly under the pool as mypool/lxd then give that as the existing zfs dataset to use during lxd init setup.

On my laptop where I test things out I setup mypool/lxd with compression and it works fine. Basically all the mypool/lxd child datasets (maybe other than snapshots) are set with compression & work fine as far as I can tell.

But for a webserver, are there any pros or cons to setting mypool/lxd up with compression?

I would imagine that compression of maybe 2x would basically double how much data can be moved by the disk in roughly the same amount of time it takes to do the same with 1x/uncompressed data. So basically more disk throughput.

But on the other side of things, the CPU has to do more work compressing & decompressing everything.

I suppose it’s possible that higher disk throughput via compression, despite more CPU overhead, could still result in speedier LXD webservers. Or maybe it slows them down.

To go even deeper on the issue, maybe lz4 compression does 2x but zstd compression might get close to 3x resulting in more disk throughput, but more CPU work.

I guess overall I’m trying to figure out if it would be a net benefit or a net negative to enable compression on the mypool/lxd dataset. And beyond that, if lz4 or zstd (or another compression algorithm) would be best in this scenario.

In case it makes any difference, the webserver would be handling various static text files, html files, php files, MySQL databases & image files. Fairly typical webserver stuff.

Thanks in advance for any advice & input on this.

I think this is a no brainer, i’ve set compression on as the first thing on any pool I’ve created as long as I can remember (in the last 10 years at least). Never saw any ill effects, even on low end ARM powered NASes.

Thanks for your reply.

Which compression algorithm do you usually use?

Are any of your use cases with running LXD containers as web servers?

90% lz4 as my workloads are mostly CPU intensive

However, I’ll soon be revisiting that as there are major changes in that area in zfs2.2 https://news.ycombinator.com/item?id=36588240

Almost all of my containers are running some kind of web server, but mostly app backends, so not too many static files, and even then they are cached at the CDN level.

The zfs block cloning / improved deduplication discussed in that ycombinator thread does seem quite interesting as well as the zstd early abort stuff.