opennextjs-cloudflare: [BUG] High CPU usage on releases after 0.5.12
Describe the bug
After migrating from 0.5.12 to 1.0.0.beta3, I noticed very high cpu usage in my app requests. It went down when I rolled back to 0.5.12
Metrics view from dashboard
Steps to reproduce
App is very simple, completely SSG with around 20 pages
open-next.config.ts (version 0.5.12) - NEXT_INC_CACHE_KV is not defined (does this disable caching?)
import { defineCloudflareConfig } from '@opennextjs/cloudflare'
import kvIncrementalCache from '@opennextjs/cloudflare/kv-cache'
export default defineCloudflareConfig({
incrementalCache: kvIncrementalCache,
})
open-next.config.ts (version 1.0.0-beta.3) - no cache binding defined
import { defineCloudflareConfig } from '@opennextjs/cloudflare'
import staticAssetsIncrementalCache from '@opennextjs/cloudflare/overrides/incremental-cache/static-assets-incremental-cache'
export default defineCloudflareConfig({
incrementalCache: staticAssetsIncrementalCache,
})
PS: I am new to Next.js/Cloudflare but even after reading the docs multiple times, I have not really understood how this cache is really working and what purpose is serving - if anyone can point me to a more verbose write up or video. Thanks!
Expected behavior
CPU is not 20x
@opennextjs/cloudflare version
1.0.0-beta.3
Wrangler version
4.12.0
next info output
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 24.3.0: Thu Jan 2 20:24:06 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T8103
Available memory (MB): 16384
Available CPU cores: 8
Binaries:
Node: 22.14.0
npm: 11.3.0
Yarn: 1.22.22
pnpm: N/A
Relevant Packages:
next: 15.3.1 // Latest available version is detected (15.3.1).
eslint-config-next: 15.3.1
react: 19.1.0
react-dom: 19.1.0
typescript: 5.8.3
Next.js Config:
output: N/A
Additional context
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 8
- Comments: 19 (6 by maintainers)
Hi @vicb , I will try to create a minimal repo with issue and get back (will update this post)
Update:
I am able to ‘sort of’ reproduce it with
npm create cloudflare@latest -- my-next-app --framework=next --platform=workersUnder the red line is with version 1.0.0-beta (actually 0.6.0 shows the same) and above with 0.5.12. The high number is browser making first request, which seems to be very slow (why?) and the subsequent requests are faster. So with 0.6.0 first slow request is 2-3x compared to 0.5.12, subsequent requests are fast with both - which also corresponds to the graphs above P50 being fast but P90+ being slow.
#653
I experimented with
1.0.3,0.5.12, and0.6.0versions of the script to keep sending requests. As a result, I found that CPU usage time increased after0.6.0on P99. Reproduction repository ishttps://github.com/nxsdev/opennext-debug
here. You can deploy by running
pnpm cf-deployin the version-0.5.12, version-0.6.0 branchThe content is Vercel’s Next.js AppRouter Playground with some parts that use cache removed. The script used for the experiment is
performance-test.js.This graph shows 1.0.3 on the left side and 0.5.12 on the right side. 0.6.0 was not significantly different from 1.0.3.