Should I use sessions in Google App Engine?

感情迁移 提交于 2021-02-18 18:47:16

问题


I have just learned from this questions that Google app Engine now supports session. I would like to be able to use them but am not sure whether I should just because I can. Thanks to scalability issues.

My questions are really,

Where would I store the session information? In the data store or would this take to long? And surely far to costly?

What about the mem cache? I have only known of GAE for a few days and am still reading. Is the Mem cache considered to be fast/scalable and does it cost?

What is the best practice for scalability with sessions?

Thanks a lot


回答1:


You don't really have a choice. Appengine handles session persistence and fast access for you, transparently.

Quote from the official documentation:

App Engine includes an implementation of sessions, using the servlet session interface. The implementation stores session data in the App Engine datastore for persistence, and also uses memcache for speed.




回答2:


Where would I store the session information? In the data store or would this take to long? And surely far to costly?

If you enable Sessions on GAE it'll automatically store session info in the memcache and back it up in the datastore.

What about the mem cache? I have only known of GAE for a few days and am still reading. Is the Mem cache considered to be fast/scalable and does it cost?

The memcache queries have no cost, and are quite faster than datastore queries. The downside is that memecache is volatile and might be flushed at any time. That's why GAE backs up session info on the datastore as well.

What is the best practice for scalability with sessions?

Well there are many schools of thought on that, but ideally your app should be "stateless" in order to achieve maximum "scalability" on GAE, so you should be able to process each request without any additional information, but that's usually really hard to get.

Having shared spaces between your instances (like memcahce/datastore/blobsotre) practically eliminate all issues related to having a "distributed and dynamic" setup, but philosophically you should attempt to achieve an app as stateless as possible.



来源:https://stackoverflow.com/questions/24349328/should-i-use-sessions-in-google-app-engine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!