What are you building? With distributed systems, it can be tricky to do some
things. A single, scalable, atomic counter is an implementation for a
solution, not a solution to a problem. There may be an alternate
implementation that'll make your life easier but solve the problem at hand.

--
Ikai Lan
Developer Programs Engineer, Google App Engine
Blogger: http://googleappengine.blogspot.com
Reddit: http://www.reddit.com/r/appengine
Twitter: http://twitter.com/app_engine



On Wed, Dec 29, 2010 at 6:55 AM, dreamer <[email protected]>wrote:

> It may be possible to simulate oracle sequence triggers, write some
> service
> on app engine that returns next number in sequence and every body else
> calls
> this service.
>
>
> On Dec 29, 6:30 am, Nichole <[email protected]> wrote:
> > Hi MG,
> >
> >    Sharded counters help solve the concurrent write contention for an
> > entity.
> > Time (to the accuracy of milliseconds) helps to provide a one way
> > arrow towards a unique value.
> > Each request itself could be associated with an identity (this is up
> > to you, perhaps time in the request header).
> > The combination of all 3 may lead to a guaranteed unique number.
> >
> > Cheers,
> >     Nichole
> > (p.s. If you do use sharded counters in your approach, you can
> > configure the datastore
> > read consistency to be strong:
> http://code.google.com/appengine/docs/java/datastore/usingjdo.html)
> >
> > On Dec 28, 8:33 pm, MG <[email protected]> wrote:
> >
> >
> >
> >
> >
> >
> >
> > > Yes, keys are unique, but they are strings, and quite long (20+
> > > characters, from what I've seen). I do need unique and "growing"
> > > numeric counter.
> >
> > > On Dec 28, 11:20 pm, nischalshetty <[email protected]> wrote:
> >
> > > > Have a look at the Datastore "Key" thingy. The keys generated are
> > > > unique across the system IMO. Not sure though but that's what I
> > > > remember reading somewhere.
> >
> > > > -N
> >
> > > > On Dec 29, 7:43 am, MG <[email protected]> wrote:
> >
> > > > > Hello!
> >
> > > > > I need to create a global atomic counter (64-bit) in my AppEngine/J
> > > > > app. Like
> >
> > > > > long count = MyCounter.increment()
> >
> > > > > that will 100% guarantee that count will never ever be the same for
> > > > > two different requests, and that I will be able to increment it
> > > > > several million times/day initially, and much more if/when traffic
> > > > > increases. I do not really care if it skips a number or two
> > > > > occasionally: I can live with it returning a value larger than the
> > > > > actual number of calls, but I do need absolute uniqueness and
> > > > > reasonably linear growth (i.e. is two consecutive calls from a
> client
> > > > > should result in ascending counter values).
> >
> > > > > Is this possible to do with Google AppEngine? Sharded counters can
> > > > > ensure consistent counting, but not unique counts; memcache
> counters
> > > > > can ensure unique increments, but they are perishable and thus
> > > > > difficult (impossible?) to properly synchronize with persistent
> > > > > storage. Using one entity to read-update in a transaction will not
> > > > > scale...
> >
> > > > > Thanks,
> > > > > MG
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine for Java" group.
> To post to this group, send email to
> [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-appengine-java%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-appengine-java?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" 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-java?hl=en.

Reply via email to