[Stack Overflow] Why does the first response takes more time in GAS web app?

71 views
Skip to first unread message

Levente Bélteky

unread,
Jul 10, 2019, 7:30:05 AM7/10/19
to Google Apps Script Community
Hi there!

I have asked a question on Stack Overflow already, so I am just reposting it here.


Thanks in advance.

Clark Lind

unread,
Jul 14, 2019, 9:44:50 PM7/14/19
to google-apps-sc...@googlegroups.com
Not exactly sure, but are you using the BetterLog as a library, or do you have it as a copy within the script? See what happens if you comment that out. If the script is loading an 'external' library, that can slow things down. Just a wild guess... the first run has to go get and load BetterLog. Try it without it and see if that is the culprit.

(from: https://developers.google.com/apps-script/guides/libraries)
Warning: A script that uses a library does not run as quickly as it would if all the code were contained within a single script project. Although libraries can make development and maintenance more convenient, you should use them sparingly in projects where speed is critical. Because of this issue, library use should be limited in add-ons.

Levente Bélteky

unread,
Jul 15, 2019, 3:17:56 AM7/15/19
to Google Apps Script Community
Thanks for replying here and on Stack Overflow as well.

I will try to disable or include the source code in my project.

The interesting part for me is that it is a deployed web application so I'd assume that everything is loaded during deployment. Also if we let it go "idle" and send a request again it will be slow again.


Request 1 sent and got a response in 3000ms+
Request 2 sent and got a response in 15000ms+
Waiting for 15-30 minutes
Request 3 sent and got a response in 3000ms+
Request 4 sent and got a response in 15000ms+

Eric Koleda

unread,
Aug 12, 2019, 8:22:17 PM8/12/19
to Google Apps Script Community
The Apps Script servers don't keep every script ever written or deployed loaded in memory, and so scripts that haven't been run in a while need to be loaded from disk first. This is usually referred to as a "cold start time" in Cloud providers.

- Eric

Levente Bélteky

unread,
Aug 13, 2019, 3:11:33 AM8/13/19
to Google Apps Script Community
Thank you for your answer, Eric.
Reply all
Reply to author
Forward
0 new messages