Analyse Redis cache usage with PowerShell

At the load tests I need to analyse communication between web servers and Redis Cache. My target was to have a statistics with most accessed cache keys. To get required stasticts I run MONITOR command to collect data from Redis cache usage to file using redis-cli command:

.\redis-cli.exe -h <redis_host> -a <redis_access_key> monitor > monitor.log

Udemy course: Improve your productivity with PowerShell

Then I run load test to create traffic on web servers. After the load test I stop MONITOR command using CTRL+C. Statistics is created from usage of GET command. Raw monitor.log file is processed by following PowerShell command:

Get-Content .\monitor.log `
 | Select-String " ""GET"" " `
 | ForEach-Object { $_.ToString().Split(@(" ""GET"" "), [System.StringSplitOptions]::None)[1] } `
 | Group-Object `
 | Sort-Object -Property Count -Descending `
 | Format-Table -Property Count,Name

Result of PowerShell command is summary statistics with most accessed cache keys:

Count Name
----- ----
 2570 "OrderService_OrderService_Orders_STATE"
 2570 "OrderService_OrderService_Orders"
  261 "Test_a2/product/detail/1"
  225 "Test_a2/product/detail/1HQNnoneV+n+FCDE"
  211 "Test_a2/product/category/1"
  211 "ProductService_ProductService_Product_1_STATE"
  202 "Test_a2/product/detail/1"
  196 "ProductService_ProductService_Product_1"   

If you are interested in PowerShell automation, take my Udemy course Improve your productivity with PowerShell.

Leave a Reply

Your email address will not be published. Required fields are marked *