googlecloudplatform / appengine-sharded-counters-python Goto Github PK
View Code? Open in Web Editor NEWGoogle App Engine Sharded Counters Sample Application in Python
License: Apache License 2.0
Google App Engine Sharded Counters Sample Application in Python
License: Apache License 2.0
If a GeneralShardedCounter is accessed often enough, the memcache representation will get out of sync.
Running 100-1000 parallel operations incrementing the counter (and occasionally reading its value) results in memcache reaching a level between 0.1% and 1% higher than the actual sharded counter value. I've tested this numerous times on 10,000 operations; the counter reaches 10,000 as the operations (task queue tasks) are spawned, but the count of operations finished (each operation increments the counter on exit) reaches anywhere from 10,001 to 10,100 or thereabout.
If the memcache value expires, and any number of operations has just incremented a shard but not yet incremented memcache, a call to get_count
will count the just-incremented shards, store the value in memcache, and then memcache will be incremented, leaving those operations counted twice, with a resulting higher count in memcache.
My workaround is to invalidate the cache if I want to get a more "accurate" number, but I think the memcache results here should be taken as no more than a hint.
This sample is not runnable due to a missing file:
counter.html
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.