---
title: "Optimizing Google Apps Script: Minimizing latency with Google Cloud data regions"
author: "Martin Hawksey"
date: 2024-09-24T21:07:47+00:00
modified: 2024-09-24T21:08:55+00:00
canonical_url: https://pulse.appsscript.info/p/2024/09/google-cloud-region-latency-in-google-apps-script/
markdown_url: https://pulse.appsscript.info/p/2024/09/google-cloud-region-latency-in-google-apps-script.md
categories:
  - "Gotchas"
tags:
  - "justin.poehnelt.com"
featured_image: https://pulse.appsscript.info/files/2024/09/Min-Latency-Max-Latency-Mean-Latency-and-Median-Latency.png
description: "As Google Apps Script is a software as a service, writing efficient code is crucial, especially for complex solutions. It's also important to consider marginal gains, such as finding small ways to improve your script's responsiveness. If you're using Google Cloud services like Vertex AI, Cloud Functions, or others, you'll also want to consider the latency between your Apps Script code and the Google Cloud data region. Justin Poehnelt recently revisited the work of Ivan Kutil, providing a way to measure Google Cloud region latency from your Apps Script project. Interestingly, when I ran Justin's sample code, I found that the region with the lowest median latency (us-east1) was approximately 11 times faster than the region with the highest (asia-south2). Click through to make a copy of the sheet to view my results and run the test for yourself."
---

# Optimizing Google Apps Script: Minimizing latency with Google Cloud data regions

![Optimizing Google Apps Script: Minimizing latency with Google Cloud data regions](https://pulse.appsscript.info/files/2024/09/Min-Latency-Max-Latency-Mean-Latency-and-Median-Latency.png)

> [https://justin.poehnelt.com/posts/apps-script-gcp-region-latency/](https://justin.poehnelt.com/posts/apps-script-gcp-region-latency/)
> Ping results to Google Cloud regions and short code snippet demonstrating how to measure latency from Google Apps Script.

As Google Apps Script is a software as a service, writing efficient code is crucial, especially for complex solutions. It’s also important to consider marginal gains, such as finding small ways to improve your script’s responsiveness.

If you’re using Google Cloud services like Vertex AI, Cloud Functions, or others, you’ll also want to consider the latency between your Apps Script code and the Google Cloud data region. Justin Poehnelt recently revisited the work of Ivan Kutil, providing a way to measure Google Cloud region latency from your Apps Script project.

Interestingly, when I ran Justin’s sample code, I found that the region with the lowest median latency (us-east1) was approximately 11 times faster than the region with the highest (asia-south2). You can [make a copy of this sheet**](https://docs.google.com/spreadsheets/d/1M8xLiT_d7kj2HkTNWWRe6a7iWk0xcXiN468jwIeNKD4/copy) to view my results and run the test for yourself.

![](https://pulse.appsscript.info/files/2024/09/Min-Latency-Max-Latency-Mean-Latency-and-Median-Latency-1.png)

Source: *[Google Cloud Region Latency in Google Apps Script | Justin Poehnelt*](https://justin.poehnelt.com/posts/apps-script-gcp-region-latency/)

---

*Published by [Martin Hawksey](https://pulse.appsscript.info/p/author/admin/) on [Pulse](https://pulse.appsscript.info/). Original article: [https://pulse.appsscript.info/p/2024/09/google-cloud-region-latency-in-google-apps-script/](https://pulse.appsscript.info/p/2024/09/google-cloud-region-latency-in-google-apps-script/)*
