user93796
user93796

Reputation: 18379

is Google appengine single threaded ?(java)

My question is "is Google appengine single threaded? .Now when i ask that i know that i cannot start my own threads by using threading in java .But we can start threads using backend.

I am concerned about threading with request to how requests are handled.I read someonewhere that in appengine each request is queued and then served one by one.And i can configure the max time for which a request can be queued.If time to server request exceeds max time then new instance is created.

So what if i want to use single instance (free quota).

If i get multiple requests as r1 , r2 ,r3,r4 (in this order).Then will each of the requests be served one after other (in case of single instance)?

If i create multiple instances when the load increases and new instance is created dynamically will the data that is present in main memory of instance one will it be cloned to instance too?

Will the data in 2 instances in synch all the time?

Upvotes: 0

Views: 585

Answers (2)

Peter McKenzie
Peter McKenzie

Reputation: 741

Agree with what Nick said, but also want to point out that this statement: "Now when i ask that i know that i cannot start my own threads by using threading in java"

is no longer true. For more details, see the section about threads here: https://developers.google.com/appengine/docs/java/runtime#The_Sandbox

So, in summary, App Engine is multi-threaded in a couple of ways:
- requests can be handled concurrently by a single instance using a thread per request
- a single request may explicitly start additional threads

Upvotes: 3

Nick Johnson
Nick Johnson

Reputation: 101149

As stated in the docs, you can enable concurrent requests on your Java app, in which case multiple threads will be spawned, each of which handles requests independently.

Instances are not cloned off already running instances, nor are they synchronized in any way - you are expected to write your code in a manner that doesn't depend on specific mutable instance state.

Upvotes: 1

Related Questions