Functions running every second

Hello, we just deployed nextjs app few days ago and noticed increased of function usage. Our site has low to no usage.

Seeing the function log is being invoked every second. is this normal for all nextjs apps deployed in netlify?

Site id: a0734f14-d6b9-44e8-a8f5-a9b63eb4e17a

Hi @rad182,

The part about functions is explained here:

@hrishikesh thanks for the link though I’m aware of the functions being generated.
My issue is that the function is being invoked every second even my site has no traffic at all.
I don’t see any information about this in the site you provided. Please do point me to the right direction.

It appears that you’re using next.config.js redirects for some of the files:

In that case, even if you’re not heavily using SSR, the requests will still be made to the functions to process the Next.js-based redirects.

Basically, the above link was supposed to explain when functions would be used:

  1. They’ll be used every time a server-side page is loaded or some next.config.js redirect needs to be parsed.
  2. They’ll be run once every revalidate period for ISR pages and Next Image component.

So if your function is being used every second, there must be some amount of traffic that would be triggering those functions.

1 Like

Hi @rad182 and @hrishikesh ,

I am facing the same issue here. My Next.js deployment on Netlify has functions invoked almost every seconds . I was forced to upgrade my free tier to a paid tier in order to keep the site running.

To give you more context: I did not have any redirects setup in my next.config.js, I am using getStaticProps without any revalidation period, and I am using next’s Image component.

My site name is stunning-ganache-7b2073.
My site id is a008ebe8-bde6-42cc-9579-d8d155e96bef

Can you help me identify if there is anything that I have done incorrectly in my setup?

Thank you.

I can see a lot of SSR calls here: Netlify App

Maybe that’s the cause?

Hi @hrishikesh,

Yes but I have no idea why those SSR are being invoked, my site has minimal traffic but the functions call are constant.
This is my deployment log:

I realise there are others who also faced the same issues

I don’t think your site has minimal traffic. In the past 7 days, 256776 requests were made to your site. I do see that a majority of the requests appear to be coming from some kind of bots. I see the substring of the top user agents as:

Bytespider: https://zhanzhang.toutiao.com/
MJ12bot/v1.4.8: http://mj12bot.com/
DotBot/1.2: https://opensiteexplorer.org/dotbot

and a few moe like Bingbot and Googlebot.