Search code examples
firebasegoogle-cloud-platformgoogle-cloud-functionscold-start

Measuring cold start time in google cloud metrics explorer


We are working on some optimizations to decrease cold start time in our firebase cloud functions. As a result of this we'd like to compare the execution times before and after these changes were implemented.

Is there a reliable way to measure cold start time for a cloud function in the google cloud metrics explorer?

The closest metric I could find is execution time, but its unclear if that includes the time it takes to load the dependencies before running a function.

metrics


Solution

  • You can check all the Firebase Database Performance usage with several options to choose to measure this and an overview of what each one offers. But what will focus on is the last part in the Cloud monitoring paragraph.

    The steps for setting up Cloud Monitoring are described in Monitor Database Usage.

    If you keep reading this page there is a Cloud Monitoring overview of the metrics you can use and this can help you to navigate through a list you can find in the next page that is the Monitor Database Usage. This page also includes more details of the mentioned options you have to measure the performance of firebase and finally, in the Cloud Monitoring section there is a link to a list of all the metrics you can use, looking through it I think the closest to your specific case it is the instance/cpu/scheduler_wait_time by its description:

    Wait time is the time a vCPU is ready to run, but unexpectedly not scheduled to run. The wait time returned here is the accumulated value for all vCPUs. The time interval for which the value was measured is returned by Monitoring in whole seconds as start_time and end_time. This metric is only available for VMs that belong to the e2 family or to overcommitted VMs on sole-tenant nodes. Sampled every 60 seconds. After sampling, data is not visible for up to 240 seconds. instance_name: The name of the VM instance.

    Feel free to navigate through them and choose the one that covers your needs, I found other metrics that can also be helpful in your case.