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:
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.