This is why I thought you wouldn't want to run Redis as a primary database.
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.
Redis itself is single-threaded because it makes for a very straightforward implementation that is easy to expand with new data structures and easy to grok for users. For 99% of applications, read scaling through replicas and write scaling through keyspace sharding is still more than fast enough, because the biggest time sink is in the latency between servers and not in the execution of the commands themselves. Therefore, multithreading would not win you much throughput except when you have very hot keys containing hashmaps or something like that. In those cases, consider one of the multi-threaded variants.
for good or bad, that means you scale it horizontally by running an instance per core and shard appropriately to that.