Extremely high amount of Data Cache writes #7108
-
SummaryI just got a notification that I am over 50% of my monthly Data Cache writes and it's only day 4 of my billing cycle... I just checked and it seems like my website is doing over 10k Data Cache writes EVERY HOUR (95% are from Incremental Static Regeneration). This is odd because my website has a little over 1500 static pages that only revalidate once every 24 hours. 380 pages are statically generated every day, the other ~1100 pages are incrementally generated during the day when people visit them. I just looked through my code and I can only find 1 I don't understand the math here... how can I be doing over 10k Data Cache writes??? The dashboard doesn't tell me at all what is causing this. |
Beta Was this translation helpful? Give feedback.
Replies: 11 comments 20 replies
-
Hey @sandervspl. It sounds like there is a lot of revalidation and incrementally generated pages on your site that could be driving up the Data Cache writes depending on things like site traffic, configuration, and build frequency. I recommend reading through this guide which has some tips for optimizing Data Cache writes: vercel.com/docs/pricing/data-cache#manage-and-optimize-usage-for-data-cache |
Beta Was this translation helpful? Give feedback.
-
I have resolved the issue. These are the steps I had to take in case anyone else encounters the same problem.
export const revalidate = false;
export const dynamic = 'force-static';
export const dynamicParams = false; // -> disables ISR
Also applied these changes but I'm not sure if they're necessary
I would LOVE to see more in-depth data on WHAT is being revalidated, because this was super stressful. It was somewhat easy for me because I only have two routes, but it was very unclear to me what was being revalidated. And honestly, I still don't understand how 10k-30k revalidates per hour make sense. I get 200-500 page views per hour. |
Beta Was this translation helpful? Give feedback.
-
We're still on the page router but are experiencing the same issue, even after completely disabling ISR (removing all It's becoming frustrating and expensive, since we don't even exactly know what we're paying for at this point. Observability on this horrible, even the support representative admitted this. @amyegan @leerob |
Beta Was this translation helpful? Give feedback.
-
We're seeing the same thing and are also waiting for a response to the ticket. We haven't completely disabled ISR, but changed the revalidation time to 18h (which made no difference). Still writing thousands of units every hour ramping up our costs without having any idea where it's coming from or why. Similar issue here: EDIT: |
Beta Was this translation helpful? Give feedback.
-
Seeing the same issue at my E-commerce site with no revalidation (Only On-demand) |
Beta Was this translation helpful? Give feedback.
-
For anyone who is still on version v14.2.2 or lower of NextJS. Update NextJS to at least v14.2.3 There was a bug with cache tags, which ended up causing them to always revalidate, this caused my data-cache write usage to match my data-cache read usage. This is the PR that fixes it vercel/next.js#64799 After updating my writes dropped from over a million a day to a more reasonable ~25,000 depending on how active our content writers/developers were. Fortunately i got some usage refunded when that happened due to it being a Vercel framework issue, but I've now hit another issue with data-cache write/read usage matching eachother after changing CMS, but using the same revalidate tags 😆, so having to debug it again. I really have a love hate relationship with the data cache, it's great when it works as expected, but terrifying when it doesn't due to the cost structure and not having visibility on what exactly is causing the revalidations. |
Beta Was this translation helpful? Give feedback.
-
I have this same problem and have tried everything, to the point I may have to move to GCP as I'm worried if I start pulling in more traffic costs won't be manageable. How can a nextjs site with ~200 visitors a day possibly need this many data writes... I've tried:
None of these seems to make any difference, my content is fairly static, so how can I just turn this off and manually trigger it once a week or something? |
Beta Was this translation helpful? Give feedback.
-
Maybe this is of help for people that are still using the page router and are experiencing this as we did: Check your usage of In our case we were using |
Beta Was this translation helpful? Give feedback.
-
I had the same issue until last month. It got fixed once we changed our API logic. Before: After: Result: Page size reduced from 1.25 MiB to 23 KiB. And our issue was resolved. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
This discussion was automatically locked because the community moved to a new site. Please join us at vercel.community |
Beta Was this translation helpful? Give feedback.
I have resolved the issue. These are the steps I had to take in case anyone else encounters the same problem.
page.tsx
ANDroute.tsx
files (such as opengraph-image routes)twitter-image.tsx
files because for some reason the route config don't work on those routes, even though the docs say they doAlso applied these changes but I'm not sure if they're necessary
export const fetchCache = 'force-cache';
to the root layout