nuxt / content

The file-based CMS for your Nuxt application, powered by Markdown and Vue components.
https://content.nuxt.com
MIT License
3.08k stars 624 forks source link

Prerender takes 10 minutes per page!!! #2449

Closed Neo-Zhixing closed 8 months ago

Neo-Zhixing commented 10 months ago

Environment


Reproduction

To test this, download this zip file: https://neo-zhixing.github.io/vk-doc-md/dist.zip and put it in ./content/man

Then, create a new module to populate the prerendering routes

import { readdir } from 'fs/promises';

export default defineNuxtModule({
    async setup(_, nuxt) {
        // Set the code highlight configurations
        nuxt.options.nitro.prerender = nuxt.options.nitro.prerender  {};
        nuxt.options.nitro.prerender.routes = nuxt.options.nitro.prerender.routes  [];
        const routes = new Set(nuxt.options.nitro.prerender.routes);

        const results = await readdir('./content/man');
        for (const filename of results) {
            routes.add('/man/' + filename.slice(0, -3));
        }
        nuxt.options.nitro.prerender.routes = Array.from(routes);
    }
})

Describe the bug

Prerendering 2000+ markdown pages take 26s per page locally. On vercel this takes 10s per page

image

Adding 20ish longer documents and this becomes 10 minutes PER PAGE.

image

What does this mean? It means that your page generation is O(n) to the amount of content. Total prerender time is O(n^2) to the amount of content you have.

This makes nuxt-content unsuitable for anything non-trivial when you have more than 1000 documents.

Removing half the pages and the per-page rendering time reduce by half.

Additional context

No response

Logs

No response

kakkokari-gtyih commented 9 months ago

Related to #2476

kakkokari-gtyih commented 9 months ago

I'm experiencing the same problem (ref: https://github.com/misskey-dev/misskey-hub-next/issues/72). My project has 3000+ markdown documents and it takes about 30 seconds to generate each page on Cloudflare Pages.


image