I have a Python App Engine application which serves about 3M requests per day. I am trying to optimize the app to save on my ridiculously ballooned hosting bill.
November, App Engine Frontend Instances: 12924.391 Hours, $604.22
I have the request handling down to some memcached calls, but now I've noticed that it usually takes about 20ms, sometimes as long as 166ms before webapp2 even passes the request to me.
In the image below you can see a Trace showing "Post" happening at 166ms.
Here is the code serving this.
import logging
logging.info("main.py logging imported")
from imports import *
from handlers import *
logging.info("completed importing others")
class Main(webapp.RequestHandler):
def post(self):
logging.info("Post")
self.get()
...
app = webapp.WSGIApplication(
[
('/.*', Main)
],
debug=False
)
What have I tried?
I have threadsafe enabled, so any imports should not be happening before the request is served. Just to be sure, I also added logging to see when the imports happen and as you can see they are not done for every request.
More information
It is not important that the latency is low, except to save on the hosting bill. I would be fine even with a 1 minute response time (the requests are an API webhook), as long as it wouldn't count for front-end instance time!
In case it is relevant, here is the beginning of my app.yaml.
application: coolestsports-hrd
version: 1
runtime: python27
threadsafe: yes
api_version: 1
automatic_scaling:
min_idle_instances: 1
min_pending_latency: 1000ms
