How can I profile memory (RAM) usage on my App Engine app? I'm trying to address errors related to exceeding the instance memory limit. I've tried these things and, so far, they don't work or don't provide what I need.
guppy.hpy()
fails with ImportError: No module named heapyc
Am I wrong about any of the above? The top-rated answer (not the accepted one) on this question says that there is no way to monitor memory usage on App Engine. That can't be true. Can it?
EDIT
I can confirm that GAE mini profiler does the job. After installation, I could change the settings in the UI to "sampling with memory" and then see this readout:
Thanks to all the contributors !
GAE Mini Profiler does provide memory stats if you use the sampling profiler and set memory_sample_rate
nonzero; at each snapshot it will tell you the memory that was in use. You will want to turn the sample frequency way down as the memory sample takes a few ms to execute.
Edit: the way it gets the memory stats is from the GAE runtime API which is deprecated, but still worked as of last I knew; I'm not sure if there's a good replacement.
To add to Ben's answer , as of 16th November 2015, despite being deprecated, the Google App Engine runtime API still works. There isn't an official replacement from Google yet.
from google.appengine.api.runtime import runtime
import logging
logging.info(runtime.memory_usage())
This will output memory usage statistics, where the numbers are expressed in MB. For example:
current: 464.0859375
average1m: 464
average10m: 379.575
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.