go ahead... be a heretic | |
PerlMonks |
Re: Designing an enqueing application proxyby BrowserUk (Patriarch) |
on Jan 04, 2008 at 02:54 UTC ( [id://660367]=note: print w/replies, xml ) | Need Help?? |
While you wait for someone to post a POE solution (could take a while), you might get away with something as simple as this:
This creates 2 threads. The listener thread, which accepts connections, maintains a (non-shared) hash of client sockets and queues the requests as they are recieved. Then the main thread dequeues the requests, spawns a thread to forward that request and await the reply before queing that back to the listener thread. A 1/10 second delay in the second threads processing loop ensures the request rate doesn't exceed 10/second. When the spawned threads receive their replies, they are queued back to the listener thread for dispatch back to the appropriate socket. Of course, a thread pool solution for the upstream connections might be more efficient (as well as a tad more complicated), but whether that is necessary depends a lot upon the burst rate of your PE process? Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
In Section
Seekers of Perl Wisdom
|
|