| 1 |
POE::Component::DBIAgent 0.10 README |
| 2 |
11-07-01 |
| 3 |
|
| 4 |
The DBIAgent is your answer to non-blocking DBI in POE. |
| 5 |
|
| 6 |
This module was written because I was developing a system that was |
| 7 |
bogging down at ONLY 1 million hits/day on dual 1GHz processors. |
| 8 |
That's only 11.5 requests/second! Needless to say, it was obvious |
| 9 |
that something wasn't working right. |
| 10 |
|
| 11 |
After much sweat, research, and profiling, I noticed an odd thing: |
| 12 |
Sometimes, my per-request times were in the milliseconds. Other |
| 13 |
times, it was taking over 25 seconds to answer a single request. The |
| 14 |
difference? DBI. During the times that my response times sucked, POE |
| 15 |
was blocking on a DBI request. I was actually serving my requests, |
| 16 |
all code considered, in milliseconds. But in the steps between |
| 17 |
assembling the response and delivering it, my program was stuck in a |
| 18 |
state that was making a DBI call, and waiting for the response. |
| 19 |
|
| 20 |
The answer? FORK! Or, more specifically, use POE's facility for |
| 21 |
forking off child processes to handle long-running tasks while the |
| 22 |
main program continues to cycle between states: Wheel::Run. |
| 23 |
|
| 24 |
DBIAgent forks off a configurable number of helper processes for |
| 25 |
running DBI queries. The states that depend on the output of the |
| 26 |
queries only get called when there is data for them to process. No |
| 27 |
more agonizing about query optimization in terms of milliseconds |
| 28 |
because the rest of your program will suffer. Leave that to the |
| 29 |
operating system! POE is designed for doing a lot of things |
| 30 |
concurrently. Waiting isn't doing, it's waiting... :-) |
| 31 |
|
| 32 |
This module will ONLY work in the places where POE::Wheel::Run will |
| 33 |
work. This generally means, *nix. Meaning, not on Windows (yet). |
| 34 |
|
| 35 |
I can't take most of the credit for this module. Fletch |
| 36 |
(fletch@[email protected]) had already done alot of this, and |
| 37 |
contributed the skeleton code for the Helper module. The Queue module |
| 38 |
is 99.6% his. I just packaged it up and wrote docs... (*his* was tied |
| 39 |
into his program... *I* made distributable. :-) |
| 40 |
|
| 41 |
Rob Bloodgood <[email protected]> |