Home > Software engineering >  How to measure available memory in a Google App Engine standard instance?
How to measure available memory in a Google App Engine standard instance?

Time:12-21

I'm trying to log memory usage/available memory in a python app on a Google App Engine standard instance. Using psutil gives me the same value for an F2 instance as an F4 instance, so it doesn't seem to return what I'm expecting.

Is there a way to measure the available free memory so we know when an instance approaches its memory limit?

CodePudding user response:

Not an ideal solution, but I ended up deploying a version with max_instances: 1 just to be able to see the memory usage graph for a single instance using the cloud console. I also set a percentage split with another version without max_instances so the rest of the instances can auto-scale if needed.

enter image description here

CodePudding user response:

There are different ways to monitor the Memory Usage in Google App Engine.

  • On the Google Cloud Console, you can check the memory usage using the Dashboard on the App Engine. screenshot.

  • Runtime API allows you to get CPU and Memory usage from the Python runtime. You can get a SystemStat memory usage with: google.appengine.api.runtime.runtime.memory_usage()

  • Cloud Profiler helps you analyze performance issues, CPU utilization, and memory usage.

  • GAE Mini Profiler does provide memory metrics; it will let you know how much memory was being used.

  • Apptrace is a package that provides a WSGI middleware for tracking memory usage in Google App Engine Python applications. Do take note that according to this documentation:

Since Apptrace is meant for development and debugging purposes only, it works with the development appserver of the Google App Engine Python SDK and TyphoonAE. It will definitely not work in the GAE production environment.

  • Related