4 ms·
Note that you can approximate rate-limiting in Redis with Postgres' UNLOGGED tables [0]. They're a lot faster than regular tables since they don't write to the
by VWWHFSfQ 5y ago
Note that you can approximate rate-limiting in Redis with Postgres' UNLOGGED tables [0]. They're a lot faster than regular tables since they don't write to the WAL. Of course, if you restart your server or if it crashes then you lose the table contents. But for stuff like rate-limiting you probably don't care. And unless you're using some kind of persistence in Redis it happens there also.
I tend to run this kind of stuff on a separate PG server so that the query velocity doesn't affect more biz-critical things.
[0] https://www.postgresql.org/docs/current/sql-createtable.html#SQL-CREATETABLE-UNLOGGED https://www.postgresql.org/docs/current/sql-createtable.html...
- jamil7 5y agoNice, Redis is awesome but definitely something I've seen pulled in prematurely all the time.
- simonw 5y agoI hadn't seen UNLOGGED tables before, that's a really neat trick, thanks.
- hcarvalhoalves 5y ago> But for stuff like rate-limiting you probably don't care. I guess you would care in this scenario, otherwise you have cascading failures (something makes pg crash, and the lack of rate limit allows the abuse to continue). So implementing a rate limiter separate from the rest may make sense too. I like their idea of doing it on memory and keeping the load balanced, as it doesn’t rely on any dependency.
- timando 5y agoYou don't lose data on a clean restart.
- VWWHFSfQ 5y agoYes good point! Clean restarts will preserve the data.
- nicoburns 5y agoIf you’re running a separate pg server, doesn’t that remove the main benefit of having everything under one system?
- VWWHFSfQ 5y agoI think the "single dependency" was moreso about the technology stack, not the number of instances of whatever the technology is.
- cortesoft 5y agoThey mention that one of the reasons is having fewer things that can fail and bring down your system... two separate PG systems doubles the failure chance
- voakbasda 5y agoIf you don't maintain redundancy (i.e. more than one instance), you will be 100% certain to have a service outage at some point in your future.
- cortesoft 5y agoSure, but you still have double the chance of failure.. Two distinct PG clusters you depend on are twice as likely to have an outage as one.
- deleted 5y ago[deleted]