I am writing a perl daemon for multiple servers that will process time consuming tasks from a single mysql database. The server maintains a connection to the database gathering tasks when they are available.
Pre-forked children report to the parent process via a PIPE telling of their status 'idle' or 'busy' so the server knows which child to assign the next task to.
The task data is usually less than 128bytes and there are 20 or more child processes at anyone time.
What would be the best way of delegating the task to the children?
- I've heard of using shared memory, having each child access a specific portion for their assignments.
- I've heard of opening a bi-directional PIPE to the child, but unsure if managing 20+ PIPEs is effective.
- I've had a suggestion that the children should access the database for the tasks. If the daemon is run on 5 seperate boxes there would be 5*20 = 100 processes querying the database endlessly. That doesn't sound effecient to me.
What would be an appropriate solution?
Thankyou Monks!