504 timeout for large data request

have an api where i am fetching data with different timeframes. when i select the timeframe of "all time" it returns back my history. I have not hit a point where one user is getting a 504 and is annoyed they cant see their all time data. What is the best way to handle this in a serverless env? 1. Batch Request on client? 2. vercel config? up limit or max response? 3. other?
3 Replies
Matthew
MatthewOP11mo ago
also, for context i am on the pro plan for vercel, and using pages router, basic t3 setup
Matthew
MatthewOP11mo ago
https://vercel.com/docs/functions/configuring-functions/duration when i view this. if i have something under src/api/x can i set the max duration and limit here or is that only for functions under src/pages/api stream of consciousness here but just not 100 percent sure what the right answer is
Configuring Maximum Duration for Vercel Functions
Learn how to set the maximum duration of a Vercel Function.
Vincent Udén
Vincent Udén11mo ago
It should work regardless of the actual location of the function. At least according to what they write. However just upping the time limit will not work for ever if the user can continually aggregate more data. Splitting requests into smaller chunks of data would be the best solution. For example by pagination
Want results from more Discord servers?
Add your server