views:

49

answers:

3

In the documentation for Google App Engine, it says that when designing data models for the datastore, you should "optimize for reads, not writes". What exactly does this mean? What is more 'expensive', CPU intensive or time consuming?

+1  A: 

It means that "reads" are cheaper than "writes". "Writes" takes more time and more resources. For more information check the presentation "Building Scalable Web Applications with Google App Engine" by Brett Slatkin from Google I/0 2008 (slides 7-8)

Ilian Iliev
A: 

"Optimize for reads, not writes" means that you should expect to see far more reads than writes, and so you should strive to make it as easy as possible to read your data, even if that might slow down the writes a little. Easy for the computer, that is, meaning that for example if you want to show names in all lowercase, you should lowercase them when they're written to the database rather than lowercasing them everytime you read them from the database. That's just an example but hopefully it makes things clear.

redtuna
A: 

agreed with @redtuna (expecting more reads than writes) and @Ilian Iliev (reads cheaper than writes & writes take more resources). another way you can optimize for reads is by using the Memcache service. since reads (usually) happen more often than writes, caching that data means that you don't even have to take a hit of a datastore access. also, items that stay active (see fetches/hits) stay in the cache longer as it employs an LRU strategy.

wescpy