rdvojmoc / DinkToPdf

C# .NET Core wrapper for wkhtmltopdf library that uses Webkit engine to convert HTML pages to PDF.
MIT License
1.09k stars 417 forks source link

Is it possible to run multiple conversions in parallel? #136

Open DmitriiGaidukov opened 3 years ago

DmitriiGaidukov commented 3 years ago

In my ASP.NET Core app, I run into a problem with the Synchronized converter that multiple web requests are queued on a single thread instead of running in parallel and/or utilizing all cores. I take it it is the expected behavior:

Use this converter in multi threaded applications and web servers. Conversion tasks are saved to blocking collection and executed on a single thread.

Is there a way to work around this limitation? For ASP.NET Core apps it's a really big issue as they are inherently multithreaded.

Markuzy commented 3 years ago

I don't have a solution at the code level, but one alternative is to re-think the infrastructure design of the pdf generation, which we can think of it like a reporting service.

If working on cloud, we can also opt to dynamically spool up a temporary application to execute the job, and then self terminate when completed. With on-premise infrastructure, it may be possible to home brew something similar.