Our great sponsors
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
I have a program in go that will open a new connection for each request. with a massive concurrent requests, redis goes down. I though why not i create a concurrent safe singleton pattern like this https://play.golang.org/p/BYxuXN16HlV. Do you think this approach is good or do u have a different approach. I know in mysql drive they handle the maximum number of open connections but it doesn't seem that's the case for this Redis package https://github.com/go-redis/redis
IMO you should avoid package level state and use dependency injection to pass the DB reference to your HTTP handlers. I found an example here https://github.com/sohamkamani/go-dependency-injection-example