Use Redis for Centralized service status tracking

When your working environment grows, services may have dependencies with each other, and this would affect your implementation of an effective monitoring solution. In typical cases, the status of a service cannot be judged simply by itself, and we have to query the status of its brother (upstream, or downstream) nodes. Here comes a question, How can we resolve this kind of issue smoothly?

As we know, by using a modern monitoring system like Zabbix, it gives you the ability of conditions check. The status of a service can be judged by multiple conditions, and each of the condition is a checking rule.

To simplify the dependencies check among services, an easy way in mind is to use a central database to keep a record of status of each service. Redis comes as a good solution, for the reasons of:

1, Redis is lightweight and easy to maintain.
Redis has less than 30k lines of code by source code. To set it up, we basically need a binary and a config file. It’s smart enough for system admins. For example, if you want to enable replications between two Redis databases, we just need to add one more line on the slave node.

2, Its interface are smartly defined and easy to talk to.
You can talk to Redis in Shell script by redis-cli, or even by telnet (or nc).  It also has enough extentions that support common scripting languages like PHP/Python/Ruby/Perl. Additionally, with the help of Webdis, you can talk to Redis via HTTP by wget (or curl).

3, Rich featured. Different data types supported, and time-sensitive records, etc.
Each of its record is called a key-value pair, and you can define a TTL over it, so that it disappeared when time is out. You can store any type of data into Redis, and meanwhile we can limit the size of each record, so that it won’t take unexpected amount of system resource. These features fit a monitoring environment well.

To install redis, it’s one command like “yum install redis” or “apt-get install redis“, then it’s time for you to update your existed script to send status data to Redis periodically, and accordingly add features to do dependencies checks. Have fun!

Share this post

Post Comment