Reputation: 4840
I have a finite set of images (> 1000) that will be used on a site hosted on the Google App Engine. In reading the documentation, I noticed there's the Images library that provides various image manipulation capabilities. The one method that caught my attention is
get_serving_url(blob_key, size=None, crop=False, secure_url=None)
This returns a URL that serves the image. The documentation then goes on to say:
This URL format allows dynamic resizing and cropping, so you don't need to store different image sizes on the server. Images are served with low latency from a highly optimized, cookieless infrastructure.
I would like to know if there is an advantage, speed wise, between serving the images from a static folder or using the Image service.
Upvotes: 0
Views: 238
Reputation: 1015
Dynamically resizing images and reading out of the blob store as the other answer here mentions is never going to be that fast. You need to store static copies of your images if you want performance. If for no other reason than caching. Prefer the static version if you can, and prefer a CDN above the static version.
The choice between blob store and static can also revolve around if your content is from you, or submitted by users. If submitted by users, then the blob store is usually the way to go if you're stuck with storing the images on app engine.
In practice, we found the internals of GAE and pricing to be less than adequate for serving images. Instead, consider a CDN if you're especially worried about serving images fast. For example, you could go with Amazon Cloudfront/S3 combo or Rackspace Cloudfiles. In both cases, there was absolutely no comparison speed-wise between using the serving url vs. a CDN.
Simply push your content either directly to the CDN on creation, or keep a fallback copy in the blobstore. What we do in our app is we keep uploaded images by users in the blobstore first, and queue up a background task to submit the content to the CDN. The various sizes such as thumbnails are generated using our CDN's API that we call via REST from App Engine. If somehow the user hits our site before all of this happens and we need these images, we simply serve them the dynamic version you referenced in your question. It's much slower, but it ensures we always have a fall-back while the system is refreshing or generating the CDN content. 99% of the time though, the user hits the fast version in the CDN.
EDIT: I want to point out that certainly the app engine static content is cached, just not with the efficiency of a decent CDN provider in my real world experience running a very image heavy app engine site with lots of unique hits per day.
Upvotes: 2
Reputation: 41089
Images service does not store or serve images. Images are served either from a BlobStore, or from Google Cloud Storage, depending on which option you use. Both options offer very fast response times. I believe that serving files from a static folder will offer very similar performance.
UPDATE:
I noticed that with the new pricing on GAE they will charge the same price for static files as they do for Google Cloud Storage or BlobStore, but the free quota is larger (5GB) for GCS and BlobStore than for code and static files (1GB).
Upvotes: 0