Skip to content

Taking Firehose’s Worker Pool for a Spin

Firehose is an application framework designed to make load testing easy. As such, Firehose comes with a worker pool which you can use to generate multi-threaded load tests without the mess of coding thread safe methods. This especially helpful if the application you intend to test is high performance and capable of handling many thousands of operations per second.

As a software consultant, some of my clients’ load generators were not capable of creating work in sufficient volume to really push the database they were testing. This was almost always because their load generator as single threaded and executed units of work serially. Firehose’s worker pool eliminates this issue by giving you the ability the throw the full heft of a multi-proccessor load on the target system.

Using the worker pool is easy. The implementing class is called WorkerPool is initialized by passing an instance of the interface WorkerPool.Executor. The thread pool performs one unit of work by calling the execute() method of WorkerPool.Executor. Let’s take a look at an extremely simple code example to see how it works.

The SimpleWorkerPoolUser class implements WorkerPool.Executor, and as such must override the execute method. SimpleWorkerPoolUser’s execute() method is just printing the thread identifier, but it could be doing any useful work I assign to it. The important thing to remember is each call to execute() is considered a unit of work.

Not much more to say about this example, except that I’ve set the size of the pool to 4 threads at line 15. You can change the number of threads the worker pool is using anytime you wish, but you’ll need restart the pool for the resizing to take effect.

Give a try and let me know what you think.

There’s lots of cool Meetups going on in May. Join me at The San Francisco MongoDB User Group to hear Michael Poremba’s talk “Transitioning a 4 TB Health Care Security Auditing System to MongoDB”, hosted at The Gap May 13th. RSVP

June 1st I’m presenting four sessions at MongoDB World 2015. Register with my promocode Reinero40 and get a 40% discount.