Jaff,
You can use a simplified
bucket algorithm to create PDFs at the fastest possible rate without getting a 503 error. This should give you a better throughput than the previous suggestion.
$bucket = 30;
$last = microtime(TRUE);
for (..; ..; ..)
{
if ($bucket == 0) sleep(2);
$now = microtime(TRUE);
if ($last + 2 <= $now) {
$tokens = (int)(($now - $last) / 2);
$bucket = min(30, $bucket + $tokens);
$last += 2 * $tokens;
}
try {
$client->convertURI(...);
$bucket--;
}
catch(PdfcrowdException $why) {
// log($why->getMessage());
}
}
However, both solutions require that there is only one active loop at a time. Ideally, there should by a single loop in your application which processes requests from all users.
It seems that the API limits are too restrictive for your application. If you are interested, we can provision a private server dedicated to your application and optimized for your needs with the limits lifted. Please contact us at info@pdfcrowd.com if you would like to discuss this option.