php - Efficient way of exporting a bunch of PDF's from a user? -


i need give our users ability export bunch of pdf's (invoices).
the problem is, pdf's generated everytime user opens them.
so don't have them stored in filesystem.

so, question is, efficient way of exporting user's pdf's, when want to?

for example, user wants export 100 invoices previous quarter.
i need call script generates pdf's , put them in .zip file.
but, if multiple users request heavy export @ same time?

i thinking of running cronjob every 10 minutes or so, doesn't solve possible heavyness of script.

do need run multiple cronjobs, can each handle portion of exports?

or can somehow create efficient script, , maybe separate pdf's in several batches?

i'm using wkhtmltopdf generate pdf's.
so fortunately, it's pretty fast render pdf's.
although still depends on content, of course.
on average, single pdf takes 3-5 seconds render.

any or guidelines appreciated!
thanks


follow-up question: if save every invoice filesystem, it's created or updated, need find way in background, avoid unnecessary waiting.
queues savior, right?

generate invoices moment saved in database , store filesystem-url database entry. if user requests package of invoices of time period, collect generated pdfs zip-file , provide download link. requirement enough space file storage on server.

you can limit invoice storing 1 year. if user requests older invoices must generated otf.


follow-up answer: since in php-environment, suggest implementing kind of invoicechanged handler. if call (with parameter invoicenr), deprecated pdf-file gets deleted , new 1 generated according modified data. if uses same file-name, not have update file-url in database.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -