I need to create a C# application (Windows Service), which runs every 5 seconds (interval), generates around 20 Million values.
I need to insert these 20 Million values into Redis (1 Key / Value) in under 5 seconds, making sure the inserts are finished before the next interval is started.
Note: I have to only keep 7 cycles in Redis => 20 Million * 7 => 140 Million Keys in Redis
I am using C#'s Threading.Tasks to call a function (20 Million Times), so that they are processed in parallel (asynchronously).
I have even created a pool for Redis clients for my process to be able to execute Redis queries also in parallel.
Here is the C# part calling the function 20 Million times:
List<Task> tasksList = new List<Task>();
foreach (object k in ListOf20MillionData)
{
tasksList.Add(
Task.Factory.StartNew(() =>
{
GenerateValue(k);
//Inside 'GenerateValue' data is generated and pushed to redis
})
);
}
Here is a section of code inside 'GenerateValue' which gets a redis client object from a Pool of clients, executes the insert and releases back the redis client into the pool.
RedisClient redisClientObj = RedisPool.GetNextAvailableClient();
redisClientObj.Add("SomeKey", "SomeValue");
RedisPool.ReleaseRedisClient(redisClientObj );
My Concerns and challenges:
- Is my concept of Redis Pools ok?
- How many Client connections can Redis handle?
- Is my request even possible to achieve using C# and Redis?
- Any advice or recommendation is highly appreciated.