How to reduce the logservice RPC's in google app engine backends
above is the image of appstats of a single GET request to my app,
this image shows the RPC traces of a single logservice RPC
do the number of loservice calls effect the app negatively, for 5 urlfetch RPC's there are around 80 logsservice RPC's while using a backend. i dont know the reason for these logservice rpc calls, how do i reduce the number of logservice RPC's,
in the backends documentation there is limited documentation about logservice
logservice.flush()
how do i contril log开发者_高级运维 flushing in backends, instead of random logservice calls thanks
You can configure log flushing by changing some of the values set by the logservice API, documented here (source). The default is to flush every 10 seconds, 1024 bytes, or 20 lines, whichever comes first. You can disable any of them independently, or disable the whole autoflush process.
To disable autoflush entirely:
from google.appengine.api import logservice
logservice.AUTOFLUSH_ENABLED = False
# When you want to flush manually, do this
logservice.flush()
to flush every 20 lines, with no limit on time or bytes:
from google.appengine.api import logservice
logservice.AUTOFLUSH_EVERY_SECONDS = None
logservice.AUTOFLUSH_EVERY_BYTES = None
logservice.AUTOFLUSH_EVERY_LINES 20 # The default, but set here for clarity
Don't be too stingy with log flushing - as you observe, the RPCs are very fast, and not having your logs flushed can be a real pain when you need to debug something.
精彩评论