I have been working on a java application on GAE that uses services like cloud sql,calender api , mail API and data-store . 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 . 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.
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. 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.
App Engine will include a couple of extra headers in all the HTTP responses it sends you. Here's HTTP headers that will help to meter the resource usage & Estimated-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
© 2022 - 2024 — McMap. All rights reserved.