简体   繁体   English

google app引擎:没有用户数据的新实例

[英]google app engine : new instance with no user data

My google engine java app looses all user data when user request is redirected to the new instance : 当用户请求重定向到新实例时,我的Google引擎Java应用会释放所有用户数据:

" This request caused a new process to be started for your application, and thus caused your application code to be loaded for the first time. This request may thus take longer and use more CPU than a typical request for your application. " 此请求导致为您的应用程序启动一个新进程,从而导致您的应用程序代码首次被加载。因此,与典型的应用程序请求相比,此请求可能花费更长的时间并使用更多的CPU。

as it is quite inconvenient behaviour i tried to set-up one resident instance so i setted "Idle Instances" to 1-1 but this does not solve my problem i am getting one resident instance and always there`s new (dynamic) instance created which serves some requests... (this guy have the same problem : Why GAE launched a second instance with Max Idle Instances set to 1 ) 因为这是非常不方便的行为,所以我尝试设置一个常驻实例,因此我将“空闲实例”设置为1-1,但这不能解决我的问题,因为我正在获取一个常驻实例,并且总是有一个新的(动态)实例创建它可以处理一些请求...(这个人有同样的问题: 为什么GAE启动了第二个实例,并将“最大空闲实例数”设置为1

I dont want to use dynamic instances at all ( my app have always low load, not many users ). 我根本不想使用动态实例( 我的应用程序始终负载低,用户不多 )。 I need to serve only one resident instance to the users. 我只需要为用户提供一个常驻实例。 Is that possible to set in GAE ? 是否可以在GAE中设置? If not , is there any convinient and reliable way how to save data between pages (eg store them in datastore ?). 如果不是,是否有任何便捷, 可靠的方法来保存页面之间的数据(例如,将它们存储在数据存储区中?)。 I am passing a lot of POST parameters between pages. 我在页面之间传递了许多POST参数。

Google App Engine is a cloud platform. Google App Engine是一个云平台。 Your app design will not be able to get all benefits of cloud platform without dynamic instances. 没有动态实例,您的应用程序设计将无法获得云平台的所有优势。

To solve your data transfer problem you can use one of the following methods: 要解决数据传输问题,可以使用以下方法之一:

  1. Use standard Java EE session object. 使用标准的Java EE会话对象。 Session is stored in datastore so you will not loose it. 会话存储在数据存储区中,因此您不会丢失它。 But you should not forget that your session object should be SERIALIZABLE and LESS than 1MB because of DataStore entity size limit. 但是您不要忘记,由于DataStore实体的大小限制,您的会话对象应该是SERIALIZABLE,并且小于1MB。

  2. Store data in DataStore manually and transfer Entity ID between pages. 手动将数据存储在DataStore中,并在页面之间传输实体ID。 Same 1MB Entity size limit applies. 相同的1MB实体大小限制适用。

  3. Use BlobStore or Cloud Storage to store your data as files and transfer file idetifier between page. 使用BlobStore或Cloud Storage将数据存储为文件,并在页面之间传输文件标识符。 It will help to eliminate 1Mb limit. 这将有助于消除1Mb的限制。

Any of this methods allows to persists data between request, but has its own limitations. 任何一种方法都允许在请求之间持久化数据,但是有其自身的局限性。 You need to provide details of your requirements to have a clear answer. 您需要提供要求的详细信息才能获得清晰的答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM