Skip to content

Add RESP3 support ( --resp parameter ) #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches:
- master
- main
pull_request:
# The branches below must be a subset of the branches above
branches:
- master
- main
schedule:
- cron: '19 18 * * 4'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'go' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://git.io/codeql-language-support

steps:
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
26 changes: 26 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# .github/workflows/github-release-publish.yml
name: Publish artifacts to github release

on:
release:
types: [published]

jobs:
releases-matrix:
name: Release Go Binary
runs-on: ubuntu-latest
strategy:
matrix:
goos: [linux, darwin]
goarch: [amd64, arm64]
steps:
- uses: actions/checkout@v3
- uses: wangyoucao577/go-release-action@v1.28
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
goos: ${{ matrix.goos }}
goarch: ${{ matrix.goarch }}
binary_name: "pubsub-sub-bench"
sha256sum: true
asset_name: pubsub-sub-bench-${{ matrix.goos }}-${{ matrix.goarch }}
build_command: "make build"
6 changes: 3 additions & 3 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ jobs:
test:
strategy:
matrix:
go-version: [1.11.x, 1.12.x, 1.13.x, 1.14.x, 1.15.x]
os: [ubuntu-latest, macos-latest, windows-latest]
go-version: [1.17.x, 1.18.x, 1.19.x]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Install Go
Expand All @@ -15,4 +15,4 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2
- name: Test
run: make test
run: make test
48 changes: 40 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,28 +1,60 @@
# Go parameters
GOCMD=GO111MODULE=on go
GOBUILD=$(GOCMD) build
GOBUILDRACE=$(GOCMD) build -race
GOINSTALL=$(GOCMD) install
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOGET=$(GOCMD) get
GOMOD=$(GOCMD) mod
GOFMT=$(GOCMD) fmt
BIN_NAME=pubsub-sub-bench
DISTDIR = ./dist

.PHONY: all test coverage
all: test coverage build
# Build-time GIT variables
ifeq ($(GIT_SHA),)
GIT_SHA:=$(shell git rev-parse HEAD)
endif

ifeq ($(GIT_DIRTY),)
GIT_DIRTY:=$(shell git diff --no-ext-diff 2> /dev/null | wc -l)
endif

LDFLAGS = "-X 'main.GitSHA1=$(GIT_SHA)' -X 'main.GitDirty=$(GIT_DIRTY)'"

.PHONY: all test coverage build checkfmt fmt
all: test coverage build checkfmt fmt

build:
$(GOBUILD) .
$(GOBUILD) \
-ldflags=$(LDFLAGS) .

build-race:
$(GOBUILDRACE) \
-ldflags=$(LDFLAGS) .

checkfmt:
@echo 'Checking gofmt';\
bash -c "diff -u <(echo -n) <(go fmt .)";\
EXIT_CODE=$$?;\
if [ "$$EXIT_CODE" -ne 0 ]; then \
echo '$@: Go files must be formatted with gofmt'; \
fi && \
exit $$EXIT_CODE

lint:
$(GOGET) github.com/golangci/golangci-lint/cmd/golangci-lint
golangci-lint run

fmt:
$(GOFMT) .

get:
$(GOGET) -t -v ./...

fmt:
test: get
$(GOFMT) ./...

test: get fmt
$(GOTEST) -count=1 ./...
$(GOTEST) -race -covermode=atomic ./...

coverage: get test
$(GOTEST) -race -coverprofile=coverage.txt -covermode=atomic .

82 changes: 54 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@

[![license](https://img.shields.io/github/license/filipecosta90/pubsub-sub-bench.svg)](https://github.com/filipecosta90/pubsub-sub-bench)
[![GitHub issues](https://img.shields.io/github/release/filipecosta90/pubsub-sub-bench.svg)](https://github.com/filipecosta90/pubsub-sub-bench/releases/latest)
[![codecov](https://codecov.io/github/filipecosta90/pubsub-sub-bench/branch/main/graph/badge.svg?token=B6ISQSDK3Y)](https://codecov.io/github/filipecosta90/pubsub-sub-bench)


## Overview

When benchmarking a Pub/Sub Systems, we specifically require two distinct roles ( publishers and subscribers ) as benchmark participants - this repo contains code to mimic the subscriber workload on Redis Pub/Sub.
Expand All @@ -10,24 +15,40 @@ Several aspects can dictate the overall system performance, like the:
- Number of subscribers per channel (controlled on subscriber)
- Subscriber distribution per shard and channel (controlled on subscriber)

## Installation

## Getting Started
### Download Standalone binaries ( no Golang needed )

### Installing
This benchmark go program is **know to be supported for go >= 1.11**.
The easiest way to get and install the Subscriber Go program is to use `go get` and then `go install`:
If you don't have go on your machine and just want to use the produced binaries you can download the following prebuilt bins:

```
go get github.com/RedisLabs/pubsub-sub-bench
cd $GOPATH/src/github.com/RedisLabs/pubsub-sub-bench
make
```
https://github.com/filipecosta90/pubsub-sub-bench/releases/latest

| OS | Arch | Link |
| :--- | :---: | ---: |
| Linux | amd64 (64-bit X86) | [pubsub-sub-bench-linux-amd64](https://github.com/filipecosta90/pubsub-sub-bench/releases/latest/download/pubsub-sub-bench-linux-amd64.tar.gz) |
| Linux | arm64 (64-bit ARM) | [pubsub-sub-bench-linux-arm64](https://github.com/filipecosta90/pubsub-sub-bench/releases/latest/download/pubsub-sub-bench-linux-arm64.tar.gz) |
| Darwin | amd64 (64-bit X86) | [pubsub-sub-bench-darwin-amd64](https://github.com/filipecosta90/pubsub-sub-bench/releases/latest/download/pubsub-sub-bench-darwin-amd64.tar.gz) |
| Darwin | arm64 (64-bit ARM) | [pubsub-sub-bench-darwin-arm64](https://github.com/filipecosta90/pubsub-sub-bench/releases/latest/download/pubsub-sub-bench-darwin-arm64.tar.gz) |

Here's how bash script to download and try it:

#### Updating
To update the Subscriber Go program use `go get -u` to retrieve the latest version:.
```bash
wget -c https://github.com/filipecosta90/pubsub-sub-bench/releases/latest/download/pubsub-sub-bench-$(uname -mrs | awk '{ print tolower($1) }')-$(dpkg --print-architecture).tar.gz -O - | tar -xz

# give it a try
./pubsub-sub-bench --help
```
go get -u github.com/RedisLabs/pubsub-sub-bench
cd $GOPATH/src/github.com/RedisLabs/pubsub-sub-bench


### Installation in a Golang env

To install the benchmark utility with a Go Env do as follow:

`go get` and then `go install`:
```bash
# Fetch this repo
go get github.com/filipecosta90/pubsub-sub-bench
cd $GOPATH/src/github.com/filipecosta90/pubsub-sub-bench
make
```

Expand All @@ -40,33 +61,38 @@ Therefore you should only use this tool on go >= 1.11.
## Usage of pubsub-sub-bench

```
Usage of pubsub-sub-bench:
Usage of ./pubsub-sub-bench:
-a string
Password for Redis Auth.
-channel-maximum int
channel ID maximum value ( each channel has a dedicated thread ). (default 100)
channel ID maximum value ( each channel has a dedicated thread ). (default 100)
-channel-minimum int
channel ID minimum value ( each channel has a dedicated thread ). (default 1)
channel ID minimum value ( each channel has a dedicated thread ). (default 1)
-client-output-buffer-limit-pubsub string
Specify client output buffer limits for clients subscribed to at least one pubsub channel or pattern. If the value specified is different that the one present on the DB, this setting will apply.
Specify client output buffer limits for clients subscribed to at least one pubsub channel or pattern. If the value specified is different that the one present on the DB, this setting will apply.
-client-update-tick int
client update tick. (default 1)
client update tick. (default 1)
-host string
redis host. (default "127.0.0.1")
redis host. (default "127.0.0.1")
-json-out-file string
Name of json output file, if not set, will not print to json.
Name of json output file, if not set, will not print to json.
-messages int
Number of total messages per subscriber per channel.
Number of total messages per subscriber per channel.
-oss-cluster-api-distribute-subscribers
read cluster slots and distribute subscribers among them.
read cluster slots and distribute subscribers among them.
-port string
redis port. (default "6379")
redis port. (default "6379")
-print-messages
print messages.
print messages.
-subscriber-prefix string
prefix for subscribing to channel, used in conjunction with key-minimum and key-maximum. (default "channel-")
prefix for subscribing to channel, used in conjunction with key-minimum and key-maximum. (default "channel-")
-subscribers-per-channel int
number of subscribers per channel. (default 1)
number of subscribers per channel. (default 1)
-subscribers-placement-per-channel string
(dense,sparse) dense - Place all subscribers to channel in a specific shard. sparse- spread the subscribers across as many shards possible, in a round-robin manner. (default "dense")
(dense,sparse) dense - Place all subscribers to channel in a specific shard. sparse- spread the subscribers across as many shards possible, in a round-robin manner. (default "dense")
-test-time int
Number of seconds to run the test, after receiving the first message.
Number of seconds to run the test, after receiving the first message.
-user string
Used to send ACL style 'AUTH username pass'. Needs -a.

```
6 changes: 5 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ module github.com/RedisLabs/pubsub-sub-bench

go 1.13

require github.com/mediocregopher/radix/v3 v3.5.2
require (
github.com/golangci/golangci-lint v1.50.1 // indirect
github.com/mediocregopher/radix/v3 v3.5.2
github.com/mediocregopher/radix/v4 v4.1.2
)
Loading