Go api with gofiber using session storage with redis
Hello
i start to get this Error:
/app/api/database/connect.go:28 +0x15b
main.main()
/app/main.go:73 +0x4a
panic: dial tcp: lookup containers-us-west-181.railway.app: i/o timeout
somtimes is stop after 1 min somtimes is take 5 min
here is the conntion:
func InitRedis() (*redis.Storage, error) {
port, err := strconv.Atoi(os.Getenv("REDISPORT"))
if err != nil {
port = 6379
}
storage := redis.New(redis.Config{
Host: os.Getenv("REDISHOST"),
Port: port,
Username: os.Getenv("REDISUSER"),
Password: os.Getenv("REDISPASSWORD"),
Database: 0,
Reset: false,
TLSConfig: nil,
PoolSize: 10 * runtime.GOMAXPROCS(0),
})
return storage, nil
}
i have add the log file
16 Replies
Project ID:
ac27f0b8-f4c4-478f-9516-441b9a3c376e
ac27f0b8-f4c4-478f-9516-441b9a3c376e
add a
time.Sleep(3 * time.Second)
right before the redis.New
lineokay i will try that on the next deploy
I also would really not recommend trying to dynamically compute the pool size, or anything that relies on determining the cpu count while on Railway because go will detect the 32 cores of the host machine and throw your code out of wack for lack of a better word
okay is they a good number to set it at?
you're on hobby, so you have 8 vcpus, set the pool variable at a static 80
this is the default PoolSize: 10 * runtime.GOMAXPROCS(0),
by using that go max procs function and setting it to zero, you are telling go to use 0 cpus, this would have unintended consequences down the line
okay i just show this var ConfigDefault = Config{
Host: "127.0.0.1",
Port: 6379,
Username: "",
Password: "",
URL: "",
Database: 0,
Reset: false,
TLSConfig: nil,
PoolSize: 10 * runtime.GOMAXPROCS(0),
Addrs: []string{},
MasterName: "",
ClientName: "",
SentinelUsername: "",
SentinelPassword: "",
}
what redis package are you using?
github.com/gofiber/storage/redis/v3
set it to 80
okay thx i will do that
just to be clear you mean like PoolSize: 80,
yes
Thx that did it