Memory available in Google App Engine flexible environment

google-app-enginegoogle-cloud-platform

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

resources:
  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.)

Best Answer

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.

Related Topic