Hi!
I’m in the process of writing a small dummy app mostly to test out Netlify and have so far had an excellent experience. I have reached a small snag, and mostly just wanted to get some insight into netlify function response times and why they might be slower than I would expect.
Here’s the function in question:
https://ecstatic-clarke-d4113c.netlify.app/.netlify/functions/myFirstFunction?name=Ses
When testing locally, I am seeing response times within 200-300ms, which is about what I would expect for a call like this.
Here’s a local log just to show me testing the speed of execution internally:
Request from ::1: GET /.netlify/functions/myFirstFunction?name=Ses
start ms: 1588961969924
Cache hit for Ses
end ms: 1588961970124
duration: 200 ms
Response with status 200 in 203 ms.
Here’s a log from the function running on netlify in production:
2:16:21 PM: 2020-05-08T18:16:21.581Z e1db1dea-a661-4632-81da-0b1e13b862d4 INFO start ms: 1588961781580
2:16:21 PM: 2020-05-08T18:16:21.695Z e1db1dea-a661-4632-81da-0b1e13b862d4 INFO Cache hit for Ses
2:16:21 PM: 2020-05-08T18:16:21.695Z e1db1dea-a661-4632-81da-0b1e13b862d4 INFO end ms: 1588961781695
2:16:21 PM: 2020-05-08T18:16:21.695Z e1db1dea-a661-4632-81da-0b1e13b862d4 INFO duration: 115 ms
2:16:24 PM: Duration: 2908.85 ms Memory Usage: 85 MB Init Duration: 400.03 ms
You can see that the response time is approx 2.9s, which I feel is pretty slow. Being on the free tier, I know I am not a prioritized resource or cache, and I would love to get some insight on the difference between the code execution time I’m seeing (approx 100-200ms) and the actual response time of between 2 and 4 seconds.
If I call the function repeatedly, I’m still seeing similar response times, so I don’t think it’s related to cold startup or anything like that.
I’m trying to use the “preformatted text” thing in the post editor and it doesn’t appear to be changing anything. Apologies for the lack of formatting.