Remix.run Logo
arp242 12 hours ago

When I last benchmarked Redis vs. PostgreSQL for a simple k/v cache it was about ~1ms for PostgreSQL to fetch a key, and ~0.5ms for Redis with a similar setup as in this post (although I used "value bytea" instead of "value string" – I don't know if it matters, probably not; 1ms was fast enough that I didn't care to test).

I didn't measure setting keys or req/sec because for my use case keys were updated infrequently.

I generally find ms to be a more useful metric than reqs/sec or latency at full load, as this is not a typical load. Or at least wasn't for my use case.

Of course all depends on your use case etc. etc. In some cases throughput does matter. I would encourage everyone to run their own benchmarks suited to their own use case to be sure – should be quick and easy.

As I rule I recommend starting with PostgreSQL and using something else only if you're heavily using the cache or you run in to problems. Redis isn't too hard to run, but still just one less service to worry about. Or alternatively, just use a in-memory DB. Not always appropriate of course, but sometimes it is.

xyzzy_plugh 12 hours ago | parent | next [-]

A difference of 0.5ms is negligible with single digit network latency. You would need significant batching to experience the effects of this difference.

Of course such sensitive environments are easily imaginable but I wonder why you'd select either in that case.

arp242 11 hours ago | parent [-]

> A difference of 0.5ms is negligible with single digit network latency

Yes, that was my take-away.

Maskawanian 12 hours ago | parent | prev [-]

When you benchmarked Postgres did you disable WAL for the cache table? That may minimize the difference.

arp242 11 hours ago | parent [-]

Unlogged table, yes. 1ms is more than fast enough so I didn't bother to look further.