Improve SnapPDF performance

I’m running the latest Invoice Ninja (v5.5.4 as of this writing) in a docker container on a Synology DS620slim NAS with full SSDs in the RAID and PDF generation takes about 3 seconds. While I’m not complaining about the speed I’ve heard that SnapPDF is capable of generating PDFs much faster (<0.5s). I understand the CPU is kinda outdated in the NAS (Celeron J3355) but I’m wondering if that’s as fast it gets or is there any way to improve the speed?

Clarification: I’m referring to generating PDFs under Quotes. Interestingly, Invoice PDFs load almost instantaneously which makes me think they are already stored as PDF files (and not being converted from HTML —> to PDF on-the-fly).

Addendum: Looking at the console output, the GET requests for displaying both the invoice and quote PDFs seem identical, which makes me wonder why quote PDFs take several times longer to generate.

GET: https://invoiceninja.xxxx.xxxx.xxxx/client/invoice/A3f46K9aOHerbflvJFxj4t0WtPjdQhjS/download?t=1659148638767&t=1659148638767

GET: https://invoiceninja.xxxx.xxxx.xxxx/client/quote/HTLfZLEuxVNb9R1UTEoxNsjPrOdXM1iK/download?t=1659148667813&t=1659148667813

Is there any way to check the logs to see what’s happening behind the scenes?

@Ph03n1ks

After the invoice is generated the first time it is not regenerated until it is changed, this could account for the speed differences you are seeing.

3 seconds sounds about right for that quality hardware. We have Enterprise Ryzen’s in production and it can take around 1 second there. You may notice a significant performance boost using our hosted_ninja PDF generator, this sends your HTML to our services for conversion on the fly into PDFs.

1 Like

@david

Thanks for the quick response, it is much appreciated. I switched to hosted_ninja but I didn’t see any improvements in performance unfortunately so I will stick with SnapPDF.

@ david
Just had a look out of curiosity
Invoices pdf’s are generated only if changes were made, which is expected behaviour.
Quotes, po, recurring and credit pdf’s seem to be regenerated regardless of whether any changes were made or not, every time you view them. Shouldn’t they behave the same as invoices?

@strider27 @david

I agree with @strider27 , it would be a really nice change in QOL if quotes etc would only regenerate if there have been changes since the last version.

Two additional things I have noticed:
• delivery notes (from invoices) also regenerate on-the-fly
• quotes DO NOT regenerate in the client portal; they load almost instantly in the browser window

I think one of the reasons those are not currently stored is because of space for people who use hosting or VPS’s etc. with limited storage.

@david
If space is a concern you can tie them to DELETE_PDF_DAYS .env variable along with invoices.

@strider27 Quote PDFs don’t regenerate in the client portal which makes me think they are already stored on the server.

Edit: yes, generated PDF files are already saved under ./public/storage/… (invoices, quotes etc)