benchmark_heavy_redis.sh 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #!/bin/bash
  2. echo "🔴 Redis Heavy Benchmark Suite"
  3. echo "=================================="
  4. echo ""
  5. # Check if Redis is installed
  6. if ! command -v redis-server &> /dev/null; then
  7. echo "❌ Redis is not installed"
  8. echo "Install with: brew install redis"
  9. exit 1
  10. fi
  11. # Check if Redis is running on default port
  12. if nc -z localhost 6379 2>/dev/null; then
  13. echo "⚠️ Redis already running on port 6379"
  14. echo "Stopping existing Redis server..."
  15. redis-cli shutdown 2>/dev/null
  16. sleep 1
  17. fi
  18. # Clean up old AOF file
  19. rm -f appendonly.aof
  20. # Start fresh Redis instance with AOF persistence
  21. echo "🗑️ Starting fresh Redis server with AOF persistence..."
  22. redis-server --port 6379 --save "" --appendonly yes --appendfsync everysec &
  23. REDIS_PID=$!
  24. sleep 2
  25. echo ""
  26. echo "📊 Running Heavy Benchmark Tests on Redis..."
  27. echo ""
  28. # Test 1: Heavy Write Load - 1M records
  29. echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
  30. echo "Test 1: Heavy Write Load (1M records)"
  31. echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
  32. redis-benchmark -h localhost -p 6379 -t SET -n 1000000 -c 100 --threads 8 -r 1000000 -P 32 -d 256 --csv
  33. echo ""
  34. echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
  35. echo "Test 2: Heavy Read Load (1M reads)"
  36. echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
  37. redis-benchmark -h localhost -p 6379 -t GET -n 1000000 -c 100 --threads 8 -r 1000000 -P 32 --csv
  38. echo ""
  39. echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
  40. echo "Test 3: Mixed Workload (500k each)"
  41. echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
  42. redis-benchmark -h localhost -p 6379 -t SET,GET -n 500000 -c 100 --threads 8 -r 1000000 -P 32 --csv
  43. echo ""
  44. echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
  45. echo "Test 4: Large Values (10KB payloads)"
  46. echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
  47. redis-benchmark -h localhost -p 6379 -t SET -n 100000 -c 50 --threads 4 -r 100000 -P 16 -d 10240 --csv
  48. echo ""
  49. echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
  50. echo "Test 5: Extreme Concurrency (200 clients)"
  51. echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
  52. redis-benchmark -h localhost -p 6379 -t SET,GET -n 500000 -c 200 --threads 8 -r 500000 -P 16 --csv
  53. echo ""
  54. echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
  55. echo "Test 6: Low Latency (no pipelining)"
  56. echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
  57. redis-benchmark -h localhost -p 6379 -t GET -n 50000 -c 50 --threads 4 -r 1000000 -P 1 --csv
  58. echo ""
  59. echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
  60. echo "Test 7: DELETE Performance"
  61. echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
  62. redis-benchmark -h localhost -p 6379 -t DEL -n 100000 -c 50 --threads 4 -r 1000000 -P 16 --csv
  63. echo ""
  64. echo "✅ Redis Benchmark Complete!"
  65. echo ""
  66. echo "Checking memory usage..."
  67. redis-cli INFO memory | grep used_memory_human
  68. echo ""
  69. echo "Checking AOF persistence file..."
  70. ls -lh appendonly.aof
  71. echo ""
  72. echo "Shutting down Redis..."
  73. redis-cli shutdown
  74. wait $REDIS_PID 2>/dev/null