在Google AppEngine做Session 本身并不是一个复杂的问题,可以基于Memcached API来做,也可以基于DataStore来做,为何让我郁闷?
先看看DataStore 这低下的性能,一般读取也要100ms cpu时间,如果有些写入可能大于200ms cpu时间,这个是以前用python做程序测试的,Java的还没有试过。如果以后访问量大了,有准备付费的打算就惨了。
我们再来看看Memcached吧:
[quote]Memcache may be useful for other temporary values. However, when considering whether to store a value solely in the memcache and not backed by other persistent storage, be sure that your application behaves acceptably when the value is suddenly not available. [color=red]Values can expire from the memcache at any time[/color], and may be expired prior to the expiration deadline set for the value. For example, if the sudden absence of a user's session data would cause the session to malfunction, that data should probably be stored in the datastore in addition to the memcache.[/quote]
Memcached来存储Session 也是在不放心,当然如果你的网站没有用户机制、状态倒是不用关心这个问题。
没办法在网站应用中可以采用Memcached + DataStore配合的方式,Memcached的数据定时存储至DataStore,这种做法有一定的适用性,但是还是可能造成Session数据丢失或者错误的问题,只是几率大大降低了,而且又能提高不少性能,不过这样做还是有些变扭。
先看看DataStore 这低下的性能,一般读取也要100ms cpu时间,如果有些写入可能大于200ms cpu时间,这个是以前用python做程序测试的,Java的还没有试过。如果以后访问量大了,有准备付费的打算就惨了。
我们再来看看Memcached吧:
[quote]Memcache may be useful for other temporary values. However, when considering whether to store a value solely in the memcache and not backed by other persistent storage, be sure that your application behaves acceptably when the value is suddenly not available. [color=red]Values can expire from the memcache at any time[/color], and may be expired prior to the expiration deadline set for the value. For example, if the sudden absence of a user's session data would cause the session to malfunction, that data should probably be stored in the datastore in addition to the memcache.[/quote]
Memcached来存储Session 也是在不放心,当然如果你的网站没有用户机制、状态倒是不用关心这个问题。
没办法在网站应用中可以采用Memcached + DataStore配合的方式,Memcached的数据定时存储至DataStore,这种做法有一定的适用性,但是还是可能造成Session数据丢失或者错误的问题,只是几率大大降低了,而且又能提高不少性能,不过这样做还是有些变扭。