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!
Single threaded processes contain the execution of instructions in a single sequence. In other words, one command is processes at a time. The opposite of single threaded processes are multithreaded processes. These processes allow the execution of multiple parts of a program at the same time.
A single threaded application includes only one thread which responsible for executing every task and method, one after the other, and the controller doesn't move to the next task until the previous one ends. More to that, the main thread doesn't exist until all the tasks are done executing.
Browsers aren't single threaded, but your script runs in a single runloop.
In General: Multi threading may improve throughput of the application by using more CPU power. it depends on a lot of factors. If not, the performance depends on above factors and throughput will vary between single threaded application and multi-threading application.
Google app engine is one of the most popular cloud products on the web. It is extensive and integrates IaaS, SaaS, and PaaS comprehensively. It also incorporates testing, building, and deployment of applications within cloud environment, supporting innumerous users over the globe.
With a 99.9+% uptime, Google App Engine is very reliable (as are all Google products). Google App Engine has its own version of SQL called GQL which is inferior to straight SQL. This means a steeper learning curve. The documentation on best practices for the platform is lacking. No support for C# is a frustrating limitation.
I use Google App Engine to program in Python for data collection and data mining. This is solely being used for engineering and … Apps get automatically scaled based on the users, more users more instances and app runs smoothly. For beginners, there is a learning curve that can be reduced by decluttering the functionalities.
That is why GAE (Google App Engine) is ideal for SMEs and entrepreneurs. With the platform, every owner can enhance and scale their apps without any performance compromise. GAE allows you to use PHP, Python, or Go for writing any app’s engine application. It also allows you to test and deploy an application locally with the SDK tools.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With