StackExchange.Redis icon indicating copy to clipboard operation
StackExchange.Redis copied to clipboard

Redis ListRightPop extremly slow

Open ed-builds opened this issue 10 years ago • 7 comments

All what am doing is _redisDatabase.ListRightPop(PendingQueueName); and its super slow against a linux instance.

ed-builds avatar Nov 19 '16 23:11 ed-builds

Can you define "super slow"? Can you provide some repro code?

NickCraver avatar Nov 20 '16 14:11 NickCraver

What I meant is, other operations examples (adding to list, sorted list, hashset) yeilds about 9,789 ops per second but when only doing ListRightPop(PendingQueueName) it yeilds 25 ops per second all with the same library against a linux redis instance out of the box configuration. Also, same code pointed to a windows redis instance works ok (yeilds about 900 ops per second for ListRightPop) but not for redis running on either Mac, or Linux. Here is a code sample.running again a list with 200K items.

Also keys are guids. (17ca8a2f-a6c2-465f-ba49-5691dfd49582)

This is my factory to get an IDatabase ` public class RedisStore { private static Lazy _lazyConnection; private static readonly object RedisObjectLock = new object();

    public static void Initialize(params string[] endPoints)
    {
        lock (RedisObjectLock)
        {
            if (_lazyConnection != null)
                return;

            var configurationOption = new ConfigurationOptions
            {
                AllowAdmin = true,
                AbortOnConnectFail = false
            };

            foreach (var endPoint in endPoints)
                configurationOption.EndPoints.Add(endPoint);

            _lazyConnection = new Lazy<ConnectionMultiplexer>(() => ConnectionMultiplexer.Connect(configurationOption));
        }
    }

    public static ConnectionMultiplexer Connection
    {
        get
        {
            return _lazyConnection.Value;
        }
    }

    public static void Dispose()
    {
        _lazyConnection.Value.Dispose();
    }
}

} `

//This is the code for getting items from the queue public string Dequeue() { var messageId = RedisStore.Connection.GetDatabase().ListRightPop(PendingQueueName); if (string.IsNullOrEmpty(messageId)) return null; return messageId; }

ed-builds avatar Nov 20 '16 19:11 ed-builds

Any updates?

ed-builds avatar Nov 25 '16 01:11 ed-builds

In this scenario, what is the size of the keys and payloads in the different operations? Are they comparable? If so, this doesn't sound like a library issue, but: a server issue. The library doesn't do much different between these operations.

On 20 Nov 2016 7:33 p.m., "Edward Adjei" [email protected] wrote:

What I meant is, other operations examples (adding to list, sorted list, hashset) yeilds about 9,789 ops per second but when only doing ListRightPop(PendingQueueName) it yeilds 25 ops per second all with the same library against a linux redis instance out of the box configuration. Also, same code pointed to a windows redis instance works ok (yeilds about 900 ops per second for ListRightPop) but not for redis running on either Mac, or Linux. Here is a code sample.running again a list with 200K items.

This is my factory to get an IDatabase ` public class RedisStore { private static Lazy _lazyConnection; private static readonly object RedisObjectLock = new object();

public static void Initialize(params string[] endPoints)
{
    lock (RedisObjectLock)
    {
        if (_lazyConnection != null)
            return;

        var configurationOption = new ConfigurationOptions
        {
            AllowAdmin = true,
            AbortOnConnectFail = false
        };

        foreach (var endPoint in endPoints)
            configurationOption.EndPoints.Add(endPoint);

        _lazyConnection = new Lazy<ConnectionMultiplexer>(() => ConnectionMultiplexer.Connect(configurationOption));
    }
}

public static ConnectionMultiplexer Connection
{
    get
    {
        return _lazyConnection.Value;
    }
}

public static void Dispose()
{
    _lazyConnection.Value.Dispose();
}

}

}`

This is the code for getting items from the queue. public string Dequeue() { var messageId = RedisStore.Connection.GetDatabase().ListRightPop( PendingQueueName); if (string.IsNullOrEmpty(messageId)) return null; return messageId; }

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/StackExchange/StackExchange.Redis/issues/527#issuecomment-261799485, or mute the thread https://github.com/notifications/unsubscribe-auth/AABDsArofxXVYDR1dY0rHEl2F2MAZ55fks5rAKBZgaJpZM4K3Zp5 .

mgravell avatar Nov 25 '16 07:11 mgravell

this is the actual value of the key am passing in

private const string PendingQueueName = "strimeo:queue:pending"; RedisStore.Connection.GetDatabase().ListRightPop(PendingQueueName)

And the Redis Value it returns is a guid. eg: "cc4924a2-3ee1-4318-8d9f-2eb46ba64fae"

ed-builds avatar Nov 25 '16 17:11 ed-builds

That shouldn't trip it at all. I very much doubt that this is a library issue- it sounds more like a server configuration problem, especially as it depends on the server back-end.

On 25 Nov 2016 5:50 p.m., "Edward Adjei" [email protected] wrote:

this is the actual value of the key am passing in

private const string PendingQueueName = "strimeo:queue:pending"; RedisStore.Connection.GetDatabase().ListRightPop(PendingQueueName)

And the Redis Value it returns is a guid. eg: "cc4924a2-3ee1-4318-8d9f- 2eb46ba64fae"

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/StackExchange/StackExchange.Redis/issues/527#issuecomment-263004512, or mute the thread https://github.com/notifications/unsubscribe-auth/AABDsKnB-zeV89Y_APjZvDFOX2E9sQJbks5rBx_1gaJpZM4K3Zp5 .

mgravell avatar Nov 26 '16 07:11 mgravell

Closing this out to cleaning barring any new info - definitely agree this appears to be entirely server-side.

NickCraver avatar Sep 02 '17 01:09 NickCraver