I am working (well in the planning stages really) on a script that interacts with the Amazon.com Web Services. No, this is not for the contest. I do not have the time nor the experience in Perl to even consider such an undertaking. In the documentation it states that, “Your Web site or application should make no more than one (1) request per second to our servers”. I am not sure how to go about this in Perl.

What I had in mind is storing the current time in seconds (epoch or something) in a MySQL database after every request has been made to Amazon.com. Then when a user would execute the script, it would then access that value every time a request is made to Amazon.com. I would then compare this database value with the current time and if they are the same I would sleep(1000) and then do it again. If they are not I would then make the request to Amazon.com. This seems to be a bit sloppy to me, there has to be a more efficient way to do the above. All of these database accesses seem a bit much. I was also thinking about creating a daemon but it seems that my hosting provider charges an extra fee for running daemons.

Any suggestions would be helpful. I am still new to Perl, so please bear with me.

Thanks


In reply to How do I prevent more than one request (to some URL) per second with CGI? by Balandar

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.