Google App Engine reset memcache statistics - google-app-engine

I've flushed memcache using flush_all() and by hitting the Flush Cache button in my deployed app Memcache Viewer, however the statistics are not resetting. Is there anyway to reset the statistics?

Other than those two options, no. If you believe that this is a bug (or feature request), please file one in the issue tracker.

Related

Is memcache for GAE client-side or server-side?

I'm building an app which should also work offline (of course with stale data).
So I thought if the user is online, I'll query the datastore to fetch fresh data, and if he's online, I'll store the recently fetched data in memcache. But then I thought memcache in GAE is implemented on the server-side most probably. Am I right?
Edit: I made my browser work offline.Reloaded the page, nothing happened and nothing appeared in my logs. But then I disabled my laptop's WiFi and somehow it started working. I got GET 200 requests in my log. Does this mean memcache is client-side?
I got the answer. Memcache is server-side caching. It worked when I disabled the wifi on my laptop because my laptop ran the dev server and also hosted the memcache. When my browser was offline, it couldn't send out requests to anybody so it failed.

Is Google App Engine memcache secure?

My application checks user authentication and authorization on every request and I am thinking of moving the authentication and authorization data from datastore to memcache.
Is memcache suitable for this usecase? Is it secure or I should not do it?
Yes, Memcache is secure. If you save important content to Memcache you have to back it up on datastore because it can be evicted at any moment. There are datastore APIs on Python (NDB) and Java (Objectify) that manage the cache for you automatically, but I'm not sure about Go.
If your users log in with their Google Account you can use the Users API1.
Yes, memcache is secure as the marked answer says (even shared memcache).
However as one comment says, you should really not reinvent appengine sessions, and instead use them. Google for "appengine go sessions" and you will find resources about it. The first link in that search:
https://godoc.org/code.google.com/p/sadbox/appengine/sessions
shows you how to use them in Go.
Besides handling the memcache and datastore implementation, it has additional features like configurable expiration.

What is the recommended way to temporarily disable my Google App Engine app so that I can perform schema migration?

I'd like to disable user access to my app so that I can perform a schema migration. I've looked into a few possibilities and found possible shortcomings:
Disable datastore writes - I'd rather just bring my whole application down so that people do not see any errors, etc. Also, I assume disabling writes will prevent me from performing the migration.
Disable the application - It's not clear to me that this would disable it only for my users, leaving me unable to perform the migration. I am also unsure of the disable/enable turnaround time.
Redirect my domain name to a temporary page - my app would still be accessible on appspot.com
Upload a new version of my app that doesn't respond to requests other than to direct to a "temporarily down" page.
Any suggestions?
Suggestion number 4 seems like probably the best way to do this. Some frameworks have a "maintenance mode" in which all incoming requests would be redirected to a page indicating the site is down due to maintenance. If your framework doesn't support such a mode, you can just upload a new version of your app (maybe call the version maintenance) and switch to that as your new default version. This version could be an empty app in which all incoming requests are turned to a "maintenance page" indicating the site is down for maintenance. Then manually go to the version of your app with the migration code and execute it (http://<version>.<appname>.appspot.com). Switch your apps default version to the new version with the new schema when you're done with the migration.
Explanation of your other ideas
Disabling writes would prevent even you from making writes on the application. I believe this was more meant for migrating from one app to another or other applications of "freezing" the datastore.
Disable the application would bring the app down entirely
Redirecting your domain would inflict a DNS lag on your migration, something that can take 48 hours to fully propagate each way (switching to the temporary page, then switching back to the new version)
As aforementioned, IMHO this would be the best way to do it.
Is it not possible to use both schema's, and use a new version of your app to migrate, which only uses the new schema. In this way you can always fall back to your old version.
By the way. Because the datastore is schema-less, It was always possible for me to change the "schema", without bringing the app down.
Go to GCP > App engine > Settings > Disable application.
You can sure enable your application ay any time.
If you disable this app, a few things will happen:
The app will stop serving
All data and state will be saved
Billing charges will still incur when applicable
Your task queues will continue to run. They can be paused in the Cloud Tasks UI

Simulating Google app engine maintenance period in development environment

During scheduled maintenance period outages, the high replication datastore will work normally, but memcache will not be available.
Is there a way this scenario can be simulated in local development environment?
More specifically, can we run dev_appserver.py with memcache disabled to test the maintenance period behavior?
As of now, I go to development console and flush out the memcache after every request, to get a rough idea of how the app behaves during server maintenance. I am hoping there must be some better way to test this scenario.
Create an api post call hook that will return None for memcache get requests. Refer to the official docs for creating an api post call hook.

AppEngine, clearing memcache from the control panel

I am working on a project on Google AppEngine, where I am using the datastore and memcache. For testing purposes, I go to the control panel, change and save of some values of some saved entities in the datastore. However, since they're already in memcache, I assume, the changes don't reflect on the application.
Using Admin/control panel, is there a way to enforce reloading these entities into memcache from the datastore, or at least to clear memcache?
Thank you,
Hazem
With the release of SDK 1.6.4 today a memcache page has been added to the production admin dashboard. It has a button that lets you flush memcache (as well as other features).
That does not solve the problem of automatically managing the memcache version of your entities. For that you could look into the NDB library (new standard library in SDK 1.6.4) which automatically caches your entities as you use them and invalidates the cache as necessary. It has lots of other features as well. I have not used it yet but it certainly sounds good: http://code.google.com/appengine/docs/python/ndb/
UPDATED March 27 now that SDK 1.6.4 has gone final and I can confirm it contains the memcache control panel.
As an alternative: I believe you could use Remote API, fire up a shell and execute e.g. memcache.flush_all()
no there isnt.
make a handler that does that for you and when you need to flush memcache you can simply hit that url

Resources