Hacker News new | ask | show | jobs
by theptip 1462 days ago
For a simple low-scale app you can often do without Redis and Celery/RMQ if you just push everything into Postgres.

Far less scalable, but it is dramatically simpler to deploy. Often gets you surprisingly far though. Would be interesting to know how many monitored integrations could be supported by that flow.

2 comments

I bet quite a lot, probably at least 10-50 per second without doing anything special for performance, i.e. multiple queries per alert, calling different APIs, things like that. I don't know of many places that are dealing with alerts measured in "per second" as a unit.

Not to mention that having multiple components doesn't mean it's "scalable" by default, it could happen that some part of the pipeline doesn't like multiple instances of something.

How does a message queue work via Postgres? Many people (including me) use Redis to run background jobs.
This is a very confused question. The data store you keep your queued items in is completely orthogonal to what a message queue actually is.

A simple way to use an RDBMS as a message queue, that has been in use since before most HN readers were born, is roughly:

  - enqueue an item by inserting a row into a table with a status of QUEUED
  - use a SELECT FOR UPDATE, or UPDATE...LIMIT 1, or similar, to atomically claim and return the first status=QUEUED item, while setting its status to RUNNING (setting a timestamp is also recommended)
  - when the work is complete, update the status to DONE
There are more details to it obviously but that's the outline.

The first software company I worked for was using this basic approach to queue outbound emails (and phone and fax... it was 2005!), millions per day, on an Oracle DB that also ran the entire rest of the business. It's not hard.

Here's the option I'm familiar with (siblings have others too):

https://github.com/malthe/pq

Doesn't have all the plumbing you'd want, there is a wrapper (https://github.com/bretth/django-pq/) that seems to give you an entrypoint command more like `celery worker ...` but I've not investigated it closely.