Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9129767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:49:24+00:00 2026-06-17T07:49:24+00:00

I need to cache some costly queries(5sec). I recently came to know about dogpile

  • 0

I need to cache some costly queries(5sec). I recently came to know about dogpile affect when using memcache. One solution is using locks on cache key-value pair to prevent this effect. Since GAE memcached doesn’t support locks on memcached key-values, what is the best practice to prevent dogpile effect?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T07:49:26+00:00Added an answer on June 17, 2026 at 7:49 am

    It depends on what your app is doing, but here are three approaches that can be useful (none is perfect for all scenarios, they each have downsides):

    If you can respond to the request with something like ‘wait a bit and try again’ then setting a flag that represents that into memcache on a miss, before you spend the time re-processing the real value could help (there will still be the possibility of a race between the get and the first set, but it will be much shorter than waiting for the query to be done):

    value = memcache.get(key)
    if value is None:
      memcache.set(key, 'recalculating')
      // do the slow thing
      memcache.set(key, actual_result)
    
    return value
    

    Alternatively, if you’re setting a lifetime on your cached results, but could cope with clients receiving slightly stale data, then as well as caching your value with a timeout and a key, you cache a copy with no timeout and a different key, then on miss use this copy to re-populate the cache while you re-process a fresh value (again, still the chance of a race between the get/set, and also it’s possible the copy will be evicted.):

    value = memcache.get(key)
    if value is None:
      memcache.set(key, cache.get(key+'copy'))
      // do the slow thing
      memcache.set(key, actual_result, 30)
      memcache.set(key+'copy', actual_result)
    
    return value
    

    The third is simpler, simply have a backend constantly doing your query and have it update the cache, so that frontend requests are less likely to have to do it. This does mean, though, that the queries are being done regardless of the values being used by anyone.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using WebView in my application and I need to pre-cache some webpages for
I need to cache some application specific data using Symfony 2's caching system so
I'm using AQuery to help cache some images. I know for fact the images
For managing some cache, I need a sort of Hashtable with the ability to
I need a cache that responds to memory pressure like the one build-into ASP.NET.
I need to cache some objects with fairly heavy creation times, and I need
Here I need to cache some entites, for example, a Page Tree in a
I'm getting some data in my WCF rest service. I need to cache this
I need to load some data from DB to Cache on server start up.And
I have an app that will need to cache some images. I have read

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.