TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Postgres: A better message queue than Kafka?

65 pointsby tylermcginnisover 2 years ago

14 comments

andrewstuartover 2 years ago
Not just Postgres.<p>You can do exactly this with MySQL and SQL server too because they both support SKIP LOCKED.<p>Interestingly, the plain old file system on Linux also makes the basis of a perfectly acceptable message queue for many use cases - the thing that makes it work is that the file move operation is atomic. Atomic moves are what make queuing systems possible.<p>You could write a file system based message queue in 100 lines of async python, which I did here:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;bootrino&#x2F;arniesmtpbufferserver" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;bootrino&#x2F;arniesmtpbufferserver</a><p>File system based message queues can be written in any language, extremely simple and, most importantly - zero configuration. One of the most frustrating things about queuing systems is configuration - that includes database backed queuing systems. They can also be fast - I wrote one in Rust which maxed out the hard disk&#x27;s random write capability well before maxing out the CPU - from memory it beat most of the common queuing systems in terms of messages per second.<p>Not all use cases for queues need to be able to globally distributed messages queues with the sort of guarantees needed for financial transaction processing. I would suggest to you that in fact most queues out there are used as outbound SMTP queues, which are then over engineered to use something like Celery, which is a nightmare to configure and debug.
评论 #33089257 未加载
评论 #33088293 未加载
评论 #33089969 未加载
hbrnover 2 years ago
A controversial, but a very pragmatic take.<p>Queues are great for semi-infinite scalability, but you rarely need it.<p>There&#x27;s numerous subtle benefits to using db compared to regular message queues that are often overlooked.<p>Being able to delete, reorder, or edit specific messages can be a lifesaver when things go wrong.<p>Most common issue with queue-based systems is getting overwhelmed with messages. Either your consumers went down. Or your producers had a bug &#x2F; executed too frequently.<p>Being able to recover with a simple SQL query is a blessing.
评论 #33088039 未加载
评论 #33090003 未加载
bsaulover 2 years ago
&quot;The write path. We built a daemon that would select log entries that were older than two weeks, copy them into a file in S3, and delete the rows from the database&quot;<p>Seriously... How can you ever consider saying &quot;a rdbms is just fine as a kafka alternative&quot; under those conditions ?
评论 #33088357 未加载
评论 #33087570 未加载
EdwardDiegoover 2 years ago
&gt; Postgres: a better message queue than Kafka?<p>&quot;We didn&#x27;t actually evaluate Kafka for this use case, because we know Postgres, so we used that.&quot;<p>Weird article angle.
评论 #33103108 未加载
lightbendoverover 2 years ago
File this under &quot;If a headline is asking a question, then the answer is NO.&quot; Honestly, I&#x27;m not even sure what point the author is trying to make besides &quot;anecdotally and at low scale, unusual-for-the-purpose technology X solved problem Y.&quot; A near-infinite number of bad patterns can solve problems along happy paths and resolve plenty of edge cases to boot. 99.9% availability was a goal post here? There are systems where 7 9s is unacceptable. The author didn&#x27;t even provide data backing the measurement goals.
评论 #33088342 未加载
评论 #33087167 未加载
chrsigover 2 years ago
Something I think needs to be stated: Kafka is not a message queue. If you need things like work stealing, you&#x27;re going to have a bad time. It doesn&#x27;t seem to apply in this case, but the terminology misuse is going to lead some poor developer astray.<p>It seems like they only tried postgres? so they didn&#x27;t compare it with kafka at all....so yeah, you can make a message queue or log table in a rdbms.
benadam11over 2 years ago
&quot;Many haters want you to buy their message queue product&quot; lol
mannyvover 2 years ago
You can spew messages into sqs then have a lambda on sqs sending to pg.<p>Funny, we were going to use kafka too, but just sending to mysql worked just fine &lt;shrug&gt;. One day that will change, obviously.
评论 #33086636 未加载
srajabiover 2 years ago
I don’t think this article made a compelling reason not to use Kafka. In fact it may have made the opposite point.<p>Wouldn’t it have been easier to just use Kafka?
评论 #33087826 未加载
评论 #33091100 未加载
hk1337over 2 years ago
I don’t want to doubt Postgres’ effectiveness as a message queue (however difficult it may be) but I have to wonder if maybe they were doing something weird or wrong in the consumer for it to be ineffective?<p>Maybe it’s not that Postgres is a better than Kafka as much as Postgres is a better solution for what they were trying to do and use Kafka?
amaiover 2 years ago
“ Today these are not major problems for us, and frankly, I’m not sure how we’ll tackle these problems. Maybe we’ll grow multi-region support and buy really big Postgres boxes. Maybe we’ll move to sharded Postgres. Maybe we’ll switch to Kafka or some other distributed queue. ”<p>LOL
ivankellyover 2 years ago
Since they&#x27;re already doing offload to S3 for older log messages, it seems like they could do this from the get-go and save a bunch of storage and interzone transfer costs in RDS. Depends on the log message sizes though of course.
kennethhover 2 years ago
There is also commercial products like NServiceBus that can use SQL Server as a connector to provide storage. I always used to think about doing this in the database as poor mans message solution. Perfect for small projects.
steeveover 2 years ago
Honestly that&#x27;s comparing apples and oranges. Also, that title is clickbait. It feels like a PR article disguised as a tech article.