Memcache System - Keys getting dropped frequently - google-app-engine

We currently have our application hosted in Google App Engine. Billing is enabled to that application. This application is still in beta that we are using for testing purpose. We have a logic of serving data from the Memcache if present, if not then we get the data from the datastore and update the memcache and serve the data. We are encountering strange behaviour related to Memcache. The data related to some keys in Memcache is getting dropped after few minutes after being set. We tried setting expiration time for the keys in the memcache, even that does not seem to work. Since the data is getting dropped from the memcache the data is again from the datastore which is increasing the billing for our application.
Currently nearly 80% of the billing is related to datastore read. The datastore read is high as the memcache is not working efficiently as it should be. Any insight why we are facing this issue would be really helpful.
Just an FYI, we are having around 75000 keys in the memcache with total size of 100 MB data. Our structure demands keeping such large number of keys in memcache, which I think should not be an issue.
Our application is being by 10 users and the billing amount per day is coming to around $40.
Thanks,
Krish

Unfortunately memcache will evict keys as and when it requires. Setting the time to expire only means the item will be in memcache for up to the expiry time.
Take a look at the docs regarding eviction.
Also, take a look at this for some more insight into ways around memcache issues.
Regarding your data structure, perhaps you could post a new question and we can see if others have advice for you.

Related

AppEngine: Memcache without any instance

My problem is my memcache resets every night. What could the be problem?
I have a very simple low-traffic web site on Google App Engine in Java. I do not have any instances left at night because of lack of traffic. If there is no instance, does it mean that memcache clears all its data?
Memcache is not persistent and can be evicted by memory pressure. Share memcache is shared with other apps. You can buy dedicated memcache for reserved amount. What you described does not seem to be a problem at all.
One important question is, what is the timeout that you set?

How long does the GAE "best effort" memcache usually last?

Google is extremely vague about when memcache entries might expire in the shared memcache. This is completely understandable as it is free and shared but does anybody have any practical guidance for how long my entries will probably exist before they are removed from the shared cache? 1 hour? 1 day? 1 week? 1 month?
I plan to store some session tokens and am trying to figure out how long the sessions can be revisited.
The memcache can trashed all your datas at any time. You can't really trust the expiration time.
According to Google, your application must work fine even without or with memcache.
The memcache is just a plus to avoid to make a lot of datastore queries and manage correctly your quotas.
And for you, the memcache is not the place to store sessions tokens.
If you are using Python, you can user webapp2 sessions. It works wonderful with AppEngine.
I've honestly seen memcache last for a day, and as little as an hour.... And I never actively monitored memcache, so I wouldn't be surprised if you have way bigger or smaller timeframes in your memcache.
It's really hard to say, since (I guess) it depends on internal usage of the computer used for your instance and how much resources are needed by other computers around.
Unfortunately there is no real answer yo this question besides : code defensively, always check memcache and then if you don't find your data in memcache, you grab it from your permanent data (datastore I guess? or cloud storage) and then push it back to memcache for your next use

google cloud storage performance characteristics (latency / request response time)

I'm considering building an app on App Engine, and I'm trying to decide if I should store data in the datastore or on google cloud storage.
Each object is going to be typically no more than around a kilobyte, perhaps a few kilobytes at most (and often less). It won't change too often.
I could have the client directly access the data, but though I might live without there would be some benefit to the app engine app accessing the data and using it as part of serving a response.
What are the performance characteristics of google cloud storage? How quickly do requests come back? I was able to find a status dashboard for the datastore which indicates that they are usually reasonably quick at handling requests but I've had trouble getting guidance on how fast GCS is.
Under the most recent price reductions, it seems like the datastore might actually be cheaper for my use case of relatively small chunks of data ($0.06/100,000 requests vs $0.01/10,000 class b operations). Am I interpreting that correctly?
This thread might give you some insights. Back in september 2013 I had about 200-250ms on average for "blank" sequential inserts. You can get a great speedup if you combine your requests. You can insert up to 500 entities in a single request. Which takes roughly 500ms-900ms if I remember correctly.

Dedicated memcache vs shared memcache (python, google appengine)

So basically, I am trying to decide if I should go for dedicated memcache.
My scenario is as follows:
I am working on an application that provides real time analysis for some public data.
I am going to maintain a total 15kb key/value memcache (20 keys, variable values)
Meanwhile values are constantly changing (total keys/values around 20 updates every 3 seconds)
Hits to the website will perform request for these keys (also around a request per 3 seconds)
I am assuming that 10000 users hit the website immediately, this will produce about 20 * 10000 requests each 3 seconds.
Considering the size of the memcache (relatively small), but also the number of requests produced about 7000/second (memcache key/value access), would dedicated memcache be more of "risk averse" deal for this situation.
Thanks,
The cached data seems crucial to the correct operation of your web application. If you lost data it might be a disservice to thousands of users! Hopefully your app also periodically persists the cached data and automatically recovers from cache erasure.
Although the size of the data is small, shared memcache still has more risk than dedicated memcache of evicting some or all of the data at unpredictable times. The design must also deal correctly with partial data loss. Not only your memory pressure but also that from other applications and cloud operational factors are more likely to result in AppEngine discarding shared cache.
With this data size you will not get any benefits from using the dedicated memcache.
The rate at which you access memcache does is not relevant for this decision.

How do you reset the Google AppEngine Datastore Quota Exceeded condition?

If you have a application that exceeds that Datastore quota of 1 Gig (Master/Slave configuration) How do you clear the condition?
I have an application called "parking-helper" and it has a Total Stored Data 100% used message.
But I've deleted 99% of the data (a few days ago) cleared the indexes,
vacuumed the indexes and cleared the memcache and also waited for at
least 2 reset cycles and yet the datastore still says 100% used.
The datastore admin shows that the datastore does not add up to more than a
meg.
I know that memcache and indexes count also. It would be nice to see the sizes of these in the Datastore Admin view (but currently we cannot see these values). But I believe I cleared them also.
How can I reset this application without the drastic measure of deleting and re-creating which means I'd have to pick another application id and re-create all the other data.
Thanks,
Ralph
It's usually just a matter of waiting. And it looks like your quota is under 100% now.

Resources