HNHacker News
TopNewBestAskShowJobs

whisk3rs

77 karma · joined September 9, 2013

submissionscomments
whisk3rs··on Keypress: A Javascript library for capturing input
Nice. This seems to solve a common problem for developers building rich UIs.

On a similar topic, does anybody have any pointers for implementing keystroke-by-keystroke character replacement in an INPUT box that doesn't suck? I'd like users to be able to enter "townhall" but have the input value be "TOWNHALL" and there doesn't seem to be a simple way to do this that doesn't fail when the user uses the arrow key or wants to insert more than one character in the middle of an input box.

whisk3rs··on Scaling with Queues
Thanks for the detailed response. I hope to learn from your experiences.

AMQP is indeed a complicated protocol so I can appreciate your reluctance to write a client.

The failure mode I was referring to with Redis is that you now have additional custom code which pulls from Redis and inserts to RabbitMQ. This is another process that can fail, and some of those failure modes could result in duplicate or lost messages. For example, agentredrabbit could shutdown in an unclean way where the "dump" file doesn't get written. Also, you didn't mention if you're using Redis in AOF or RDB persistence mode, but in RDB it only writes to disk occasionally so you could lose messages there. Also, if agentredrabbit fails then Redis could run out of memory (RabbitMQ automatically writes to disk once memory limits are exceeded).

I will believe that writing to Redis is /always/ faster than writing to RabbitMQ, but I'd really like to know what other things you guys tried to make RabbitMQ actually work for you. Did you experiment with queue settings? Memory limits? Erlang tweaks? SSDs? What was it about shovel that didn't work the way you wanted it to? I'm working towards what I hope will be a pure RabbitMQ infrastructure so knowing what you've tried and didn't try will be informative.

Thanks.

whisk3rs··on Scaling with Queues
I'm curious about the justification for Redis in this pipeline. That seems to introduce additional failure modes. Was it the case that a non-durable non-confirming (in-memory only) RabbitMQ wouldn't satisfy the latency requirements? I'd love to see some benchmarks comparing Redis to an in-memory RabbitMQ.

Pulling data out of Redis and into RabbitMQ seems fraught with problems, whereas you could have the durable RabbitMQ use shovel to pull data out of the faster in-memory RabbitMQ with a few lines of config.

whisk3rs··on Hutch: Inter-Service Communication with RabbitMQ
No problem. Frustratingly, people rarely seem to talk about how they use RabbitMQ in practice. Also, there are a lot of things that are still a mystery to me (for example, best practices for dealing with things like server shutdowns, or what to do when a NACK "fails", etc).

I need to poke around Hutch and steal some ideas for an RPC implementation. We're just using fire-and-forget type work for now, but I'd love to be able to use RabbitMQ w/anonymous reply queues as a workaround for PHP not being able to do asynchronous RPCs.

whisk3rs··on Hutch: Inter-Service Communication with RabbitMQ
Oh, that's great to hear. I'm surprised I didn't find that previously. I vaguely remember trying a php-amqplib and having issues with error messages, but your client promises to be strict-compliant so perhaps I was using an ancient version somehow.

For the sole purposes of producing messages, STOMP and a few dozen lines of PHP seems more attractive to me than using the full library (plain text protocol, easy persistent connections, simple retry behaviors, and no surprises). I'll use your library when we add PHP consumers, though, because consumption is harder to get right.

Thanks.

whisk3rs··on Hutch: Inter-Service Communication with RabbitMQ
RabbitMQ queues support two features that can be combined to implement a deferred retry queue, and RabbitMQ will do all the work for you.

The first is a "message-ttl". This tells RabbitMQ to discard messages after a specified number of milliseconds. The second is a "dead letter queue". Messages that are discarded from a queue can be routed to a dead letter queue automatically.

When we have a job that we wish to "retry later", the framework re-queues the message in a secondary queue with a name derived from the original name. For example, if the original queue was "prod-emailer", the derived queue name might be "prod-emailer-1m" indicating that the contents of this queue are messages originally bound for prod-emailer but were delayed by 1 minute.

This delayed queue is configured with a x-dead-letter-exchange of the original exchange, x-dead-letter-routing-key of the original routing key, and x-message-ttl of 60,000. With this configuration, RabbitMQ handles the timeout automatically. When the message expires from the -1m queue, RabbitMQ sends it back to the exchange and it gets routed to the intended queue by the pre-existing bindings.

The framework expects all messages to be in an "envelope" of JSON which lets us annotate the jobs. When we mark a job for retry, we also increment an "attempt-count" attribute in the JSON. The workers can them implement their own "retry N times" policies.

I haven't thought about how this would work if we were using topic exchanges. We are only using direct at the moment.

whisk3rs··on Hutch: Inter-Service Communication with RabbitMQ
I've built something similar as part of renovations to a large, legacy PHP code base.

We're writing our consumers in Go using some impressively well written AMQP libraries (https://github.com/streadway/amqp) and some custom framework code. The framework code takes care of retries and acking, so the consumers are very simple (in: an envelope, out: fail/done/retry-later). Each worker runs as its own binary. I'm currently adding standardized variable exports for monitoring, and ephemeral queue-based reply capability.

On the PHP side, I found none of the PHP AMQP libraries to be worth using. They all have compilation problems or bugs or seem to be unmaintained. Instead, I'm using RabbitMQ's STOMP plugin w/default login and then wrote a simple TCP client in PHP using persistent connections. The client supports timeouts and multiple backends.

So far, this is working really well. Anybody doing their own RPC implementations using HTTP should take a look at using something like RabbitMQ. It solves a host of real-world problems and introduces much flexibility into your architecture.

← PreviousPage 2 of 2