The Redis SLOWLOG command configures and displays the content of a log of slow queries detected by Redis. On Compose Redis deployments, you've always been able to get at the results of this log from the Redis command line. The "Slow Log" feature of Compose Redis deployments allows you to view that from your Compose console on the web.
To find the Slow log support, go to your Compose Redis console. You'll see the "Slow Log" option in the sidebar menu.
The first thing you'll see when you click to open the Slow Log view are the current results of the Slow log, shown in the Results tab.
The results tab of the "Slow Log" view comprise a command line representing the command being run (
SLOWLOG GET) and a field for a number. Click Run to re-run the query and refresh the Slow log Results, shown underneath the command line.
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.
The parameters for the slow log are configured in the Settings page of the deployment. Clicking on the Settings tab of the Slow Log will take you directly there.
There are two configurable settings,
The slow log is actually a queue of slow log events. You can control the size of that queue with
slowlog-max-len. The bigger you make it, the more memory it consumes. 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 120 and you should start with that until you are certain you need to increase it.
The other way to capture that tricky slow event is 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.
The default value is 10000 microseconds, and when you are trying to track down a slow event you should begin with this default. In the screenshot shown above it is set to 1000 to catch more slow queries. You can reduce the value all the way down to 0 if you want - as a result everything will be logged as it all takes more than zero microseconds. To disable slow logging completely set it to -1.
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 the value of either
slow-log-slower-than, you need to click the Apply Configuration Changes button to save them.
It's worth remembering that slow logs are concerned with only 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, which is why it's 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.
If this article didn't solve things, summon a human and get some help!
Updated almost 3 years ago