Repository navigation
Data Cache MISS at a rate much higher than expected #90141
SummaryHello, Our app uses App Router (migration from Pages Router in progress) and we use the Data Cache in our dynamic routes to cache GraphQL queries made with Apollo. We've set the revalidation time with next.revalidate as part of Apollo fetchOptions to 24 hours. Yet I am seeing cache MISS logs in Vercel for these queries multiple times an hour. This is a much higher rate than expected. The hit rate in Vercel Observability is only 50%, we would expect 90%+. This increases backend load and our Vercel usage costs. What could explain this? Why is the cache not honoring the revalidation rate? LRU limits? Something else? Additional informationSome info on our app:
- Next 16, Turbopack, NOT cacheComponents (we tried but hit too many bugs), App Router (for pages where we see this behavior), deployed on Vercel.
- We have some marketing pages, but most of our app is a purchase funnel for a product among 20k+ products, identified by a slug. These pages a dynamic due to usage of cookies, searchParams, etc.
- I am seeing the non-honored cache behavior on the product detail page query in particular. It returns slow-changing data, hence why we want to cache it for 24h in order to avoid unnecessary load and compute. We are expecting one cache entry per product slug, so about 20k, which seems reasonable?
- Total daily Data Cache usage on Observability: 1.2M reads, 200k writes.ExampleNo response |
Replies: 2 comments 6 replies
|
I'd also try to pipe this through Vercel community, or support. That being said, I wonder if in graphql, the variables used in the query are to high cardinality ( |
|
Update - Vercel confirmed we hit the Data Cache LRU limit and that as a result entries are being actively evicted. Here's some info they shared that's not documented:
I estimated our caching need to be roughly 10-15 GB, so it seems we'll need to move away from Vercel's Data Cache hosting. It's sad that for the same Pro Plan in the past, we had a roughly working caching story under Pages Router -- pages were basically cached by ISR -- and App Router introduced limitations that forces us to rely on this severely limited solution.
As a result we will be investigating alternative cache storage solution, possibly relying on a Memcached instance already deployed for our backend needs. |
Update - Vercel confirmed we hit the Data Cache LRU limit and that as a result entries are being actively evicted.
Here's some info they shared that's not documented:
I estimated our caching need to be roughly 10-15 GB, so it seems we'll need to move away from Vercel's Data Cache hosting.
It's sad that for the same Pro Plan in the past, we had a roughly working caching story under Pages Router -- pages were basically cached by ISR -- and App Router introduced limitations …