Scale out using Redis
This section explains aspects of setting up a Redis server for scaling out.
Set up
Download & Run Redis from https://redis.io/download
or for Windows OS https://github.com/ServiceStack/redis-windows
In the Go import statements add
github.com/kataras/neffos/stackexchange/redisand use it.
Use
The first input argument is the optional redis client configuration.
The second one is the redis channel prefix which messages will be published and connections will be subscribed to.
Setting a channel prefix isolates one neffos app from others that use different channel prefixes.
import "github.com/kataras/neffos/stackexchange/redis"
// [server := neffos.New...]
exc, err := redis.NewStackExchange(redis.Config{}, "MyChatApp")
if err != nil {
// [...]
}
server.UseStackExchange(exc)Configure options as needed
Options can be set in the Config structure.
Network
Protocol to use
"tcp"
Addr
Network address of a single redis instance
"127.0.0.1:6379"
Clusters
A list of network addresses for redis clusters
nil
Password
A password to connect
empty
DialTimeout
Max time to connect
0
MaxActive
Keep open at least the given number of connections to the redis instance
10
Redis Clustering
Redis Clustering is a method for achieving high availability by using multiple Redis servers. Clustering is supported by the Clusters []string configuration field.
References
Last updated