Serverless Function Timeout on Vercel
Unanswered
Thrianta posted this in #help-forum
ThriantaOP
I am running a serverless function ( currently an API route that calls a server action, tried just an api route and tried to use edge as well )
Function is designed to generate a vCard of a users contact info from the backend (mongo DB) and works as expected in all set ups on localhost but I am getting a time out on vercel production deployment
On local host dev the function is running at the highest ive logged 1.8 seconds where as the vercel deployment hits the 10 second time out every time.
Looking for some help figuring out why this is taking so much longer to run on vercels servers than my crappy machine.
Function is designed to generate a vCard of a users contact info from the backend (mongo DB) and works as expected in all set ups on localhost but I am getting a time out on vercel production deployment
On local host dev the function is running at the highest ive logged 1.8 seconds where as the vercel deployment hits the 10 second time out every time.
Looking for some help figuring out why this is taking so much longer to run on vercels servers than my crappy machine.
3 Replies
Spectacled bear
The system that vercel gives for a free plan is not that powerful as you think it is. So that' s the reason that your function gets timeout.
I'm not that experienced with this stuff, but what you could do is either host your app on a cheap vps so that there is no downtime, or take that function to a separate backend and host that backend in the server, or pay more to vercel 😄
I'm not that experienced with this stuff, but what you could do is either host your app on a cheap vps so that there is no downtime, or take that function to a separate backend and host that backend in the server, or pay more to vercel 😄
ThriantaOP
Yeah so im on the hobby plan for vercel im broke as a joke atm, I have no idea what cost would look like on something like this with vercel either. as much as i do understand pricing for all this type of stuff is a wild guess for me. that goes for other platforms like aws ibm or w/e
But from what you say, im assuming that if i had a paid plan my function would run in about 2 seconds or less essentially negating the need for the upgrade outside of the under powered free tier
and i find that rather annoying. I wanted to use vercels free platform to start this SaaS project off and only move or upgrade when the user base grew and I am actually making the money to afford to do that. but im not sure how much more of this app will land in the serverless function realm, so by the time ive got a useable product ready will it fail on vercel... sigh
The issue I ran into with edge is that I was getting errors connecting to the mongo api and from what i could tell the edge runtime cant do that otherwise I feel that vercels free tier with edge could handle it. but my expierence working with this enviroment is like 2 instances of one little function and they worked with out issue so i spent maybe an hour collectively on both.
I am also wondering and will take feedback before i try, if i scrap the api route and server action and just build the vcard builder into the rest of the contact component, if i could either by pass the srverless function or make it fast enough to clear the 10 second window ( which vercel if you read this come on bruh give us a touch more power or increase the window so it can be done with little power )
But from what you say, im assuming that if i had a paid plan my function would run in about 2 seconds or less essentially negating the need for the upgrade outside of the under powered free tier
and i find that rather annoying. I wanted to use vercels free platform to start this SaaS project off and only move or upgrade when the user base grew and I am actually making the money to afford to do that. but im not sure how much more of this app will land in the serverless function realm, so by the time ive got a useable product ready will it fail on vercel... sigh
The issue I ran into with edge is that I was getting errors connecting to the mongo api and from what i could tell the edge runtime cant do that otherwise I feel that vercels free tier with edge could handle it. but my expierence working with this enviroment is like 2 instances of one little function and they worked with out issue so i spent maybe an hour collectively on both.
I am also wondering and will take feedback before i try, if i scrap the api route and server action and just build the vcard builder into the rest of the contact component, if i could either by pass the srverless function or make it fast enough to clear the 10 second window ( which vercel if you read this come on bruh give us a touch more power or increase the window so it can be done with little power )
Spectacled bear
I think it should be possible, but from what I understand, you're trying to make the db query from the client. That's never a good idea.
I think I have an idea. Try making smaller queries and join them afterwards. So my guess is we will make many serverless functions which is in the free tier.
But even then there might be rate limiting, so fingers crossed
I think I have an idea. Try making smaller queries and join them afterwards. So my guess is we will make many serverless functions which is in the free tier.
But even then there might be rate limiting, so fingers crossed