The good and bad of Queuing

London Scalability Group • 16th July 2012. #ldnscale

Alister Bulman

self::about()

self::current()

view from the 13th floor Scaling PHP-based systems, with related technologies. Currently working on a 'secret project' in our secret volcano base, half-way up the Centre Point tower....

(OK, so it's the 13th floor, and we are eye-to-eye with a crane-driver)
I might be able to tell you more very soon

self::prev()

Programming PHP since 1999, PHP v3, (>12 years ago). Previously in everything from a ZX81, BBC/Electron, 6502 to 8086 Assembler, Pascal and C/C++ before PHP

Programming since 198-cough

Classic uses of a queue

various queue systems

What I've done with queues

Hang on to your hats

Beanstalkd live demo

Putting 1000 items in - and then taking them out

Here's the good

asyncronous!

Msmq Many long running, or intensive tasks could be done in the background

- Background or Parallel Processing


The classic problem is image uploads. Even happy-snap digital cameras can produce an image that is 3-4+ megabytes. You can't just store that and end up resizing it in the browser. You have to resize it, but you also can't do it in the same PHP process that uploaded it - it takes too much time - and memory.

Even the pic from the 13th floor was 780KB on disk, at least 15MB memory - just to view. To resize, could be 30MB or more.

Don't even try to resize 5+ GB of 1080p quality HD video

Use of queues at Flickr
- the most popular use isn't even about resizing images

The Advantages

The Bad

Over enthusiasm

The Bad, II

If things go wrong

The Bad, III

Setting up and running

Queueing via a DB :: Anti-pattern


If you are deleting items from the queue as they are being sent, then you know the DB can be good for millions of records

Beanstalkd

Many language bindings are available

Quite easy to write, as it's a simple text-based format, ala Memcached

The daemon is equally dumb as a classic MemcacheD. Talking to multiple servers is done from the client-side.

Blocking
I'll wait here till you have something

BeanstalkD was written in C for a Facebook app called 'Causes' - which was written in RubyOnRails

Not to be confused with the 'Beanstalkapp.com', which is remote SVN & GIT version control

OR WITH Amazon's Beanstalk to start EC2 and other AWS services

What to send through the queue?

64KB default limit.

In Summary

Thanks

Questions ?