简体   繁体   English

计量Google App Engine服务

[英]Metering on Google App Engine services

I have been working on a java application on GAE that uses services like cloud sql,calender api , mail API and data-store . 我一直在使用GAE的Java应用程序上工作,该应用程序使用云sql,日历api,邮件API和数据存储等服务。 So my question is that I need to meter the usage of these services for the users accessing my application . 所以我的问题是,我需要为访问我的应用程序的用户衡量这些服务的使用情况。 This will be based on how many I/O's they do on cloud sql or how much data they have stored . 这将基于它们在云sql上执行的I / O数或已存储的数据量。 Is there any way to do that ? 有什么办法吗?

There is no builtin way to meter quota per user. 没有内置的方法来计量每个用户的配额。 You might be able to get away with keeping track of each user's accesses to these resources and storing them in the datastore, though this will drive usage up. 您可能可以跟踪每个用户对这些资源的访问并将它们存储在数据存储中,尽管这会提高使用率。 2 writes are needed for each use, or 4 if it is indexed. 每次使用需要2次写入,如果已索引则需要4次写入。

If you don't require precise metering, and are OK with metering data being lost if Google's resources run low, you can store it in memcache as username/id->metering data. 如果您不需要精确的计量,并且可以在Google资源不足的情况下丢失计量数据,则可以将其作为用户名/ id->计量数据存储在内存缓存中。 It is provided on a best-effort basis which should be enough if tied with your own per-app sanity limits and there is no need to bill users. 它是尽最大努力提供的,如果与您自己的每个应用的健全性限制挂钩,就足够了,并且无需向用户收费。

The two can optimally be used together. 两者可以最佳地一起使用。 Every few minutes to an hour, write the memcached usage details to the datastore, and if data is lost from the memcache(unless you purchase dedicated memcache), restore from the datastore(possibly estimating usage over the past lost period). 每隔几分钟到一个小时,将一次内存缓存使用情况详细信息写入数据存储,如果数据从内存缓存中丢失(除非您购买了专用的内存缓存),请从​​数据存储中还原(可能是估计过去丢失期间的使用情况)。

Currently there is no way to meter the usage of each service. 当前,尚无办法衡量每种服务的使用情况。 but this may help you to get the cost & CPU usage of each request. 但这可以帮助您获取每个请求的成本和CPU使用率。

App Engine will include a couple of extra headers in all the HTTP responses it sends you. App Engine在发送给您的所有HTTP响应中都会包含几个额外的标头。 Here's HTTP headers that will help to meter the resource usage & Estimated-CPM-US-Dollars: 这是HTTP标头,有助于计量资源使用情况和估算的CPM-US-Dollars:

X-AppEngine-Resource-Usage: ms=293 cpu_ms=500 api_cpu_ms=236 
X-AppEngine-Estimated-CPM-US-Dollars: $0.012320

Here are some reference: http://googleappengine.blogspot.in/2009/08/new-features-in-124.html https://developers.google.com/appengine/docs/java/#Java_Responses 以下是一些参考: http : //googleappengine.blogspot.in/2009/08/new-features-in-124.html https://developers.google.com/appengine/docs/java/#Java_Responses

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM