4 ms·
> For simple dequeuing, deserialization, execution, and updating stats (as with the Hello worker above), goworker is 80x faster than Resque and 23x faster than
by jrochkind1 13y ago
> For simple dequeuing, deserialization, execution, and updating stats (as with the Hello worker above), goworker is 80x faster than Resque and 23x faster than Sidekiq.
In real world use cases, how often is that kind of overhead a significant portion of total run time, compared with the actual work? If it's a small portion, would that make the speed up fairly irrelevant, does it actually speed up real world use cases significantly?
Of course, your actual work payload may be faster too in go than ruby if you know how to write it well.
- bradleyland 13y ago> In real world use cases, how often is that kind of overhead a significant portion of total run time, compared with the actual work? I wish more people paid attention to questions like this. Be it web servers, app servers, whatever; too many people look at microbenchmarks and decide that a move is imperative when they're really only optimizing a tiny fraction of the total run time. > Of course, your actual work payload may be faster too in go than ruby if you know how to write it well. I think that this is the big bet you're going to make when you choose goworker over a Ruby implementation. What makes this intriguing is that in a web app scenario, background workers are often used for tasks that would take too long to run in the HTTP request/response cycle. This means there is a selection bias toward tasks that may be computationally difficult. That's not to say that all tasks handed off to background workers are CPU bound; many (most, maybe?) are I/O bound, but for the class of problems that are CPU bound, this offers a great solution.
- derefr 13y agoBut for the CPU-bound cases, people are usually calling into a library implemented in C either way (this is why Resque uses a forking model instead of green threads, after all.) The only speed-up you'll get is in the glue, because the task itself will probably use the same C library.
- bradleyland 13y agoIf you're already doing the majority of your work (total run time) in C code, then of course you're not going to benefit from a Golang back-end, but I'd challenge the "usually" portion of your claim. C wrapped in Ruby is not the same as pure C or Golang. The tool-selection argument quickly devolves in to the usual arguments between the benefits of languages like Ruby versus lower level languages, but I'm not sure that's the most productive conversation. That's well traveled ground. What I'm saying is that I'm happy to see this (Golang workers available through a Resque API) as an option. I'm not advocating blindly replacing C implementations (or any other implementation), but I wouldn't be surprised to see a Golang back-end outperform Ruby code, even when that Ruby code is calling in to C libraries. The usual rules apply when making that evaluation. You have to see for yourself.
- benmanns 13y agoYes! I think you capture my intent with goworker. I like to think of it as a halfway point between pure C or C extensions and pure Ruby.
- sanderjd 13y agoI would actually expect the simple dequeue-deserialize-update-something-in-redis use case to be the "worst case" comparison and that the more work the go worker does, the better the performance numbers would look. It seems like using something designed from the start for cross-technology communication (like 0mq) may be a better idea, but I suppose there is already lots and lots of existing resque client code out there.
- benmanns 13y agoYes, this is exactly what I was thinking. You can replace one single Resque worker to see how the performance improves without changing the front-end queuing or having to run an additional queuing server
- steveklabnik 13y agoSince jobs are just encoded as JSON into Redis, it's pretty already cross-technology compatible. Furthermore, we're committing to a format specifically for Resque 2.0, so you can guarantee that you'll be interoperable.
- sanderjd 13y agoNeat. I really like the idea of Resque being able to be thought of as a protocol specification plus a reference client and server implementation.
- benmanns 13y agoYou're right that this is less significant if you are hitting an empty queue (triggering a timeout) between each request. However, even when not comparing (seconds to computer 10000 jobs) benchmarks, you still get benefits from goworker. Since dequeuing, deserialization, and updating stats is faster, the latency between "job insert" and "job started" is lower, which means faster interface updates. You can also restructure your workers. Instead of running one worker that loops 5,000 times because the Redis overhead is too high, you can have one job queue 5,000 more which can be run on several distributed workers.
- jrochkind1 13y agoYour conclusions about latency, and being able to restructure things so tasks are much smaller -- make sense. (Potentially; I'd still want to benchmark my own real world app before assuming!) (I am confused with your first paragraph and a half, I think you have some typos in there, or I just don't understand what you're saying. But I understand what you're saying about latency and about being able to restructure tasks to be smaller, thanks.)
- benmanns 13y agoAck, sorry for the confusion. I mean that if your users are waiting on jobs, they get the result when `encode time` + `enqueue time` + `wait time` + `dequeue time` + `decode time` + `execute time` is completed. Even though you might not need raw 1000 jobs/second throughput, your users will still benefit by reducing `wait time` + `dequeue time` + `decode time`, which goworker does.
- meritt 13y agoYup. I have distributed worker system with all the workers in PHP. The majority of the time spent is waiting on database requests and external HTTP calls. Even if the speed of code was instantaneous it wouldn't make much of a performance increase overall.
- benmanns 13y agoEven though most of the time is spent on I/O, goworker can get wins from its super cheap concurrency. I was able to run 100,000 workers on my single 4GB RAM laptop.