TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Code rant: The Database As Queue Anti-Pattern

13 点作者 FrancescoRizzi大约 13 年前

8 条评论

btilly大约 13 年前
The database is not the world's most efficient way to do this. However if it isn't a bottleneck, who cares? It is one less dependency to maintain, understand, etc.<p>We're looking to create working solutions, not works of art. Seeking the perfect component for every piece is often simply not worthwhile.
评论 #3920512 未加载
redcircle大约 13 年前
I find it ironic that he writes this as a rant, which is an anti-pattern for influencing people. One of his commenters hints at how it might have been better presented: introduce messaging systems, explain how they solve the problem, and describe their advantages over the database. For further discussion on why a rant is probably an anti-pattern, see Dale Carnegie's "How to Win Friends and Influence People."
tarr11大约 13 年前
Using databases as a queue is not an anti-pattern (delayed_job is an example).<p>A full blown message queue system is often overkill; it adds another system that you have to learn. (And frankly, queues are often backed by databases anyway)<p>That said, it's best to avoid having application state in the queue, it should be generic. This makes it more scalable and flexible.
评论 #3919595 未加载
gaius大约 13 年前
But no-one polls a database anymore; they all have a callback mechanism an app can just subscribe to.
dclaysmith大约 13 年前
I use MySql+cron as a simple message queue every now and again--it's great for jobs like sending confirmation emails or registering new users for a mailing list. ie. Tasks that make synchronous calls over the network and can degrade the speed of important processes (registration, etc). You just have to make sure that these tasks are going to be infrequent and not prone to spikes that might overwhelm the server.
jgrahamc大约 13 年前
A lot of that post is specific to SQL Server. I used a MySQL table as a queue as part of Signal Spam (<a href="https://www.signal-spam.fr/" rel="nofollow">https://www.signal-spam.fr/</a>) and it worked flawlessly. Polling was at 1 minute intervals and queue entries that were completed were simply deleted.
评论 #3919772 未加载
pbreit大约 13 年前
I would be happy to use something else but every time I start to look at ZeroMQ or celery, I lose interest and just go back to the DB which surprisingly, seems a lot easier to use. Is there a delayed_job for Python?
tszming大约 13 年前
Let's face it, not all systems in the world need to be "web scaled", as the author also said: "Simple, use the right tool for the job".<p>But you need to understand not all jobs are created equal..