views:

60

answers:

4

Say you are creating a facebook style app for the app engine. How would you handle user profile pics?

As far as I know, you would have to either store the images in the datastore or blobstore. Which means every fetch to a picture would require going through a dynamic handler and using up at least 20ms cputime.

Is there an efficient way to do this? Or is this just something the app engine can't currently handle?

A: 

i think that dynamic handler is there for a reason: imagine having static image url connected to your account posted on internet: you are gonna be billed for everyone that is using it on it's blog (for example).

fazo
Using a dynamic handler isn't going to prevent hotlinking.
Drew Sears
could you explain that?
fazo
To prevent hotlinking you need to check referers and send a 403 for unauthorized ones. Using a dynamic handler doesn't give you this automatically.
Drew Sears
A: 

And cache the most recently used images in the memcache. That's pretty much all the platform affords.

GAE is a good tool for the class of applications it was built for. Making a Flickr clone is outside its design intentions.

msw
+2  A: 

Let's compare a few different options:

Google App Engine:

  • $0.10 per CPU hour
  • $0.12 per gigabyte outgoing bandwidth

Google Storage for Developers:

  • $0.01 per 10,000 GET requests
  • $0.15 per gigabyte downloaded for Americas and EMEA

Amazon S3:

  • $0.01 per 10,000 GET requests
  • $0.15 per gigabyte up to 10 TB / month data transfer out

Say you're serving 10 million images at 50KB each.

On App Engine, with a dynamic handler using 20ms per request, this is going to cost you $57.22 in outgoing bandwidth plus $5.55 in CPU time. On Google Storage or S3, you'll pay $71.52 for the outgoing bandwidth plus $10 for the GETs.

So basically if your handler uses less than 36ms CPU time, it's cheaper on App Engine than on services designed for this exact purpose. Somebody double-check my math, please. =)

Drew Sears
+1  A: 

You don't have this issue anymore, since get_serving_url() doesn't use any of your CPU quota (only outgoing bandwidth and storage). Plus it gives you scaling and cropping for free.

Amir
Yep, that new functionality solves this problem
Kyle