Bivil M Jacob
Bivil M Jacob

Reputation: 521

Redis list performance metrics

I am using redis-queue gem to implement a message queue in redis server. Every single message undergoes the lpush and lpop command in the message queue. I am able to get the current length of the queue which is apparently a Redis list using the llen command.

But is there any single way I can get the total number of lpush as well as lpop happened on the list during a particular time span, say in the past 24 hrs. ?

Upvotes: 1

Views: 1044

Answers (2)

Itamar Haber
Itamar Haber

Reputation: 49962

In addition to using keyspace notifications, as proposed by my esteemed SO peer Matias, there are at least two additional ways that you can do that:

  1. The INFO COMMANDSTATS prints, for each command, a wealth of information including a counter. To reset the instance's statistics, use CONFIG RESETSTAT. Note that this does not offer per key counts but per command (which may be good enough, depending on the case).

  2. You can MONITOR a Redis instance to get a stream of all the commands it executes. Simple filtering can get you any statistic you're after, but note that using MONITOR has a performance impact.

Upvotes: 1

Matías Fidemraizer
Matías Fidemraizer

Reputation: 64923

It seems like you can use Redis keyspace notifications for this. Redis can be activated to publish messages when keys are changed under certain conditions and then you can subscribe to this messages using regular Redis pubsub.

Upvotes: 2

Related Questions