Hacker Timesnew | past | comments | ask | show | jobs | submitlogin

I just talked about pipes as a useful conceptual tool. You’re assuming what applications I think they apply to. But I’ll do my best.

One of my takeaways is that if you do not handle on data transfer in the http request/response then you are choosing to exit the pipe model. Once you do that, yes all kinds of crazy async problems exist which require very complex tools to wrangle.

See the sibiling comment from Google engineer. It’s better to do work synchronously than delay it until later.

So now we get your list of requirements that MQ is for. Ok but how did we get here? What problem are we trying to solve? The answer is usually a performance problem for which this is a bandaid.

Another possible model for this problem is email. You can find some great threads here about large amounts of infrastructure being replaced with Unix email tools. Although I have yet to try it!

> If every consumer that ever wanted to fetch a message had to issue a network RPC poll/timeout cycle, and they were all doing that constantly, that'd be both a lot of traffic for the MQ to handle and a lot of network chatter

This makes no sense to me. A while loop blocked on a socket read with a producer with a write does not generate any extra network “chatter”.

Anytime you are using callbacks you are choosing not to have a thread with imperative logic.

> I don't think your other points support this

Correct that was not a conclusion.

What I’m trying to say is if you want to send data between two systems and you have producers and consumers at different rates, you don’t have to do anything special. The UNIX kernel is designed to solve this problem.

So when I hear that, my inclination is that we don’t understand the capabilities UNIX already offers and I’ve yet to be wrong.



> The answer is usually a performance problem for which this is a bandaid.

I agree that if that's the problem you're trying to solve, MQs are a poor stop-gap and not a general-purpose solution.

But many (most?) MQs aren't deployed for that reason; rather, they're used to either a) defer work whose latency characteristics are incompatible with the producer's runtime (e.g. sending email which might take minutes/hours to be accepted upstream can't be done synchronously from an HTTP request handler), b) handle work which doesn't need to be done transactionally and which has a high probability of needing to connect to resources whose uptime you don't control (queues make retries easy), or c) work that needs to be batched or otherwise completed on a schedule or dimensionality that's not available in the producer.

> A while loop blocked on a socket read with a producer with a write does not generate any extra network “chatter”.

True, and some MQs support that pattern, but it's rare for the same reason that most network server applications' core loop doesn't wrap a blocking read. While-blocking-read plays poorly with timeouts, restarts, and multiplexing/wait-any. This isn't unique to MQs.

> Anytime you are using callbacks you are choosing not to have a thread with imperative logic.

I mean, it's pretty easy in most languages/runtimes to turn a callback into an imperative wait. When it comes to network servers specifically, I think exposing the lowest-runtime-overhead model as the primary API (selectors and callbacks) and letting users add control flow primitives on top of that is preferable, but reasonable minds can differ here. This also isn't unique to MQs.

> if you want to send data between two systems and you have producers and consumers at different rates, you don’t have to do anything special. The UNIX kernel is designed to solve this problem.

For ephemeral/can-be-lost local traffic, you're partly right (pipes/fifos are a simple and widely available tool that can help with this, though you have to layer some protocol-ish logic on top to make them work reliably between consumers that expect particular structures and don't speak ASCII/newlines alone). For durable local traffic, or remote traffic, UNIX doesn't have a prebuilt primitive. TCP tx/rx window sizes aren't surfaced such that buffers and backpressure can be reliably interpreted by userland to make delivery decisions.


Thanks for high quality reply.

> latency characteristics are incompatible with the producer's runtime

> handle work which doesn't need to be done transactionally and which has a high probability of needing to connect to resources whose uptime you don't control (queues make retries easy

I agree. I think you do need to break the request/response pipe for this use case.

I traditionally have treated this as a state in a database. I know there are limitations and I can see MQ being a solution. I want to try the email idea sometime.

I do think queues are a poor technology for dealing with performance problems in a web stack.

> This also isn't unique to MQs.

Agreed. My ranting about async and callbacks is an ongoing project.

I think pipes solve producer/consumer problems in a way most engineers don’t appreciate.

> While-blocking-read plays poorly with timeouts, restarts, and multiplexing/wait-any.

The primary problem solved by not using blocking primitives is to try to free up OS resources from threads (green threading). Why would an internal queue have that problem? It’s not accepting arbitrary connections.


> Thanks for high quality reply.

Likewise; thanks for engaging constructively as well.

> I traditionally have treated this as a state in a database.

Which is a super appropriate tool many (most) times! I've been using "MQ" in this context refers to the conceptual capability to externalize/distribute/persist work with a push/pop API. That can be provided by a database, a UNIX pipe, or a more traditional message broker--the reasons-to-adopt and costs/benefits are largely the same.

> I want to try the email idea sometime.

Email (and the print spool) are some of the oldest message-queue primitives on UNIX systems, I think? I'm not sure if POSIX/shmem MQs predate them or not, but they're all quite venerable proofs that the pattern has its uses. I'm sure you can (maybe others already have?) use SMTP and the mailq to manage application-internal queue communication. I'm not sure how low-overhead or performant it'll be given that it's highly optimized for one/very few consumers and delivery attempts >1 being attempted on a pretty large time scale compared to application traffic, but it'd be an interesting experiment to be sure!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: