When will memory get freed after completing the request on App Engine Backend Instances?

后端 未结 2 997
Happy的楠姐
Happy的楠姐 2020-12-19 20:11

Scenario-

I am running B* instances on App Engine. I\'ve a background ETL related task(written in python) scheduled as a cron job on App Engine. Whe

2条回答
  •  抹茶落季
    2020-12-19 20:56

    There are a few questions on StackOverflow describing similar memory issues for tasks when using ndb on app engine. Here is one example.

    The issue is that app engine doesn't clear the ndb context cache upon the conclusion of a task so context cache continues to hog your memory long after the task completes.

    The solution is to not use or clear the context cache during your tasks. Here are a few ways:

    • Bypass caching with key.get(use_cache=False)
    • Call ndb.get_context().clear_cache() at appropriate times.
    • Disable caching for all entities of a kind by adding _use_cache = False to your model definition.

提交回复
热议问题