Open kissthom opened 3 years ago
Did you firgure it out?
Generally node is single threaded (IO may be offloaded to separate threads, not CPU bound code). You'd need some sort of workers
I've tried some approaches with eg piscina, but ran into other issues with those unfortunately. So far I'd recommend spinning up multiple containers if require
First of all I'd like to say a big thank you for this library, it is a really awesome example how to use react-pdf on node!
I ran into some difficulties and I really hope you can help me out.
Generating larger PDF-s (> 30 pages) can take some time. For my use case it takes ~8 seconds right now. If I call the pdf generating endpoint only once without concurrent requests it works like a charm. But If I call it concurrently with requests that trigger generating these larger pdf-s that I can run into problems.
Use Case:
Although the first PDF was generated in 8 seconds it could be returned after step 4 but unfortunately handling request 2 with long running PDF generation kicks in and blocks the writing of first response. As a result first request takes ~16 seconds, second request 8 seconds to complete.
How I see it it can cause 2 problems:
How could I tackle these problems? I'd really like if the long running PDF generation would not block the returning of the previous response(s). Any idea, suggestion?