Struggling to Reduce Vercel Function Invocations on My Next.js Website – Need Optimization Tips!
I'm building a website using Next.js, Prisma, and MongoDB, but I'm encountering an issue with excessive Vercel Function Invocations. On a private Vercel account, I noticed that a single request can trigger anywhere from 19 to 100 function invocations, which feels extreme.
I've already tried batching requests, server-side caching, and Incremental Static Generation (ISR), but the improvements are minimal. Does anyone have experience optimizing server-side actions for medium to large-scale projects? How can I effectively consolidate these invocations without sacrificing functionality?
Any advice, strategies, or resources would be greatly appreciated! I am including stats from my Vercel Account where the app was hosted. I have paused the project because I don't want to end up homeless before AI takes my job.
Here is the GitHub repository to make it easier for anyone who wants to help. I did my best to write the code as clean as I can. If you have any trouble with anything or have advices please tell. https://github.com/Lamine220/CartoonHub
This is code snippet of the Watch Page (path: /[mediaType]/[tmdbId]/[season]/[episode])
GitHub
GitHub - Lamine220/CartoonHub
Contribute to Lamine220/CartoonHub development by creating an account on GitHub.
3 Replies
This is the code inside the media action file [path: /features/media/server/actions]
This is the code that manipulates the database.
Solved, the extra requests were made because of the Link components. I had to set prefetch to false on my Link components