Hey Thomas, Thanks for the reply.
-So are textProperties more efficient than StringProperties because they're not indexed? -I noticed something weird: I do not have an index listed in appengine dashboard for the thumb datastore. Maybe that's what's causing this problem? To find all the images for a particular item I use back references. -I see your point about Memcache & Cache handlers which should help optimize the system. But Isn't it important to get the basic functionality straightened out before using those extra tools? This isn't a very complex operation AT ALL; which is why it is so puzzling to me that it takes so many resources. -Wouldn't adding etag--while increasing efficiency if I have the same users loading the same image again and again--actually decrease efficiency for users who are opening up an thumbnail for the first time? In that situation, I'd have another column for etags in my datastore being requested w/ every query. -Could this problem be a result of having two reference properties in one Model? Also, is back referencing inefficient? Should I instead just store all the Keys as strings & then query the datastore for all entries that have that Key? Thanks! On Sep 25, 1:52 am, Thomas Johansson <[EMAIL PROTECTED]> wrote: > At Google IO I believe it was mentioned that TextProperty's are fine > for anything that you don't want indexed; They are no less efficient > than strings for short data. You might want to look into trying that > out with mime and type if you don't filter/order by them. > > Other than that, I'd suggest trying to memcache the images, something > to the effect of: > > id = int(id) > cache_key = 'ImageThumb:%i' % id > image = memcache.get(cache_key) > if not image: > image = ImageThumb.get_by_id(id) > if image: > memcache.set(cache_key, image, 3600) > if image: > self.response.headers['Content-Type'] = str(image.mime) > self.response.out.write(image.thumb) > else: > self.error(404) > > In addition to that, I'd recommend you generate cache headers, in > particular etag and expiration. A good idea would be to generate the > etag when the ImageThumb is created, and then compare against that > from cache, before you write out the image. As an added bonus you > could store the etag on it's own in the cache, separate from the > image, and only pull out the actual image in case the etags don't > match. > > On Sep 25, 4:59 am, iceanfire <[EMAIL PROTECTED]> wrote: > > > I'm still having trouble with high-cpu warnings for thumbnails. This > > time around I took some profiler data to see what's causing it. But > > before I get into that here is the model i'm using: > > > class ImageThumb(db.Model): > > binId = db.IntegerProperty() > > thumb = db.BlobProperty(default=None) > > building = db.ReferenceProperty(Buildings) > > apartment = db.ReferenceProperty(Apartments) > > mime = db.StringProperty() > > type = db.StringProperty(choices=['Floor Plan','Picture']) > > created_by = db.UserProperty() > > > So here's the Profiler cpu data: > > 2538 function calls (2472 primitive calls) in 0.028 CPU seconds (rest > > of the data:http://docs.google.com/Doc?id=dgfxff5_30hc9tjsgg) > > > But here's the warning: This request used a high amount of CPU, and > > was roughly 1.3 times over the average request CPU limit. High CPU > > requests have a small quota, and if you exceed this quota, your app > > will be temporarily disabled. > > > Here's the megacycle info from the new Admin console: 1339mcycles 7kb > > > Here's the code that pulls up the data for thumbnails: > > class Apt_thumb (webapp.RequestHandler): > > def get(self,id): > > image = ImageThumb.get_by_id(int(id)) > > if image: > > self.response.headers['Content-Type'] = > > str(image.mime) > > self.response.out.write(image.thumb) > > else: > > self.error(404) > > > The images stored are 4kb each in the datastore. As I said, I had this > > problem earlier, so I had taken out the full image and put that in its > > own Model. Clearly that didn't help. > > > Any idea what's causing this high-cpu error & how I can fix it? > > > Thanks! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to google-appengine@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en -~----------~----~----~----~------~----~------~--~---