Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Looping through database query to send emails is taking too long

by flexvault (Monsignor)
on Jul 21, 2015 at 15:35 UTC ( [id://1135645]=note: print w/replies, xml ) Need Help??


in reply to Looping through database query to send emails is taking too long

htmanning,

With most of my cgi scripts, I make them schedule work, rather than complete the work. In your case, you could open and lock a scheduling file in append ('>>') mode and then put(print) the 'Todo' string in the scheduling file and unlock it (close). Then immediately complete the transaction for the user with a HTML page with related information.

If your web-server is Apache2 on *nix, then the tricky part is to have a Perl script running under the same user and group as Apache2, that does the actual work. Other web-servers may allow you to schedule another Perl script, but Apache2 doesn't without waiting for all scripts to complete, which will make the process slow again :-(

You look like a hero to your users for being so fast, and you can expand the functionality of the 'Todo' script without worrying about the time to do the actual work.

You can get into client/server communication, but using an external file is very fast and simple to implementation. If for some reason the transaction fails, you know the exact parameters needed to re-schedule the task.

Hope this gives you some ideas for improving your users' experience!

Regards...Ed

"Well done is better than well said." - Benjamin Franklin

  • Comment on Re: Looping through database query to send emails is taking too long

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1135645]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2024-04-24 07:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found