GAE是无国籍的吗?有什么影响? [英] Is GAE Stateless? What are the implications?

查看:102
本文介绍了GAE是无国籍的吗?有什么影响?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

曾经有人告诉我GAE是无国籍的.我大致了解无状态的概念,但可以在概念上将其应用于GAE类型系统时使用一些指导.

I was once told that GAE is stateless. I understand the concept of statelessness in general but I could use some guidance in conceptually applying it to a GAE-type-system.

我之所以问这个问题,是因为我开发的一个应用似乎存在干扰问题.也就是说,当两个或更多的人同时使用它时,它会变得混乱. (我将继续进行错误测试,以确认错误仅在同时使用时发生.)我认为,从理论上讲,可以通过两种方式发生这种干扰:A,不正确的GQL查询得到了错误的db记录(我检查过,不行);或b.在服务器级别.我的问题:后者实际上可行吗?当该应用投放服务时,一个用户是否可以通过更改程序中变量的状态来干扰另一个用户?或者,也许这是由无国籍状态阻止的吗?我很困惑,可能遗漏了这个问题. Namaste.

I'm asking this question specifically because I an app I've developed appears to be having an interference problem. That is, when two or more people use it at the same time, it becomes confused. (I am continuing to bugtest to confirm that the error only occurs during simultaneous use.) I perceive that there are two ways such interference could theoretically occur: A, incorrect GQL queries getting the wrong db records(I checked this, nope); or b. at the server level. My question: is the latter actually possible? When the app is serving, can one user interfere with another by, say, changing the state of a variable within the program? Or, perhaps, is this prevented by statelessness? I am confused and may have misstated the question. Namaste.

推荐答案

我认为您在混淆一些术语.首先,您使用什么语言?这是java还是python?

I think you're confusing a few terms. First off, what language are you using? Is this java or python?

告诉您GAE是无国籍"的人不知道他们在说什么,否则您对他们告诉您的内容感到困惑. GAE是一个Web服务器平台,您的应用程序的状态取决于您. HTTP是一种无状态协议(GAE用于构建使用http的Web应用程序),但是您可以绝对打开会话并以这种方式为用户实现有状态性.

The person who told you that GAE is 'stateless' doesn't know what they are talking about, or else you are confused as to what they told you. GAE is a web server platform and the statefulness of your app is up to you. HTTP is a stateless protocol (and GAE is for building web applications which use http) but you can absolutely turn on sessions and achieve statefulness for users that way.

您描述的错误条件是并发之一.您已经在GAE中共享了资源(数据存储区,内存缓存等),并且如果您使用的是高复制数据存储区,那么您最终还将在数据存储区中保持一致性.

The error condition you are describing is one of concurrency. You have shared resources in GAE (the datastore, memcache, etc) and you also have eventual consistency in the datastore if you are using the High-replication datastore.

GAE不保证同一服务器实例将由同一个人处理多个请求,并且默认情况下不存在多线程(无论如何,在Java中,我不确定python).没有多线程,在任何给定时间在任何实例上只有1个人.但是,如果启用多线程,则必须确保代码是线程安全的,否则您可以让2个用户在单个实例上修改变量,但这不是GAE独有的.

GAE does not guarantee that the same server instance will serve multiple requests by the same person, and by default there is no multi-threading (in java anyway, I'm not sure about python). With no multi-threading there will only be 1 person on any instance at any given time. However, if you enable multi-threading you must make sure that your code is thread-safe, or else you can have 2 users modifying a variable on a single instance, but this is not unique to GAE.

您肯定可以让2个用户修改2个不同服务器上的相同数据存储区实体或相同的内存缓存条目,并且您需要通过使用事务等为该情况进行编码.此外,最终的一致性在写入和写入之间可能会有所滞后读取,因此如果您写入数据而另一个用户立即读取该数据,则他们可能不会获得相同的值 背部.

You can definitely have 2 users modifying the same datastore entity on 2 different servers or the same memcache entry and you need to code for that case by using transactions, etc. Also with eventual consistency there can be a lag between a write and a read so if you write data and another user immediately reads it they might not get the same value back.

这篇关于GAE是无国籍的吗?有什么影响?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆