"Also, although goroutines and channels are present, when a Go app runs on App Engine only one thread is run in a given instance. That is, all goroutines run in a single operating system thread, so there is no CPU parallelism available for a given client request. We expect this restriction will be lifted at some point"
That was in May 2011. Is it still true ?
I have an app which does nothing but take advantage of Golang's speed; takes some input data, performs an in- memory calculation on it, returns the results. Never touches the datastore or any other App Engine APIs.
I need to the app to perform many calculations, ideally with some degree of parallelisation. Because I am a Golang noob I just coded up the algo without any thought to thread safety. This worked fine when I sent one request at a time, but when I tried sending multiple calculations in parallel, all the results were wrong. I suspect, but don't know 100%, that thread safety is the problem, esp as the algo uses maps and maps are not thread safe
So. How to make my algo thread safe and get some degree of parallelism.
First thoughts was to use channels, which seem to be thread safe:
But then I came across the link at the top which suggests channels might not be available.
So .. if they are not available, maybe I need to set up a task queue for the calculation which can only perform one calculation at a time.
Can someone enlighten me on the best pattern for achieving a degree of thread- safe parallelisation on Golang App Engine ?
- Golang，App Engine，渠道和线程安全