#Go api with gofiber using session storage with redis

18 messages · Page 1 of 1 (latest)

limber reef
#

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

fathom lionBOT
#

Project ID: ac27f0b8-f4c4-478f-9516-441b9a3c376e

strange widgetBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

limber reef
#

ac27f0b8-f4c4-478f-9516-441b9a3c376e

wind sandal
#

add a time.Sleep(3 * time.Second) right before the redis.New line

limber reef
wind sandal
#

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

limber reef
#

okay is they a good number to set it at?

wind sandal
#

you're on hobby, so you have 8 vcpus, set the pool variable at a static 80

limber reef
#

this is the default PoolSize: 10 * runtime.GOMAXPROCS(0),

wind sandal
#

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

limber reef
#

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: "",
}

wind sandal
#

what redis package are you using?

limber reef
wind sandal
#

set it to 80

limber reef
#

okay thx i will do that

#

just to be clear you mean like PoolSize: 80,

wind sandal
#

yes