go - Should we store App Engine Context in a global var versus creating it for every request? -


We currently generate App Engine references on every single request. We have read elsewhere, it does not matter because the app engine essentially caches the relevant context too.

  func addHandler (res http.ResponseWriter, req * http.Request) {c: = appengine Our question: Will there be any reason to store app engine reference in global variable? 

I will suggest against it for the following reasons:

  1. There is always a danger to the global situation: it can be stale, corrupt and generally it is saying that isolation and encapsulation breaks.

  2. The way you work as an appointee, like you come out on a large scale or outside, you are not really global that what the global reality is and what other requests are read / Can be written.

  3. Concurrency is made of global variable concurrency, save your discretion and do not use global variables for any web app.


Comments