Rendering 16,000 Schematics in the Cloud with RabbitMQ and PhantomJS
circuitlab.com
circuitlab.com
If you do most of your work in Python, Celery is pretty slick: http://celeryproject.org/
If you like Redis -- and who doesn't? -- then Resque or one of the alternate implementations will work well in Ruby or a plethora of other languages:
https://github.com/defunkt/resque
https://github.com/defunkt/resque/wiki/Alternate-Implementat...
Beanstalkd is pretty generic, and simple to set up. If for some reason you can't use Celery or Resque, maybe have a look at it:
http://kr.github.com/beanstalkd/
Distributed task queueing is important and useful stuff, and if you half-ass it, your infrastructure will literally explode, usually at 3:00 AM. Get a good library for it.
See my comment above if your rendering clients are written in Erlang.
It's easy to follow the rabbitmq tutorial and build a nice little pipeline for tasks - what is the difference between that and using a library?
What happens if a worker crashes? What happens if a few jobs cause the workers to work forever? What happens if a job hits a bug in your worker code and causes it to reliably crash every time? What happens if your queueing server goes down? What happens if you need to migrate your queueing server to another EC2 instance because Amazon has decided to get rid of the physical machine it's running on?
Undesirable answers to such questions include "We accidentally drop a job without noticing," or "We have to shut down the whole system in a user-visible way for twenty minutes while we do maintenance," or "All the workers keep crashing and being restarted, flapping eternally until someone notices and manually intervenes."
EDIT: Oops, I just noticed that I didn't really answer your question about what I meant by using a library. What I mean is, use one of the more full-featured job queueing libraries like Celery or Resque, rather than trying to roll your own on top of something like RabbitMQ.
Thanks for that!
Distributed workloads is a hard problem, but it is a solved problem (for most applications, there are some exceptions thought too).
Wait… really? A schematic editor can render a schematic at least 30 times per second. "Rendering" to PDF should be even faster since PDF is a vector format. Are they rendering in hundreds of different formats?
Of course, we could devote engineering effort to bring that 10 seconds down by an order of magnitude, writing a fully custom PDF (and EPS, SVG, PNG, ...) rendering engine, but part of the beauty of elastic cloud computing is that we can make better use of existing components -- even if it's less efficient from a CPU time perspective -- because the CPU time is cheap and programmer time is expensive (and better used elsewhere). There's a balance, of course, but making well-informed tradeoffs is what engineering is all about.
Layouting was already done by the user, so I don't see what part of rendering is incurring the heavy costs here. As it stands, you have now spent lots and lots of programmer time building a batch system from scratch.
Of course you might have done all of that - no way to know unless you tell us more about the actual pipeline.
But, I presume you didn't use cairo for a reason - or you are using it, but need those other tools to post-process its output somehow. I'd be interested to know why?
> and takes a lot less programmer time
I don't see how this is true. You've already spent time setting up a distributed system from scratch (pretty much at least), and you also need to maintain it. Distributed systems are complicated stuff; lots of stuff that can go wrong. If the optimization made it possible to use a single machine, it would be much easier to grasp and debug.
You mean like this? http://cairographics.org/ (Which, BTW, has Python bindings…)
because the CPU time is cheap and programmer time is expensive (and better used elsewhere)
Yes, but programmer time to implement rendering using a fast library such as Cairo is O(1), while the CPU time is O(n) where n is the amount of business you do.
(Disclaimer: I have written a schematic renderer before using Cairo. It took me maybe a couple days.)
I know this from personal experience. If you have a consumer based distributed worker pool, AMQP is overkill! My application is built in Erlang and the worker nodes are also built in Erlang - I initially went with using RabbitMQ to hand work out to the workers (and to receive processed results back from workers) but I quickly found it added a lot of message latency (vs. a straight RPC call) and I also had to write a lot of management code.
Switching over to straight RPC was a great decision and I essentially kept the "worker queue" logic in our Python application (where it is a "solved" problem).
Big topic, for sure - I should write a blog post on how my application is structured.
(Are you using Spice as the underlying simulator?)
We actually have a custom simulator engine running client-side in Javascript.