Home > Blockchain >  Google Apps Script - Avoiding doPost Simultaneous Execution Limits
Google Apps Script - Avoiding doPost Simultaneous Execution Limits

Time:06-17

Question: What is the best way to deploy a Google Apps Script as a web app to receive a high volume of POST requests from users?

Context:

  • I am developing a Chrome Extension that uses Google Apps Script on the backend
  • I have the Google Apps Script deployed as a web app. Data is sent from the extension to Google Apps Script via POST, and Scripts receives the data via the doPost() function.
  • I currently have the web app deployed as Execute as > Me ([email protected]), Who Has Access > Anyone. This works as intended with the Chrome Extension during testing.

    As my user base expands, however, I am concerned I may run into the "30 simultaneous executions/user" limit pretty quickly, as noted in the official Google Scripts documentation: https://developers.google.com/apps-script/guides/services/quotas


    I know the general recommendation is to have the GAS deployment execute as "User accessing this app," but I don't understand how that configuration would work in conjunction with POST requests sent from a Chrome Extension.

  • CodePudding user response:

    It depends on what exactly you're trying to do, but you may simply be running into the limits of Apps Script's intended usage. In my experience, Google doesn't make exceptions for Apps Script quota limits unlike GCP API quotas, which do have a request increase process, which tells us that they probably don't really want you using Apps Script at a large scale like this.

    You still have a couple options. First make sure that you really need to run the app as yourself, though I assume you already know this and are probably accessing APIs with your own account or something similar.

    Also, 30 simultaneous executions doesn't necessarily mean 30 users max, since not all of them will be sending requests all the time. If your app only calls the script occasionally you can get away with more than that, especially with a retry strategy like exponential backoff. A somewhat dodgy approach could also be to set up multiple scripts and have your extension randomly choose between them along with a backoff strategy. Note that these scripts would have to be from different accounts because the 30 simultaneous executions are for all scripts within your account.

    If you expect your user base to really grow, as in commercial app levels, you'll need to look at a reliable solution like App Engine or your own server that connects to the Google APIs. Apps Script is not suited to something like that.

    • Related