This is why I thought you wouldn't want to run Redis as a primary database.
If you don't need transaction commits to be durable, you can turn that off in postgres, on a per-transaction/connection/user/database basis. E.g.
BEGIN;
SET LOCAL synchronous_commit = off;
/* bunch of writes */
COMMIT;
will, just for that one transaction, not wait for transaction commits to be flushed to disk. Can be very useful for not-that-important data...What you really want is 2 replicas in a shared-nothing environment, and use min-replicas-to-write.
You can’t scan 1 year of data every time, so now you need some type of external process that can either pre-compute those metrics (not flexible) or a compaction type process that makes it manageable to scan all that data.
Which is basically the trade off between something like stream processing or compaction in a database.
I remember when I thought it was a great idea to use Elasticsearch as a primary database. The decision was a mistake
A query engine is a very powerful and useful layer of abstraction that you end up having to recreate in your application code for every scenario where you need some data. It’s complicated, it’s hard to get right and it really slows you down.
My recommendation would be: don’t do it.
Easier to scale out than either a cloud based or on-prem database possibly?
If you are in the cloud and have any hint of using kubernetes then DO NOT USE redis as a persistent store. The problem is that redis' master/slave and replication pattern goes against the load balancing and Service objects of kubernetes. Redis was created in a time when it expected physical nodes to be available 24/7 and is not designed for nodes to go away. It can handle it but it isn't designed for it. Two different things.
Redis as a single pod and a cache works great. I would never use redis as a DB. We have DBs specifically designed to be DBs.
The best solution I found was running keydb in a multi-master, multi-replica mode. All of the pods are masters, any pod can be written to and the keys will be copied over to the other masters/replicas. Performance is decent too.
The impedance match between redis and most programming language data structures is just really perfect; Redis supports all of the structures (arrays, maps, etc) that you'd expect, and a few you wouldn't (bloom filters, for example).
Also, it has some really odd security choices and just generally a lack of focus on security at all. It didn't even have any password at all for the first few years -- anyone could connect to it and just do whatever they wanted (and, in fact, you could even gain access to the OS!) It's also pretty hard to start up securely in the cloud (by default, it binds to every interface instead of just localhost, or at least the last time I checked, although you can override this in the config.. just be careful about that, because this lack of emphasis on security seems to run through it.)
Again, as a very fast and flexible cache that supports a million different datatypes and has real big-O performance guarantees, it is superb.
But these days, if you want a primary production database, you should just default to postgresql, unless you already have a solid reason to choose something else. If you don't know SQL, you should learn, but until you're really ready to, just use an object relational mapper (ORM) for your programming language and that will turn postgresql basically into MongoDB or similar, but with all the power of SQL behind it.
It usually means that the bytes are in the drive's cache, not that it's on disk. In theory, the disk can write the cache if the power is cut.
Even then, the disk can fail.
The safe thing is a shared-nothing replica, but you need 2 of them to have availability. 3 if you are worried about bit-flips causing your 2 replicas to disagree.
With Mongo you can still use Schemas, and migrations are pretty easy.
We still used redis extensively but not as a persistence layer.
Cosmos was expensive. I mean, really really expensive. Microsoft promised it would solve a lot of our problems and I'm not fully convinced it ever did.
The client was insanely bizarre, the protocol was very complex and convoluted and the library code was almost (or maybe it ultimately was) transferred to ZEIT's ownership since we were pretty much the only ones working on it at the time. Microsoft certainly wanted to have some agreement about that; to what end, I'm not sure.
I remember a lot of headaches. We were also entirely on our own with it as it was pretty opaque to work with. Very little public examples and we had to contact Microsoft quite a lot for help if memory serves.
IMHO, no. Unless! you can ensure your data is less than the size of memory. Redis must fit all the data into memory. If you run out of memory Redis doesn't have great options (besides buy more memory). In my mind a primary database handles the complexities/speed of pulling data from a disk, manipulating data in memory and scales with more disk. Redis manipulates data in memory only.
Redis is rad for specific group of problems.
In that case, it is better than other databases, being extremely performant, and more importantly, being very easy to develop for.
If you need more space, you can use Redis cluster to extend horizontally.
It depends, like everything.