Why does Google App Engine support a single thread of execution only?

后端 未结 6 1863
甜味超标
甜味超标 2020-12-09 11:03

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 d

6条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-09 12:03

    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.

提交回复
热议问题