Reputation: 1314
We have a one RoR application where we used one global variable.
When we tried to HTTP
requests from multiple browsers, for fraction of seconds it's getting nil
, again after few seconds refresh it get filled with value.
Not sure what's the happening here, is Global variable shared between multiple HTTP
requests, and due to latency creating over there?
It will more helpful if I get more detailed information on Global variables.
Upvotes: 0
Views: 1209
Reputation: 59621
again after few seconds refresh it get filled with value.
It probably has nothing to do with the fact that your waiting a few seconds. If anything when you refreshed the browser, nginx forwarded your request to a different Ruby process than the request before.
Global variables are only global within the same process - If you are running 2 Ruby processes, and set a global variable in the first the second won't see this.
If you really want to share data between multiple processes, using a database is the standard way.
Upvotes: 3