Can I use the Goroutines in the Google App Engine?

Can I use the Goroutines in the Google App Engine?

The following example seems to work, but can I use it? My goal is to make background processing very easy (while the actual task task is too heavy), and I want to immediately return the result to the client.

func MyHandler(w http.ResponseWriter, r *http.Request) { go func() { // do something here but return immediately }() return // 200 } 
+6
source share
1 answer

Yes, you can do this, but consider the limitations of goroutines for AppEngine:

The Go runtime for App Engine provides full support for goroutines, but not for parallel execution: goroutines are planned on a single operating system thread. This single-threaded restriction may be removed in future versions. It is possible to process several requests simultaneously with this instance; this means that if one request, say, is waiting for a call to the data warehouse API, there may be another request being processed by the same instance.

Source: https://cloud.google.com/appengine/docs/go/runtime

See https://cloud.google.com/appengine/docs/go/ for more details.

+7
source

Source: https://habr.com/ru/post/978823/


All Articles