Marcello has asked for the wisdom of the Perl Monks concerning the following question:
A large Perl application currently queries a certain MySQL table for records. As soon as records are found, they are processed by the application and DELETE'ed from the database. So, basically the table acts as a queue.
This process needs to be as fast as possible. Therefore, the idea is to use multiple Perl processes (2 or more) to query this database and process the records.
The requirements are as follows:Process the records as fast as possible
Avoid different processes handling the same record
Sometimes a process cannot handle records when a connection to a remote server is lost (which could take hours to resolve). At this point, the other processes should handle its records or otherwise the records would stay in the queue for too long.
I am not sure what kind of logic to implement to meet the requirements above.
For 2 processes, one could handle the records with odd Id's and the other one with even Id's, but then still the second requirement is not met when one process cannot handle the records.
If processes SELECT the same records, there is a significant overhead because 50% or more of the records are already handled by other processes and therefore should not be handled.
What is the best approach I can use to meet these requirements?
TIA!
This process needs to be as fast as possible. Therefore, the idea is to use multiple Perl processes (2 or more) to query this database and process the records.
The requirements are as follows:
Sometimes a process cannot handle records when a connection to a remote server is lost (which could take hours to resolve). At this point, the other processes should handle its records or otherwise the records would stay in the queue for too long.
I am not sure what kind of logic to implement to meet the requirements above.
For 2 processes, one could handle the records with odd Id's and the other one with even Id's, but then still the second requirement is not met when one process cannot handle the records.
If processes SELECT the same records, there is a significant overhead because 50% or more of the records are already handled by other processes and therefore should not be handled.
What is the best approach I can use to meet these requirements?
TIA!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Database queue logic
by ruoso (Curate) on Jun 14, 2005 at 12:20 UTC | |
Re: Database queue logic
by trammell (Priest) on Jun 14, 2005 at 20:20 UTC | |
Re: Database queue logic
by monarch (Priest) on Jun 14, 2005 at 12:11 UTC | |
by Marcello (Hermit) on Jun 14, 2005 at 12:14 UTC | |
by monarch (Priest) on Jun 14, 2005 at 12:41 UTC | |
by Tanalis (Curate) on Jun 14, 2005 at 13:20 UTC | |
Re: Database queue logic
by Solo (Deacon) on Jun 14, 2005 at 17:33 UTC | |
Re: Database queue logic
by astroboy (Chaplain) on Jun 14, 2005 at 19:56 UTC | |
Re: Database queue logic
by Ben Win Lue (Friar) on Jun 14, 2005 at 12:12 UTC | |
by moot (Chaplain) on Jun 14, 2005 at 14:34 UTC | |
by Marcello (Hermit) on Jun 15, 2005 at 08:05 UTC | |
Re: Database queue logic
by thcsoft (Monk) on Jun 14, 2005 at 13:30 UTC |
Back to
Seekers of Perl Wisdom