views:

29

answers:

3

Does each JVM instance only use one thread?

eg. if a user makes a request to one JVM instance that will take 5 seconds, then 2 seconds later another user makes a request to the same JVM instance, will the second user have to wait the remaining 3 seconds before their request even starts being processed?

A: 

I don't think so. If it works like any other application server, each request is on a different thread.

Valentin Rocher
A: 

Each instance can have more than one thread. I can't find a reference to link that says so, but if each JVM was single threaded, I think we would see a lot more requests feel slow due to the delay of new JVM's starting up.

Peter Recore
+1  A: 

Currently, JVMs are single threaded, but you shouldn't rely on that continuing to be the case: The Java Servlet spec allows Servlet containers to be multi-threaded.

As far as your example goes, no, the second user will not have to wait: App Engine spins up multiple independent VMs to service your app, so the second request will go to a different VM.

Nick Johnson