为什么Google App Engine仅支持单个执行线程? [英] Why does Google App Engine support a single thread of execution only?

查看:166
本文介绍了为什么Google App Engine仅支持单个执行线程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人知道为什么Google App Engine只允许部署的应用程式只执行一个执行绪?



我个人认为它与应用程序的可预测性,以便Google可以更可靠地调整其性能。在Google的网站上发布的关于单线程执行的原因似乎没有。



有一个已经是多线程的应用程序,目前部署在虚拟机上

编辑:我已标记下面的答案,因为它的声音非常可能的是,由于水平缩放要求,不允许线程。自然,线程都在同一进程空间内执行,并且GAE可以为您的应用程序运行许多进程,因此很难共享线程。也就是说,我仍然认为每个进程的小线程池将是有用的,可能有助于将应用程序迁移到云。我将要求这是一个功能。感谢您的讨论!

解决方案

Google App Engine中有一种有限的替代线程,称为任务队列:http://code.google.com/appengine/docs/python/taskqueue/



EDIT



http://code.google.com/appengine/docs/java/runtime.html#The_Sandbox


为了允许App Engine在
多个Web服务器上分发
的应用程序请求,并防止
一个应用程序干扰
另一个应用程序,运行在
限制的沙箱环境中。在
这个环境中,应用程序可以
执行代码,存储和查询数据在
App Engine数据存储,使用App
引擎邮件,URL提取和用户
服务,并检查用户的web
请求并准备响应。


像其他人已经指出的,线程不是



Google App Engine中有许多其他限制,强制开发人员创建可扩展的应用程序。我相信任务队列只是这些限制中的另一个,因为与在处理HTTP请求的当前机器上创建线程相反,任务被放入队列,然后可以由其他机器调度并执行。任务队列允许工作以可扩展的方式在机器之间共享和分发。


Does anybody have an idea why Google App Engine permits only a single thread of execution for a deployed application?

I personally believe that it has something to do with the predictability of an application so that Google can size its performance more reliably. There does not appear to be any rationale posted on Google's site regarding single threaded execution hence my question.

Having an application that is already multi-threaded and presently deployed on a VM means that it is difficult for me to move to the cloud given this restriction.

EDIT: I've marked the answer below as it sounds quite plausible that threads are not permitted due to horizontal scaling requirements. Naturally threads all execute within the same process space and, as GAE can run many processes for your application, it would be difficult to share threads. That said, I still think that a small thread pool per process would be useful and might help migrate apps to the cloud. I shall request this as a feature. Thanks for the discussion!

解决方案

There is a limited alternative to spawning threads in Google App Engine called task queues: http://code.google.com/appengine/docs/python/taskqueue/

EDIT

From http://code.google.com/appengine/docs/java/runtime.html#The_Sandbox:

To allow App Engine to distribute requests for applications across multiple web servers, and to prevent one application from interfering with another, the application runs in a restricted "sandbox" environment. In this environment, the application can execute code, store and query data in the App Engine datastore, use the App Engine mail, URL fetch and users services, and examine the user's web request and prepare the response.

Like other people have pointed out, threads are not supported for securities reason to sandbox applications.

There are many other restrictions within Google App Engine that forces developers to create scalable apps. I believe task queues are just another one of these restrictions because, as opposed to creating a thread on the current machine handling the HTTP request, a task is put into a queue which can then be schedule on and executed by other machines. Tasks queues allow work to shared and distributed amongst machines in a scalable manner.

这篇关于为什么Google App Engine仅支持单个执行线程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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