Next.js Discord

Discord Forum

High CPU Usage with Server Actions

Unanswered
Canvasback posted this in #help-forum
Open in Discord
CanvasbackOP
I’m experiencing high CPU usage on my Next.js app running on the server.
I’m using the following fetch configuration to get data for my pages:

const defaultOptions = { next: { revalidate: 15 }, cache: "force-cache", } as RequestInit; export async function getWebinarWithSlug(slug: string): Promise<WebinarType> { try { const response = await fetch(${process.env.WEBINAR_API_URL}/info/seo/${slug}, defaultOptions ); if (!response) { return notFound(); } const body = await response.json(); if (!body || response.status >= 400) { return notFound(); } const data = body?.payload; return data; } catch (err) { return notFound(); } }


- I’m using force-cache and revalidate: 15 to cache the data for 15 seconds.
- Despite this, my server’s CPU usage is very high, especially under load.
Questions:

- Is there something wrong with my caching strategy that could be causing high CPU usage?
- Could the way I’m using revalidate or force-cache be leading to excessive server-side rendering or cache stampedes?
- What are best practices to reduce CPU usage in this scenario?
- Any tips for debugging or profiling this kind of issue in a Next.js app?

0 Replies