I have a paid app on the app engine. At the moment, usually there is only one instance. The app has a download handler that sends an image after re-sizing it if it is too big. The problem is: if a web page contains many big images (60 or more) the app engine creates another instance. I'm trying to keep the app as cheap as possible and creating too many instances is probably not good for that.
Is there a way to improve this code? Or my concerns are just unfounded?
The application settings are:
automatic_scaling: min_idle_instances: 1 max_pending_latency: 10s
class ServeHandler(blobstore_handlers.BlobstoreDownloadHandler): def get(self, resource): resource = str(urllib.unquote(resource)) blob_info = blobstore.BlobInfo.get(resource) if not blob_info: pass else: data = blobstore.fetch_data(blob_info.key(), 0, 50000) img0 = images.Image(image_data=data) img = images.Image(blob_key=blob_info.key()) if img0.width >= 800: img.resize(width=800) img = img.execute_transforms(output_encoding=images.JPEG) self.response.headers['Content-Type'] = 'image/jpeg' self.response.out.write(img) else: self.send_blob(blob_info)