

![]() | Start a set with this search |
![]() | Include this search in one of my sets |
![]() | Exclude this search from one of my sets |
![]() | Permalink to these results Paste this link in email or IM: |
| Atom feed for tracking future search results Paste this URL into your reader: |
9 messages in com.googlegroups.google-appengine[google-appengine] Re: felxible shard...| From | Sent On | Attachments |
|---|---|---|
| conman | Aug 13, 2008 4:11 am | |
| Calvin Spealman | Aug 13, 2008 3:07 pm | |
| Bill | Aug 13, 2008 7:03 pm | |
| conman | Aug 14, 2008 12:16 am | |
| conman | Aug 14, 2008 12:39 am | |
| Bill | Aug 14, 2008 10:38 am | |
| Bill | Aug 14, 2008 11:39 am | |
| Bryan A. Pendleton | Aug 14, 2008 12:15 pm | |
| conman | Aug 14, 2008 11:58 pm |

![]() | Permalink for this message Paste this link in email or IM: |
![]() | Permalink for this thread Paste this link in email or IM: |
| Atom feed for this thread Paste this URL into your reader: |
| Subject: | [google-appengine] Re: felxible sharded counter | Actions... |
|---|---|---|
| From: | Bill (bill...@gmail.com) | |
| Date: | Aug 13, 2008 7:03:41 pm | |
| List: | com.googlegroups.google-appengine | |
Constantin,
That's a good idea to increase the shard number. From the docs, it looks like db.run_in_transaction() will already try to run the transaction a number of times. I added your idea to my implementation and didn't put it in the transaction. Instead, I have the shard handler increase the number of shards and retry with a totally new transaction, upto a max shard number.
I've put the code, which also uses memcache, over here: http://pastie.org/252692
Just tried out Jing and posted a movie showing the code in use as I create a Counter in a shell running on AppEngine servers: http://screencast.com/t/d4YnIgzIi3a
Cheers and thanks for the idea, Bill
On Aug 13, 4:11 am, conman <cons...@googlemail.com> wrote:
Hello,
I have implemented a variation of the sharded counter form Google IO speech (http://sites.google.com/site/io/building-scalable-web- applications-with-google-app-engine)
My variation is that instead of haveing a fixed number my number of shards increases if contention on the counter increases.
But I am not quite sure if I have done it right: Please have a look:
def inc(self): try: def txn(): c = self._get_one() # get sharded counter by random c.count += 1 # increase counter c.put() # write counter try: db.run_in_transaction(txn) except db.TransactionFailedError(): # if this transaction fails... logging.debug('Counter %s: inc failed.' % self.name) self.num_shards += 5 # increase number of shards self.put() except: pass
You see, when the transaction fails due to high contention I modify the number of shards. But I am not sure, if I should place this
self.num_shards += 5 # increase number of shards self.put()
inside a transaction or not...? I mean if contention is high a lot threads are going to try to increase the number of shards. Is it correct to ignore the case when this code fails (the outer try/except block) or should it be placed inside a transaction (which would leed to retries of this code)?
Regards, Constantin
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To post to this group, send email to goog...@googlegroups.com
To unsubscribe from this group, send email to
google-appengine+unsu...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---







