I am finding Prince to be very slow in this environment. For just the prince run (log right before prince executes and right after), it takes 2-4s the first time the lambda runs (Duration: 3269.74 ms according to Cloudwatch) and 260-400ms on subsequent runs. This is generating a simple "hello world" PDF that takes ~80ms to generate when running Prince on my laptop.
Is there any way to get information from Prince about what it is spending time on?
We are investigating this ourselves, Lambdas do have some startup cost and overhead but it's difficult to say at the moment whether there could be other factors involved.
I had the Lambda memory set to 256 MB. Increasing to 1024 MB seems to improve the performance by 50-100ms on average (some data points generating a simple PDF: 189ms, 193ms, 144ms, 209ms, 148ms) so I will try allocating a higher memory baseline.
We also added a lambda "warmer" via an event that runs every 5 minutes and invokes the Lambda. This keeps the Lambda alive (avoiding Lambda cold start problem) and also avoid slow Prince first time execution times when the Lambda is alive but Prince has not run yet. I assume there is a startup cost in finding and caching fonts the first time Prince runs on a new environment.
I think we're in the ballpark now in terms of performance.
In our side, we're using Lambda as well, and are having issues with performance. With HTML that's around 4-6 mb, it's taking over a minute. I know the html is pretty large, and has lots of css in it. Is there a way to improve the performance?
Here's how long it takes: Duration: 158784.52 ms Billed Duration: 158785 ms Memory Size: 4048 MB Max Memory Used: 410 MB
I've got the memory up to 4048, but it's only using 410 MB of that, so I don't think it's a memory issue.
Hi mikeday, I have a similar issue. We are creating a PDF file from a document with a lot of images and creating the PDF file is taking around 20-26 seconds. Without images, same document takes around 550ms.
I'm not doing it using Lambda though, I'm using prince on the terminal and the time I've given is what prince takes to create the PDF file. I'm on a Macbook Pro 2021. Would you say it could be faster on a server?
Downloaded over HTTP. They are ranging from 50kb to 200 kb. There are more than 200 of them. I tried using local files, which is significantly faster and gives around 6.5 seconds, but it still is not good enough.
Most are PNGs. Is there a way to use PNG images as is? Without decompressing and recompressing? How much more space would you say a 100kb PNG would take without compressing, compared to a compressed PNG.
Currently PNG will always be processed by Prince so I would expect them to be slower than JPEG in general, although it's difficult to know how significant that factor is for your particular document without testing.