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


In reply to Re: Looping through database query to send emails is taking too long by flexvault
in thread Looping through database query to send emails is taking too long by htmanning

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.