On Sun, Aug 21, 2011 at 12:49 AM, Jeff Schnitzer <j...@infohazard.org> wrote:
>
> Just to add a few bits of complexity that I didn't mention the first time:
>
>  * The UI must display the # of units left

If you're selling up to 1000/s is this a meaningful number? By the
time the user has read the message it will be wrong.

You could estimate the global sales velocity by recording sales by a
front-end instance in local memory and periodically flushing to
memcache. Given the global total from memcache you could give messages
like: half gone; less than 5000 left; estimate all sold in 10 mins.


Here's another way to sell widgets:

In Phase One, a front-end instance starts up and deducts 1000 widgets
from a datastore counter. It may sell widgets with IDs 1-1000 from
instance memory. It is selling widget 42, not any old widget. When it
sells out, it deducts another 1000 widgets from the global datastore
counter, widgets with IDs 10,001-11,000 say.

Contention on the datastore counter is reduced 1000-fold and
front-ends may sell without contention, and without overselling, as
long as they continue to grab batches of 1000.

A front-end may crash or be recycled without selling all 1000 widgets.
You may be happy selling 80%, 95%, 99.9%, depending.

However, when a front-end instance grabs the last 1000 widgets from
the global datastore counter you could enter Phase Two:

Sweep the sales looking for gaps in your blocks of 1000. You could
have your front-ends record when they lease 1000 IDs, when they sell
all 1000 IDs, and checkpoint every N mins if sales die down before
they sell out. Consolidate all the gaps into a new range from 0-N and
restart the sale. Start speculatively sweeping once you've sold 90% of
stock so that there is no time gap between a phase one and two sale.
Add phases until 99.N% sold.

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to