Appengine Optimizations

2019-06-13 16:33发布

How can I get the requests of my Google AppEngine application to perform better and faster (i.e. less load times and less CPU usage)? I'm specifically referring to imporvements for the server-side portion of the app, and not the client-side.

5条回答
相关推荐>>
2楼-- · 2019-06-13 17:17

I'd recommend using Appstats to see where in your app there's bottlenecks.

查看更多
老娘就宠你
3楼-- · 2019-06-13 17:19

I use memcache which significantly increased my app's performance. I hope it also can be usable for you. When using memcache in combination with a HTTP header setting the cache-control I've gotten significant improvements in response times.

查看更多
混吃等死
4楼-- · 2019-06-13 17:20

One often overlooked aspect is that various Appengine related services support asynchronous processing, for example Datastore:

https://cloud.google.com/appengine/docs/java/datastore/async

and URL Fetch:

https://cloud.google.com/appengine/docs/python/urlfetch/asynchronousrequests

If you have requests that do various tasks you can see if they can be parallelized.

查看更多
SAY GOODBYE
5楼-- · 2019-06-13 17:26

Use appengine Appstats to see where actually your application uses more cpu resources.Try to find out the reason for that and look for alternative solution. In python you can do lot of optimisation. M

  1. Make use of memcache api which makes data fetch easy and fast. Avoid unnecessary fetch() and get().

  2. Avoid doing a lot of RPCs while using db.reference() property. Nick's blog on this explains about this.

  3. Modeling in appengine matters a lot in performance. Make sure you have the right model designed for your application.

  4. Avoid doing get and fetch unless until you really need them.

查看更多
时光不老,我们不散
6楼-- · 2019-06-13 17:29

This is not really an optimization but the choice of framework is really important here. Most legacy framework in Java and Python(Django,..) are not designed to startup fast because it just isn't important in traditional hosting. Consider using an App Engine specific framework like Tipfy, Kai, Webapp, ... (Python) or slim3, ... (Java).

Ideally, you should organize your data so that each user request needs only one call to the datastore, preferably a db.get because queries are significantly slower. To achieve this, you'll often need to denormalize your data, and maintain the different copies in sync using entity groups and transactions.

When making more than one urlfetch or API call, you can speed up the process by making the calls in parallel using the non-blocking(async) syntax. Caching whenever possible is of course really important too.

If you haven't yet, I recommend watching Google's IO talks (2010 & 2011), in particular this year's Scaling App Engine Applications which does a very good job of describing server-side best practices.

查看更多
登录 后发表回答