Thanks for the detailed response
@Xon. That makes a lot of sense.
A couple of questions:
1) Do compressed tables use RAM more efficiently? I read
conflicting reports--sounds like
sometimes the InnoDB buffer pool stores both a compressed and uncompressed copy of the data, sometimes just a compressed copy, and couldn't find much detailed docs on this.
2) Is the performance hit from compressed tables primarily on writes, or both reads and writes?
3) What block size are you using for your compressed tables?
Default is 16k in MariaDB 10, not sure whether
how much is actually gained by dropping to 8k, and I've read insert times for most workloads are horribly slow if using 4k.
4) Any idea how much of the request processing time for Xenforo is generally in the DB vs PHP interpreter?
I haven't looked into this, just been assuming as a forum grows, DB query time increases while PHP time stays relatively constant.
My use case: I run Nginx/PHP-FPM/MariaDB10. I've got several forums hosted on the same VPS--most are 10+ years old, so they've accumulated a lot of posts that generate a long-tail of search traffic, but overall concurrent activity isn't that high on any one forum. So it's a read-heavy workload for sure. I have plenty of SSD space on this box, so saving disk space doesn't matter. I've also got plenty of CPU headroom, so enabling compression shouldn't cause any issues from a total load perspective, but I assume it still has a minor impact on latency of each request, so all else being equal, I normally wouldn't enable it. It's RAM that I'm tight on, and with those forums each having a long tail of posts, so the more I can fit into the InnoDB buffer pool, the better--I assume any CPU hit will be outweighed by the benefit in decreased times to access RAM rather than SSD. Along these lines, I've read a few places that compression could actually increase performance because it lets more stuff fit in RAM...
https://signalvnoise.com/posts/3571-scaling-your-database-via-innodb-table-compression
Also, for anyone who stumbled across this post later,
@Xon was nice enough to list which tables he compresses here:
https://xenforo.com/community/threads/scaling-database.98161/#post-945458 and good tip about saving RAM by switching to Elastic Search now that it uses
significantly less RAM than the `xf_search_index` table.
Also, be sure you've fulfilled the requirements for using Compressed or Dynamic... MySQL silently fails back to compressed otherwise:
https://www.percona.com/blog/2014/01/14/innodb-file-formats-here-is-one-pitfall-to-avoid/
An easy query to check the row_format of your tables:
Code:
SELECT TABLE_NAME, ROW_FORMAT FROM INFORMATION_SCHEMA.TABLES WHERE ROW_FORMAT='compact'