As the documentation indicates, global variables are within the scope of the instance of the script itself (on the VM it’s running on?). I want to know if, in a high concurrency environment, it’s safe to increment a global variable without losing data… is it an atomic operation, like an INCR in Redis?
Also, I’m trying to create some counters that I will periodically push to a central service. I’m hoping to do this by using global variables and after short periods of time upload the data from the workers (so that if the script goes down I don’t lose too much data). Is there a better way of doing this (I’m assuming sending out a beacon for every request using a fetch is not something that will be very efficient).