Coder Social home page Coder Social logo

Comments (8)

jiayliu avatar jiayliu commented on May 16, 2024

It seems NDB datastore is exactly what we need: https://cloud.google.com/appengine/docs/python/ndb/
"NDB uses Memcache as a cache service for "hot spots" in the data. If the application reads some entities often, NDB can read them quickly from cache."

from samples.

jiayliu avatar jiayliu commented on May 16, 2024

Hmm, I changed the code to use NDB datastore and uploaded it to https://9-dot-apprtc.appspot.com. But the setup time does not seem to improve based on both client side log and server side log. (scratching head)

from samples.

jiayliu avatar jiayliu commented on May 16, 2024

After more investigation I found most of the time for loading the first GET is spent in getting the lock. Acquiring the lock typically takes 100-200ms, but may take as long as >1s in some cases.
Querying the datastore takes 10-20ms for DB, 20-40 for NDB.
Writing to the datastore takes 30-40ms for DB and NDB.

from samples.

jiayliu avatar jiayliu commented on May 16, 2024

BTW, we have a decent 80-90% memcache hit rate, so I can confirm memcache is indeed used in NDB.

from samples.

jiayliu avatar jiayliu commented on May 16, 2024

Our code does not release the lock when calling channel.send_message, which is very slow.
Moving it out of the lock can save ~60ms.

from samples.

jiayliu avatar jiayliu commented on May 16, 2024

Hmm, now I don't think using memcache or NDB will help us much.

NDB makes reading fast when it reads from cache. But apprtc usually does read + write to add a user, where the write will invalidate the cache, so the next read for the second user will load from datastore.
Using appstats, I see NDB almost doubles the RPC calls to add a user and takes more time than DB.

If we write our own memcache logic, we can make the read for the second user faster (20ms vs. <10ms). But the writing part is not any better, since we need to write to both memcache and datastore, and we cannot return the request before the datastore write is completed using async functions, because that will abort the async write.

Similar to adding a message to the memcache/datastore.

from samples.

juberti avatar juberti commented on May 16, 2024

Let's discuss when I get back to Kirkland. Each candidate should be fast since that is only read from memcache, right?

from samples.

jiayliu avatar jiayliu commented on May 16, 2024

We shouldn't do one datastore/memcache read per candidate, but only one
read in total when the second user joins.
If candidate is sent to GAE after the second user joins, GAE will send it
to GCE.

On Fri, Nov 14, 2014 at 4:36 AM, Justin Uberti [email protected]
wrote:

Let's discuss when I get back to Kirkland. Each candidate should be fast
since that is only read from memcache, right?


Reply to this email directly or view it on GitHub
#163 (comment).

-jiayl

from samples.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.