views:

35

answers:

2

Is there an easy way to calculate the size of an entity stored in App Engine? I would like to know how close a particular entity is to hitting the 1 MB upper limit on entity size.

+4  A: 

App engine stores each entity as a protobuf. You can use the db.model_to_protobuf() function described here to manually convert your entity into a protobuf and then use the standard len() method to determine its size in bytes.

Example usage:

from google.appengine.ext import db
sz_in_bytes = len(db.model_to_protobuf(some_entity).Encode())
David Underhill
+2  A: 

Google's documentation on how entities are encoded and stored:

http://code.google.com/appengine/articles/storage_breakdown.html

Forest