简体   繁体   English

是Google appengine单线程的吗?(java)

[英]is Google appengine single threaded ?(java)

My question is "is Google appengine single threaded? .Now when i ask that i know that i cannot start my own threads by using threading in java .But we can start threads using backend. 我的问题是“ Google appengine是单线程的吗?现在当我问我知道我无法通过使用Java中的线程来启动自己的线程时,但是我们可以使用后端来启动线程。

I am concerned about threading with request to how requests are handled.I read someonewhere that in appengine each request is queued and then served one by one.And i can configure the max time for which a request can be queued.If time to server request exceeds max time then new instance is created. 我担心与请求一起处理请求的方式。我在appengine中读取了某个地方的消息,每个请求都排队,然后一个接一个地处理。我可以配置请求可以排队的最长时间。超过最大时间,则创建新实例。

So what if i want to use single instance (free quota). 那如果我想使用单个实例(免费配额)呢?

If i get multiple requests as r1 , r2 ,r3,r4 (in this order).Then will each of the requests be served one after other (in case of single instance)? 如果我收到多个请求r1,r2,r3,r4(按此顺序),那么每个请求将一个接一个地处理(如果是单个实例)?

If i create multiple instances when the load increases and new instance is created dynamically will the data that is present in main memory of instance one will it be cloned to instance too? 如果我在负载增加时创建了多个实例,并且动态创建了新实例,那么实例一的主内存中存在的数据也会被克隆到实例中吗?

Will the data in 2 instances in synch all the time? 2个实例中的数据是否会一直同步?

Agree with what Nick said, but also want to point out that this statement: "Now when i ask that i know that i cannot start my own threads by using threading in java" 同意尼克所说的话,但也要指出这一说法:“现在,当我问我知道我无法通过使用Java中的线程来启动自己的线程时”

is no longer true. 不再是真的。 For more details, see the section about threads here: https://developers.google.com/appengine/docs/java/runtime#The_Sandbox 有关更多详细信息,请参见以下有关线程的部分: https : //developers.google.com/appengine/docs/java/runtime#The_Sandbox

So, in summary, App Engine is multi-threaded in a couple of ways: 因此,总而言之,App Engine通过以下两种方式是多线程的:
- requests can be handled concurrently by a single instance using a thread per request -单个实例可以使用每个请求的线程并发处理请求
- a single request may explicitly start additional threads -单个请求可以显式启动其他线程

As stated in the docs , you can enable concurrent requests on your Java app, in which case multiple threads will be spawned, each of which handles requests independently. docs所述 ,您可以在Java应用程序上启用并发请求,在这种情况下,将产生多个线程,每个线程独立处理请求。

Instances are not cloned off already running instances, nor are they synchronized in any way - you are expected to write your code in a manner that doesn't depend on specific mutable instance state. 实例不会从已经运行的实例中克隆出来,也不会以任何方式进行同步-您应该以不依赖于特定可变实例状态的方式编写代码。

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

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