How does Go handle concurrent request on Google App Engine

I must admit I have no inside knowledge of AppEngine. This is all speculation and guessing, but I think it is somewhat reasonable.

Your app will never reach the ten thread limit. This is because there are very few reasons for threads to be created. First, the maximum number of goroutines running at once is set to one to enforce memory safety. Second, unlike a normal go program, app engine does not actually need to make syscalls. The only time it does is for networking. All IO in appengine can be muxed into one epoll thread. This means all you need is two threads at any given time. You can then add a third or forth thread in case every once in a while you need to run other syscalls such as allocating memory and accepting/closing connections. These are fast syscalls that block for a very small amount of time. Even with these other syscalls, you are still very far from the ten thread limit.

Concurrency is not affected because in the end, everything you do in appengine boils down to waiting for something over the network to return. You do not need multiple threads to be doing many things at once.


I was looking for an answer and happened upon this question/answers, but also ended up finding more official documentation on the matter. According to a post by Andrew Gerrand and Johan Euphrosine this can be explicitly configured.

From that post:

This configures each instance of the app to serve up to 100 requests concurrently (up from the default of 10). You can configure Go instances to serve up to a maximum of 500 concurrent requests.


A Go App Engine instance allows 10 concurrent requests, but only runs one CPU thread. In effect, multiple requests can be processed concurrently, but only one will be able to do CPU work at a time. If one request is, say, waiting for a datastore API call to return, another request is free to be processed by the same instance.

Your statement "If Go is single threaded on App Engine then point 3 is moot." is incorrect. There is still a limit of 10 concurrent in-flight requests to a single Go App Engine instance. The documentation is a bit loose with words when it talks about "threads".