I'm compiling 20k pages, and it's only using a fraction of my CPU
Unanswered
Dwarf Crocodile posted this in #help-forum
Dwarf CrocodileOP
I'm on the latest version of next.js (13.4?), and I've put together a benchmark to see how next.js would perform on my 20k page website.
I'm running
I need static site generation. ISR isn't an option for me.
I'm running
next build, with the export option turned on. It only seems to be maybe a single CPU core. Is there a way I can speed this up further? I haven't added things like CSS or images to my test to optimize yet, so if there is no parallelization currently, I'm worried this will slow down too much.I need static site generation. ISR isn't an option for me.
29 Replies
Check out these options
They aren’t documented
But there’s an option for experimental.cpus
But by default it should try to use all of them…
Maybe enable workerThreads
One more thing you could do
Increase the heap size
So it utilizes more of your available memory
@linesofcode Maybe enable workerThreads
Dwarf CrocodileOP
How can I enable worker threads, or choose settings for webpack?
Take a look at the code I linked
Those are all the options available in your next config
So you would add the corresponding option to your next config
To enable it
But I think your biggest win here will be increasing the heap size
I was wondering about how are you compiling 20k pages?
Dwarf CrocodileOP
So right now, it's just relatively simple .tsx pages. We're working on generating tests that are more complicated.
We're evaluating moving everything over to next.js.
We're evaluating moving everything over to next.js.
You mentioned that ISR isn't an optoin
does that include using the "fallback" strategy ?
the idea is that you only build a subset of all your popular pages during build-time
and the remaining pages will be built on demand when a user navigates to them
and then the newly built paged will be served for subsequent requests
Dwarf CrocodileOP
How can I choose what pages are built at buildtime?
by using the fallback option
the ones without fallback enabled will be built
you need to define a getStaticPaths function which returns a list of all the page paths
Dwarf CrocodileOP
We are trying to rely fully on
output: 'export'. It's a lot easier to make websites that are fully static highly reliable and performant