memory - Share variables between hosts with Go -


I have an application in Golong, and this will load basic data globally, so that the application responds faster Create and export a http interface to update the version while the user changes the database.

But I launch another server, and I use a proxy. There is a problem, when the user sends an update URL to the URL, it will load the traffic from any of the servers. Not others

utils.go:

  Basic data map to package utilities [string] * MyModel func UpdateVar () {// some work} func PreLoadVar () { // preload data in original data}   

and main.Go

  package main import ("codebase / utils") func main () {Utils. PreLoadVar ()}   

So is there any sharing between multiple hosts? Or can any worker help in this work?

Nsq.io is a good option, but if I think I want one more simpler. Thank you :)

Your global variable is a very simple form, which is known to be problematic when There are several ways to fix this problem: There are several ways to fix this problem:

  1. As suggested by Bill Nelson: Using your database as a central database And do not cache your data in your data.
  2. Open your cache externally with a simple key-value store, for example by using any one.
  3. Use a distributed cache such as.

    If you have a lot of time on your hands, then may be use a message solution like NSQ to implement your distributed cache, but I I will advise against this - this is not an easy problem.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -