App Engine调度程序何时使用新线程与新实例? [英] When does the App Engine scheduler use a new thread vs. a new instance?

查看:80
本文介绍了App Engine调度程序何时使用新线程与新实例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我在 app.yaml 文件中设置 threadsafe:true ,那么当新的实例将被创建来为请求提供服务,而不是在现有实例上创建新线程?



如果我有一个应用程序对每个应用程序执行一些计算密集请求,多线程给我买东西吗?换句话说,实例是一个多核实例还是一个单核?

或者,当现有线程在IO上等待时,新线程是否只会启动?

解决方案

以下是一组规则,用于确定给定实例是否可以接受新请求:

 如果处理超过N个并发请求(今天N = 10):false 
超过软存储限制的elif:false
elif超过实例类CPU限制:false
elif热身:false
else true

以下总CPU /内核限制当前适用于每个实例类:

 类1:600MHz 1个核心
CLASS 2:1.2GHz 1核心
CLASS 4:2.4GHz 1核心
CLASS 8:4.8GHz 2核心

因此,只有一个 B8 实例最多可并行处理多达2个CPU绑定请求。



设置 threadsafe:true (Python )或< threadsafe> true< / threadsafe> (Java) 8不允许在单个实例上并行处理多个CPU绑定请求。



如果您没有完全限定CPU或执行I / O,则Python并且Java运行时将产生新线程来处理新请求,最多10个并发请求使用 threadsafe:true



另请注意即使Go运行时是单线程的,它也支持并发请求:
它将在每个请求中产生1个goroutine,并在执行I / O时在goroutine之间产生控制。


If I set threadsafe: true in my app.yaml file, what are the rules that govern when a new instance will be created to serve a request, versus when a new thread will be created on an existing instance?

If I have an app which performs something computationally intensive on each request, does multi-threading buy me anything? In other words, is an instance a multi-core instance or a single core?

Or, are new threads only spun up when existing threads are waiting on IO?

解决方案

The following set of rules are currently used to determine if a given instance can accept a new request:

if processing more than N concurrent requests (today N=10): false
elif exceeding the soft memory limit: false
elif exceeding the instance class CPU limit: false
elif warming up: false
else true

The following of total CPU/core limits currently apply to each instance classes:

CLASS 1: 600MHz 1 core
CLASS 2: 1.2GHz 1 core
CLASS 4: 2.4GHz 1 core
CLASS 8: 4.8GHz 2 core

So only a B8 instance can process up to 2 fully CPU bound requests in parallel.

Setting threadsafe: true (Python) or <threadsafe>true</threadsafe> (Java) for instances classes < 8 would not allow more than one CPU bound requests to be processed in parallel on a single instance.

If you are not fully CPU bound or doing I/O, the Python and Java runtime will spawn new threads for handling new request up to 10 concurrent requests with threadsafe: true

Also note that even though the Go runtime is single threaded, it does support concurrent requests: It will spawn 1 goroutine per requests and yield control between goroutines while they are performing I/O.

这篇关于App Engine调度程序何时使用新线程与新实例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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