preact-cli icon indicating copy to clipboard operation
preact-cli copied to clipboard

Pre rendering very slow and memory expensive

Open Debdut opened this issue 5 years ago • 2 comments

Reproduction

Please try building this repo

Steps to reproduce

I am building with pre-render about 1000 pages.

preact build --prerenderUrls ./prerender.js

Expected Behavior

I expect 1K pages rendering to take significantly less time and less memory.

Actual Behavior

When I try to build on a 2GB memory container, it fails with Out of Memory Error (Exit Status 137). It takes about 1 hr on 4GB machine with 4 vCPUs to build.

As it seems from the building process, preact build all of the files in memory first and then emits them, instead of emitting one by one and clearing the memory in process. This probably leads to such high memory usage.

On similar pre-rendering frameworks like react-static and Gatsby it takes about 5 min each for the same job.

I love Preact but it seems I won't be able to scale the pre-rendering for my site with it.

Debdut avatar Oct 30 '20 18:10 Debdut

opened an rfc https://github.com/preactjs/preact-cli/issues/1482 regarding this

prateekbh avatar Dec 08 '20 07:12 prateekbh

Unfortunately the experimental renderer never did make it in, but if someone still needs fast prerender.js script:

https://github.com/preactjs/preact-cli/issues/1684#issuecomment-1094349753

LionsAd avatar Apr 10 '22 19:04 LionsAd