From c6d79e671e836bb418f404d1df4ced43c2a478df Mon Sep 17 00:00:00 2001 From: Ruurd Keizer Date: Thu, 3 Oct 2024 17:20:59 +0200 Subject: [PATCH 1/2] add docker build file --- Dockerfile | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..991abbc --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM golang:latest AS builder +COPY . / +WORKDIR / +RUN make + +FROM ubuntu:24.10 +LABEL Description="redis-benchmark-go" +COPY --from=builder /redis-benchmark-go /usr/local/bin + +ENTRYPOINT ["redis-benchmark-go"] +CMD [ "--help" ] \ No newline at end of file From 4192a720106eba9254f0f7eb31c0434150ed1c1e Mon Sep 17 00:00:00 2001 From: Ruurd Keizer Date: Mon, 7 Oct 2024 20:42:21 +0200 Subject: [PATCH 2/2] add TLS support --- redis-bechmark-go.go | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/redis-bechmark-go.go b/redis-bechmark-go.go index 15ab422..c8455d3 100644 --- a/redis-bechmark-go.go +++ b/redis-bechmark-go.go @@ -2,12 +2,9 @@ package main import ( "context" + "crypto/tls" "flag" "fmt" - hdrhistogram "github.com/HdrHistogram/hdrhistogram-go" - radix "github.com/mediocregopher/radix/v4" - "github.com/redis/rueidis" - "golang.org/x/time/rate" "log" "math/rand" "net" @@ -16,6 +13,11 @@ import ( "strings" "sync" "time" + + hdrhistogram "github.com/HdrHistogram/hdrhistogram-go" + radix "github.com/mediocregopher/radix/v4" + "github.com/redis/rueidis" + "golang.org/x/time/rate" ) func benchmarkRoutine(radixClient Client, ruedisClient rueidis.Client, useRuedis, useCSC, enableMultiExec bool, datapointsChan chan datapoint, continueOnError bool, cmdS [][]string, commandsCDF []float32, keyspacelen, datasize, number_samples uint64, loop bool, debug_level int, wg *sync.WaitGroup, keyplace, dataplace []int, readOnly []bool, useLimiter bool, rateLimiter *rate.Limiter, waitReplicas, waitReplicasMs int, cacheOptions *rueidis.CacheOptions) { @@ -212,6 +214,8 @@ func main() { nameserver := flag.String("nameserver", "", "the IP address of the DNS name server. The IP address can be an IPv4 or an IPv6 address. If empty will use the default host namserver.") flag.Var(&benchmarkCommands, "cmd", "Specify a query to send in quotes. Each command that you specify is run with its ratio. For example:-cmd=\"SET __key__ __value__\" -cmd-ratio=1") flag.Var(&benchmarkCommandsRatios, "cmd-ratio", "The query ratio vs other queries used in the same benchmark. Each command that you specify is run with its ratio. For example: -cmd=\"SET __key__ __value__\" -cmd-ratio=0.8 -cmd=\"GET __key__\" -cmd-ratio=0.2") + tlsEnabled := flag.Bool("tls", false, "Use TLS") + tlsSkipCertCheck := flag.Bool("tls-skip", false, "Ignore TLS certificate check") flag.Parse() totalQueries := len(benchmarkCommands) @@ -288,6 +292,15 @@ func main() { opts.Protocol = "3" alwaysRESP2 = false } + if *tlsEnabled { + conf := &tls.Config{ + InsecureSkipVerify: *tlsSkipCertCheck, + } + opts.NetDialer = &tls.Dialer{ + NetDialer: nil, + Config: conf, + } + } ips := make([]net.IP, 0) if *nameserver != "" {