Title: SQLite vs Redis
Last modified: April 15, 2023

---

# SQLite vs Redis

 *  Resolved [eriky82](https://wordpress.org/support/users/eriky82/)
 * (@eriky82)
 * [3 years, 1 month ago](https://wordpress.org/support/topic/sqlite-vs-redis/)
 * Hi, I’ve been testing this plugin on a smaller site of mine. It works great! 
   I glanced over the code and it seems well-built. So thank you for creating this!
 * I just enabled it on a bigger site that gets lots of visitors. It seems to do
   fine there as well. Not sure how large the cache will grow, so that’s something
   I’ll monitor for now.
 * I used the Redis object cache plugin before, but I’m trying this one because 
   it’s easier to maintain. Not needing a Redis server and managing multiple site
   id’s manually is one less thing to worry about.
 * Having said that, can you (the author) tell more about how this performs compared
   to Redis? I imagine the SQLite file is cached in memory by the OS or perhaps 
   even by PHP-FPM? That should help a lot. And we all know SQLite is pretty amazing,
   performance-wise. Has there been any performance tests? Am I crazy to use this
   one over Redis for the reason mentioned (easier maintenance)? 🙂

Viewing 8 replies - 1 through 8 (of 8 total)

 *  Plugin Author [OllieJones](https://wordpress.org/support/users/olliejones/)
 * (@olliejones)
 * [3 years, 1 month ago](https://wordpress.org/support/topic/sqlite-vs-redis/#post-16657970)
 * Thank you for using this with a large site! I don’t have large site benchmarks
   to offer you, so I would be grateful if you would send me yours, maybe by posting
   them here.
 * As for SQLite doing memory caching, my code uses [Write-Ahead Logging](https://www.sqlite.org/pragma.html#pragma_journal_mode)
   in SQLite. This provide a mixture of RAM caching and file system use. Using this
   plugin drives up per-php-fpm-process RAM usage and IOPS. That could get costly
   in server-provisioning charges.
 * What’s the “Total cost of operation” including RAM, IOPS, and administrative 
   time / hassle? I hope you’ll contribute some real-world experience to helping
   understand that.
 * The plugin’s Statistics panel shows descriptive statistics about time taken for
   cache operations. I find the 95th percentile stats useful. If you can think of
   anything else the plugin should measure, please let me know.
 * It would also be great to hook up the stats measurement in the plugin to monitoring
   tools like Nagios or Cacti or whatever. I don’t know enough about those tools
   to specify that interface myself. If somebody who DOES know about that kind of
   tool will tell me what to implement, I’ll do it.
 *  Thread Starter [eriky82](https://wordpress.org/support/users/eriky82/)
 * (@eriky82)
 * [3 years, 1 month ago](https://wordpress.org/support/topic/sqlite-vs-redis/#post-16658231)
 * I created [a screenshot of the performance stats](https://ibb.co/YhcdKTJ). I 
   have nothing to compare it to, but it’s humming along fine so far. It’s not very
   scientific, but the site doesn’t seem to be slower or faster than with the Redis
   object cache.
 * The cache and wall files are around 22MB each (after running for half a day).
 * Another plus for this plugin is that it also works on the staging copy of my 
   site. The Redis object cache always complains about a foreign drop-in or something;
   plus, you don’t want to pollute your cache with staging data anyway. This plugin
   is nicely contained in the current directory tree. In addition, I reckon it’s
   easier to migrate a site to another server; it will even migrate the cache 🙂
   It just makes things less complicated.
    -  This reply was modified 3 years, 1 month ago by [eriky82](https://wordpress.org/support/users/eriky82/).
    -  This reply was modified 3 years, 1 month ago by [eriky82](https://wordpress.org/support/users/eriky82/).
 *  Plugin Author [OllieJones](https://wordpress.org/support/users/olliejones/)
 * (@olliejones)
 * [3 years, 1 month ago](https://wordpress.org/support/topic/sqlite-vs-redis/#post-16658981)
 * Thanks for this information!
 * And, be careful to put your cache on local SSD / HDD storage, not a remote, shared,
   or NFS drive. `/tmp` is a good choice. Explanation about how to do that is [here](https://wordpress.org/plugins/sqlite-object-cache/#i%20want%20to%20store%20my%20cached%20data%20in%20a%20more%20secure%20place.%20how%20do%20i%20do%20that%3F).
 *  Thread Starter [eriky82](https://wordpress.org/support/users/eriky82/)
 * (@eriky82)
 * [3 years, 1 month ago](https://wordpress.org/support/topic/sqlite-vs-redis/#post-16659065)
 * Good point. I do use fast SSD memory. In addition, the VPS has 16G of memory,
   a large part of which is used as disk cache thanks to Linux’s excellent [disk caching mechanism](https://www.linuxatemyram.com/index.html).
   So I’m guessing a frequently accessed SQLite file will be in memory most of the
   time. If you have enough spare memory, I bet this can be as fast as using Redis.
 * I think the hidden dot files are safe enough, but it’s good to know we can use
   something like /tmp or even a memory disk.
 *  Plugin Author [OllieJones](https://wordpress.org/support/users/olliejones/)
 * (@olliejones)
 * [3 years, 1 month ago](https://wordpress.org/support/topic/sqlite-vs-redis/#post-16661331)
 * Again, thanks for the information.
 * A question for you, as a large-site administrator: The plugin does not (yet) 
   contain any way to limit the size of the cache to a preset number of MiB. That’s
   something redis does automatically. Is that a feature I need to add?
 * I could easily implement a least-recently-written scheme to discard old entries,
   or a random-choice scheme. Least-recently-used will necessarily be a bit slower
   because it requires a database update for each cache READ to keep track of time-
   of-use. That seems wasteful to me.
 * The current version does age out old cache entries. It removes transients at 
   their time of expiry, and other entries after a configurable number of hours.
 *  Thread Starter [eriky82](https://wordpress.org/support/users/eriky82/)
 * (@eriky82)
 * [3 years, 1 month ago](https://wordpress.org/support/topic/sqlite-vs-redis/#post-16663022)
 * My site doesn’t have an insane amount of posts. The cache is 26MB right now (
   that’s the largest I’ve seen it grow so far). I think sites with many pages and
   posts would eventually hit memory limits if you don’t limit the cache size.
 * So yes, perhaps such a feature would be desirable. Ideally you’d have a choice
   between LRU eviction and random eviction 🙂
 * On the other hand: if your site is that large, maybe you’re better off using 
   Redis. So you could opt to keep this plugin plain and simple and put up a warning
   somewhere about the cache size being unbounded.
 *  Thread Starter [eriky82](https://wordpress.org/support/users/eriky82/)
 * (@eriky82)
 * [3 years ago](https://wordpress.org/support/topic/sqlite-vs-redis/#post-16698992)
 * I’ve been using the latest version for a few days now. Seems to work fine.
 * I set the cache to a max of 20MB. The file size grows to 28MB. The “All Groups”
   item size grows to 19.385 MB (30,002 items). So it seems you’re looking at the
   items size and not the file size, correct?
 *  Plugin Author [OllieJones](https://wordpress.org/support/users/olliejones/)
 * (@olliejones)
 * [3 years ago](https://wordpress.org/support/topic/sqlite-vs-redis/#post-16701608)
 * Yes, the size of the cache keys plus values. The size of the actual cache file
   will be larger, because of
    1. the index on item timestamps.
    2. any performance measurements (which go into the same SQLite database file).
 * The plugin [VACUUM](https://www.sqlite.org/lang_vacuum.html)s the database whenever
   it purges older entries to keep the keys+values size under the target maximum
   size.
 * Thanks for the feedback.
    -  This reply was modified 3 years ago by [OllieJones](https://wordpress.org/support/users/olliejones/).

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘SQLite vs Redis’ is closed to new replies.

 * ![](https://ps.w.org/sqlite-object-cache/assets/icon-128x128.jpg?rev=2829632)
 * [SQLite Object Cache](https://wordpress.org/plugins/sqlite-object-cache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/sqlite-object-cache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/sqlite-object-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/sqlite-object-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/sqlite-object-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/sqlite-object-cache/reviews/)

 * 8 replies
 * 2 participants
 * Last reply from: [OllieJones](https://wordpress.org/support/users/olliejones/)
 * Last activity: [3 years ago](https://wordpress.org/support/topic/sqlite-vs-redis/#post-16701608)
 * Status: resolved