When your database performs as quickly as Redis, you can be really sensitive to slow queries. That's why the Redis developers created the slow queries log to record those queries that execute too slowly and a SLOWLOG command to read and configure that log.
On Compose Redis deployments, you've always been able to get at the results of this log from the Redis command line. We wanted this information to be easier to get at so now you can configure and access the slow query log using our web interface.
To find the Slow log support, go to your Compose Redis console and select the Browser. Once in the browser's database selection view, you'll now see a "Slow log" option in the options. It's there because it affects all databases within a Redis deployment. Select it to get to the Slow log view.
The first thing you'll see are the current results of the Slow log. If your database hasn't had any slow log events, it'll look like this:
This view lets you view a number, ten by default, of entries in the Slow log. If something had triggered a Slow log event, it would look like this:
Here we can see the event ids, the relative time they occurred, the number of microseconds they took and, most importantly, the command that caused the slow log event. What you do with this information is up to you.
The next question is where do we set the parameters for the slow log. Notice the Settings tab, and click on that to see this:
As always with the Compose console, we've integrated as much information into the front end as possible. There's two configurable settings,
slow-log-slower-than. The slow log is actually a queue of slow log events and you can control the size of that queue with
slowlog-max-len. The bigger you make it, the more memory you will consume. Ideally, it should be big enough for you to catch your problematic slow commands, but not so big that it becomes an issue itself. The default is 128 and we recommend you run with that till you are certain you need to expand it.
The other way to capture that tricky slow event would be to filter out all the slow, but not that slow, log events . That's where
slowlog-log-slower-than comes in. It sets the threshold on what qualifies as a slow event. It defaults to 10000 microseconds. The sharp-eyed amongst you will notice that in the screenshot of those results earlier, there were much smaller execution times. That's because we set the
slowlog-log- slower-than to 100 microseconds before taking that screenshot. You can take this setting all the way down to 0 if you want - everything will be logged as it all takes more than 0 microseconds. Or you can go one further and set it to -1 which disables slow logging. Again, we recommend you start with the default. If you are trying to track down a particularly slow event, it's then worth raising the
slowlog-log-slower-than to isolate those events in the log.
When you change either of those values, you'll need to click Update Settings to apply them immediately. Finally, there's the Reset button gives you a quick way to clear the Slog log and reclaim the memory used by those entries.
Once set up, you can return to the results. If we just reset our
slowlog-log-slower-than to 10000 microseconds and go back to our results:
We can see another, actual slow event has occurred listing the contents of
Notes on slow logs
It's worth remembering that this is just the execution time of the command. The I/O involved in processing the command is not measured, only the time spent doing the actual work of the command. The I/O is multithreaded so it can take place alongside other work, but the execution happens on a single thread, blocking other commands from running, and is therefore the critical thing to measure from the database's point of view. Another thing to keep in mind is that the Slow log is transient; there's no persistence for it so in the case of failover, the slow log is lost. If you are looking to rely on a persistent slow log, you'll be wanting to reconsider your design choices.
So, now you can see and control slow logs from the Compose Redis web console. It's just another way Compose brings the power of your databases to your fingertips.