Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance between 1.2.6 and 2.0.601 #1327

Closed
zhangxin511 opened this issue Jan 21, 2020 · 1 comment
Closed

Performance between 1.2.6 and 2.0.601 #1327

zhangxin511 opened this issue Jan 21, 2020 · 1 comment

Comments

@zhangxin511
Copy link

zhangxin511 commented Jan 21, 2020

To whom it may concern,

We are upgrading our legacy 1.2.6 client to latest 2.0.601 version with our redis to elasticache upgrade. It could relate how we use the library, however we noticed a performance issue, and also see StackExchange.Redis.RedisTimeoutException, and I am able to replicate just use the .net framework 4.8 console app below, all the program doing is insert random numbers to elasticache by parallel:

using StackExchange.Redis;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading.Tasks;

namespace RedisSync
{
    class Program
    {
        static void Main(string[] args)
        {
            var plexer = ConnectionMultiplexer.Connect("Our super secret connection string to elasticache with auth token and ssl enabled");
            var tasks = new List<Task>();
            var rnd = new Random();
            var sw = Stopwatch.StartNew();

            for (int taskCtr = 0; taskCtr < 500; taskCtr++)
                tasks.Add(Task.Run(() =>
                {
                    var rndKey = rnd.Next(10000);
                    try
                    {
                        plexer.GetDatabase().StringSet(
                            rndKey.ToString(),
                            rndKey,
                            TimeSpan.FromMinutes(5)
                        );
                    }
                    catch (Exception)
                    {
                        Console.WriteLine($"Failed to play key {rndKey}");
                        throw;
                    }
                }));

            try
            {
                Task.WaitAll(tasks.ToArray());
            }
            catch (AggregateException e)
            {
                foreach (var ie in e.InnerExceptions)
                    Console.WriteLine("{0}: {1}", ie.GetType().Name, ie.Message);
            }

            Console.WriteLine($"Takes {sw.ElapsedMilliseconds} ms, Press enter to finish");
            Console.ReadLine();
        }
    }
}

When the program runs on 1.2.6, everything is fine. However when it runs on 2.0.601, it complains about timeout for 5000ms, using the exactly same code.

We have to reduce 500 to 16 or smaller number for the task list on my local, in order to avoid the timeout exception. But we will then see performance drops measured by the stopwatch.

Just want to see anything we did wrong?

@zhangxin511 zhangxin511 changed the title Performance between 1.2.6 and 2.* Performance between 1.2.6 and 2.0.601 Jan 21, 2020
@zhangxin511
Copy link
Author

Sorry for the interruption, I figured out the WORKER and IOCP are playing the trick here. playing around it make it works now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant