GAE flexible environment lets you specify the resources your container needs. For example:

  cpu: 0.5
  memory_gb: 1.3
  disk_size_gb: 10

This will allocate g1-small instances with 1.7GB of memory. However, if I raise memory_gb to 1.5, GAE now allocates n1-standard-1 instances with 3.75GB of memory.

Why does the scheduler appear to over-allocate memory by over 10%? Does that mean that my container running in g1-small can't actually safely use all 1.7GB of memory the instance has?

(The underlying question is: given an instance's memory size, and running under GAE flexible environment, what should I set node's --max-old-space-size to ensure my process doesn't thrash? But given answers to the above questions I can probably figure this out.)


As of yesterday, a new Beta release of the App Engine flexible environment was deployed and no longer specifies the machine type upon container instance creation. As described in this Resource Settings’ link, the app engine takes care of assigning an instance with sufficient resources to at least guarantee your specified amount of CPU and memory for your application. Therefore, the amount of memory you specify for the memory_gb variable, will be the amount of memory available for your container.

Alternatively, upon configuring your App Engine application and deploying it to the Cloud, you can do the following steps to retrieve the amount of memory available to you application:

  1. Run the command:

    gcloud compute instances describe NAME [--zone=ZONE]
  2. Locate key: gae_app_container_memory_mb

    The value under gae_app_container_memory_mb represents the guaranteed minimum amount of memory(in MB) available to your container. (see this link for more information)

Concerning you previous observations, the observed behaviour would be related to the required instance overhead to run the application’s environment and so as a precaution, happened to need more memory than requested (i.e. setting a more powerful GCE instance type).

As a last note, this Beta release of the App Engine flexible environment is not covered by any SLA or deprecation policy and the implementation may change, possibly in backward-incompatible ways. Therefore, It is not recommended for production use.

  • Thanks, I'll try to migrate to env: flex ASAP. In the meantime, I tried gcloud compute instances describe but my instances don't have a gae_app_container_memory_mb key. Is that only set for env: flex instances? – Piotr Nov 26 '16 at 2:34
  • You are right, the gae_app_container_memory_mb key is currently only available on an App Engine Flexible Environment instance. – Alex Nov 29 '16 at 22:45
  • I update to env: flex, but now the instances no longer show up in GCE (or in gcloud compute instances). I tried using gcloud app instances describe instead, but ran into a bug: code.google.com/p/google-cloud-sdk/issues/detail?id=1435. – Piotr Dec 27 '16 at 6:26
  • Anyway, I think the new behavior is much easier to understand and the correct amount of memory gets reported to the process, so I can constrain Node appropriately so it won't trash. Nice improvements -- thanks! – Piotr Dec 27 '16 at 6:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.