News for hackers. Stuff that matters.
Re:Moving from relational data to events by datadeft on Saturday December 16, 2023 @11:42AM (#38665583)
When a comment on HN has more merit than the article.

The only problem with postgres is that inserting has some interesting scaling problems. Putting a queue between the event sources and the db is usually recommended.

Re:Moving from relational data to events by refset on Saturday December 16, 2023 @12:13PM (#38665897)
"normalize until it hurts, denormalize until it works" is evergreen advice for scaling both reads and writes. Synchronously enforcing referential integrity and other forms of normalized constraints is what gets expensive.

Pat Helland has some really good writing on this stuff, e.g. https://pathelland.substack.com/p/i-am-so-glad-im-uncoordina...

Re:Moving from relational data to events by ldng on Saturday December 16, 2023 @12:36PM (#38666136)
And in between, at the coma, revise seriously your indexing policy and don't hesitate to remove unused and underused index (even on foreign key if you don't need them that much). People too often underestimate the impact of rebuilding and index on large inserts.
Re:Moving from relational data to events by refset on Saturday December 16, 2023 @07:38PM (#38669254)
Absolutely, there's no beating the RUM Conjecture.
Re:Moving from relational data to events by withinboredom on Saturday December 16, 2023 @11:54AM (#38665685)
> Putting a queue between the event sources and the db is usually recommended.

Emphasis on _usually_. If your db is at 2% CPU utilization with/without queues ... you probably don't need a queue.

Re:Moving from relational data to events by asah on Saturday December 16, 2023 @12:31PM (#38666094)
see my reply above - one classic case is db system maintenance.
Re:Moving from relational data to events by asah on Saturday December 16, 2023 @12:30PM (#38666091)
thanks! forgot to mention queuing (e.g. SQS), which is SUPER valuable, for example when you want to do large scale maintenance on the database (major version upgrade where the on-disk format can change)
Re:Moving from relational data to events by varelaz on Saturday December 16, 2023 @02:13PM (#38666892)
SQS has eventual consistency, you can get the same message twice on 2 different intances for example (which was often the case for my projects). I would rather suggest Amazon MQ.
Re:Moving from relational data to events by icedchai on Saturday December 16, 2023 @06:27PM (#38668795)
This is often possible to work around by adding a UUID to the message, on the sender side. Then either handle dupes at the DB level by ignoring duplicate inserts, or using something like redis. In practice, even with other queue systems, you can wind up with dupes due to bugs, timeouts, retries, like duplicate sends when the first one actually went through but wasn't acknowledged. I worked on systems sending thousands of messages/second through rabbitmq, originating from various third parties, and dupes would happen often enough that we needed to work around it on the receiving "worker" side.
Re:Moving from relational data to events by withinboredom on Saturday December 16, 2023 @07:59PM (#38669390)
SQS is weird in that you can get the same message in Japan and Germany at the exact same time and "race" to process the message. It's annoying af. I do not recommend SQS unless you are at some kind of scale (in company/team size, not revenue) where you can deal with it properly.
Re:Moving from relational data to events by icedchai on Saturday December 16, 2023 @10:19PM (#38670052)
I used extensively at a previous company for longer running background tasks. It was simpler to use SQS than dealing with standing up our own RabbitMQ cluster. Their Amazon MQ service did not exist at the time. Our system was built to tolerate duplicates and it worked well enough. For something higher volume I'd definitely use RabbitMQ though.
Re:Moving from relational data to events by withinboredom on Sunday December 17, 2023 @02:19AM (#38671005)
A cluster! Yeah, if you have enough messages warranting a cluster, SQS might be simpler (but probably far more expensive). It's always tradeoffs I guess.
Re:Moving from relational data to events by layer8 on Saturday December 16, 2023 @12:48PM (#38666253)
> Putting a queue between the event sources and the db is usually recommended.

That depends on the nature of the events and whether you can live with the database being out-of-date while the events are still in the queue.