One write in bigtable datastore cost around 900 mcycles. One read cost
around 40 mcycles. You have one write and 10 reads and this reason why
it is 1252 avg.

There is no memcache that can help you with writing to datastore. Also
memcache can't help you in reading from datastore with standard design
(for desktop application, or even low (or expensive) scalable web
application).

Problem is in your expectation. There is probably no way in creating
cheep total scalable information system if you allow more than one
write per request.

To achieve under 1200 mcycles you need to think out of the box.
Transfer more programming logic to client side (javascript) and learn
some paging tehnics with app engine. Python code isn't expensive but
datastore operations are.

Try to read every article about app engine before you start to write
any code. My first request took around 70000 mcycles, second design
15000 mcycles, and third and final design (after complete
documentation and group reading) is always under 1000 mcycles but now
instead of one web request I have more than 30 requests for same. With
smart memcache usage (for reading requests) you can have average web
request under 100 mcycles. It takes more time but when you achieve
this it is worthy.

My only problem with one write datastore operation per request is no
internal counter system. So when you implement shard counter principle
and divide this in two requests (one write plus one counter write) you
have possible problem when first write request finished nice and
second not.

So you should design your system not to depend too much on counter
information. Maybe some information purpose where 99% precision is
fine.

On Dec 14, 8:58 am, Thomas <[email protected]> wrote:
> Hi all,
>
> I made a very simple performance test to find out, why my scripts
> reach the 1000 megacycle per request.
>
> 1.) With template:
>
> <---- Schnip
>
> import os
> from google.appengine.ext import webapp
> from google.appengine.ext import db
> from google.appengine.ext.webapp import template
> from google.appengine.ext.webapp.util import run_wsgi_app
>
> class User(db.Model):
>   name = db.StringProperty(required=True)
>   password = db.StringProperty(required=True)
>
> class MainHandler(webapp.RequestHandler):
>
>   def get(self):
>     new = User(
>             name="Mandy",
>             password="MM"
>               )
>     new.put()
>
>     template_values = {
>       'query' : db.GqlQuery("SELECT * FROM User ORDER BY __key__ DESC
> LIMIT 10")
>       }
>
>     path = os.path.join(os.path.dirname(__file__), 'test2.html')
>     self.response.out.write(template.render(path, template_values))
>
> def main():
>     run_wsgi_app(webapp.WSGIApplication(
>                 [
>                     ('/test/', MainHandler)
>                 ])
>                 )
>
> if __name__ == '__main__':
>     main()
>
> Schnap ---->
>
> The script uses a very simple template with html header (2 metatags
> und title) and an empty body. A test with 1000 requests, every 4
> seconds one, shows 1250 avg megacycles per request.
>
> 2.) Without template
>
> <---- Schnip
> from google.appengine.ext import webapp
> from google.appengine.ext import db
> from google.appengine.ext.webapp.util import run_wsgi_app
>
> class User(db.Model):
>   name = db.StringProperty(required=True)
>   password = db.StringProperty(required=True)
>
> class MainHandler(webapp.RequestHandler):
>
>   def get(self):
>     new = User(
>             name="Mandy",
>             password="MM"
>               )
>     new.put()
>
>     results = db.GqlQuery("SELECT * FROM User ORDER BY __key__ DESC
> LIMIT 10"
>
>     self.response.out.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML
> 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>')
>     self.response.out.write('<html xmlns="http://www.w3.org/1999/
> xhtml" lang="de" xml:lang="de">')
>     self.response.out.write('<head>')
>     self.response.out.write('<meta http-equiv="Content-Type"
> content="text/html; charset=UTF-8" />')
>     self.response.out.write('<link href="/stylesheets/main.css"
> rel="stylesheet" type="text/css" />')
>     self.response.out.write('<title>TEST2</title>')
>     self.response.out.write('</head>')
>     self.response.out.write('<body>')
>
>     for result in results:
>         self.response.out.write ('Name:'+ result.name + '<br>')
>         self.response.out.write ('Password:' + result.password +
> '<br>')
>         self.response.out.write ('ID:' + str(result.key().id()) +
> '<br>')
>
>     self.response.out.write('</body>')
>     self.response.out.write('</html>')
>
> def main():
>     run_wsgi_app(webapp.WSGIApplication(
>                 [
>                     ('/test2/', MainHandler)
>                 ])
>                 )
>
> if __name__ == '__main__':
>     main()
>
> Schnap ----->
>  A test with 1000 requests, every 4 seconds one, shows 1240 avg
> megacycles per request.
>
> 3.) With DB-Query (NO GQL) + templates
>
> <--- Schnip
>
> import os
> from google.appengine.ext import webapp
> from google.appengine.ext import db
> from google.appengine.ext.webapp import template
> from google.appengine.ext.webapp.util import run_wsgi_app
>
> class User(db.Model):
>   name = db.StringProperty(required=True)
>   password = db.StringProperty(required=True)
>
> class MainHandler(webapp.RequestHandler):
>
>   def get(self):
>     new = User(
>             name="Mandy",
>             password="MM"
>               )
>     new.put()
>
>     query = User.all()
>     results = query.fetch(limit=10)
>
>     template_values = {
>       'query' : results
>       }
>
>     path = os.path.join(os.path.dirname(__file__), 'test2.html')
>     self.response.out.write(template.render(path, template_values))
>
> def main():
>     run_wsgi_app(webapp.WSGIApplication(
>                 [
>                     ('/test/', MainHandler)
>                 ])
>                 )
>
> if __name__ == '__main__':
>     main()
>
> Schnap ----->
> A test with 1000 requests, every 4 seconds one, shows 1252 avg
> megacycles per request.
>
> Question:
> I'm a really Python and Google App Engine newbie and I tryed a lot
> different scripts. But every script which puts something to the
> datastore and reads some information from the datastore exceeds the
> 1000 megacycle per request. Has somebody some tipps or ideas?
>
> 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 [email protected]
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to