Skip to content
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

feat: benchmark different fiber envs #5

Open
wants to merge 1 commit into
base: main
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
30 changes: 19 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
This repo contains a Go program to help you benchmark and compare Fiber vs. Bloxroute transaction streams.

## Requirements
* Golang: https://go.dev/doc/install

- Golang: https://go.dev/doc/install

## Usage

Options:
```

```text
NAME:
fiber-benchmark - Benchmark Fiber against other data sources

Expand All @@ -20,21 +23,26 @@ COMMANDS:
help, h Shows a list of commands or help for one command

GLOBAL OPTIONS:
--fiber-endpoint value Fiber API endpoint
--fiber-key value Fiber API key
--blxr-endpoint value Bloxroute API endpoint
--blxr-key value Bloxroute API key
--interval value Duration of each interval (default: 0s)
--interval-count value Number of intervals to run (default: 1)
--log-file value File to save detailed logs
--help, -h show help
--fiber-endpoint value Fiber API endpoint
--fiber-key value Fiber API key
--blxr-endpoint value Bloxroute API endpoint
--blxr-key value Bloxroute API key
--interval value Duration of each interval (default: 0s)
--interval-count value Number of intervals to run (default: 1)
--log-file value File to save detailed logs
--fiber-only Only benchmark between two Fiber endpoints (default: false)
--help, -h show help
```

### Transactions

Example:

```bash
go run . --fiber-endpoint $FIBER_ENDPOINT --fiber-key $FIBER_KEY \
--blxr-endpoint $BLXR_WS_ENDPOINT --blxr-key $BLXR_KEY --interval 20s --log-file benchmarks.csv transactions
```

### Blocks
WIP

WIP
7 changes: 7 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type config struct {
logFile string
sink string
benchmarkID string
fiberOnly bool

clickhouse clickhouse.ClickhouseConfig
}
Expand Down Expand Up @@ -176,6 +177,12 @@ func main() {
Usage: "File to save detailed logs in case of file sink",
Destination: &config.logFile,
},
&cli.BoolFlag{
Name: "fiber-only",
Usage: "Benchmark two separate Fiber endpoints between each other",
Value: false,
Destination: &config.fiberOnly,
},
&cli.StringFlag{
Name: "sink",
Usage: "Output sink. Options: 'clickhouse', 'svg', 'stdout', 'none'. Default: 'none'",
Expand Down
33 changes: 25 additions & 8 deletions transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,34 @@ func runTransactionBenchmark(config *config) error {
logger.Fatal().Err(err).Msg("Invalid config")
}

fiberSource := fiber.NewFiberSource(config.fiberEndpoints, config.fiberKey)
if err := fiberSource.Connect(); err != nil {
return err
}

var fiberSource *fiber.FiberSource
var otherSource TransactionSource
var otherSourceName string

if config.blxrEndpoint != "" && config.blxrKey != "" {
otherSource = bloxroute.NewBloxrouteSource(config.blxrEndpoint, config.blxrKey)
otherSourceName = "bloxroute"
if config.fiberOnly {
firstEndpoint := config.fiberEndpoints[0]
fiberSource = fiber.NewFiberSource([]string{firstEndpoint}, config.fiberKey)
if err := fiberSource.Connect(); err != nil {
return err
}

otherSourceName = "fiber-2"
secondEndpoint := config.fiberEndpoints[1]
otherFiberSource := fiber.NewFiberSource([]string{secondEndpoint}, config.fiberKey)
if err := otherFiberSource.Connect(); err != nil {
return err
}
otherSource = otherFiberSource
} else {
fiberSource = fiber.NewFiberSource(config.fiberEndpoints, config.fiberKey)
if err := fiberSource.Connect(); err != nil {
return err
}

if config.blxrEndpoint != "" && config.blxrKey != "" {
otherSource = bloxroute.NewBloxrouteSource(config.blxrEndpoint, config.blxrKey)
otherSourceName = "bloxroute"
}
}

sink, err := setupSink(config, sinks.Transactions)
Expand Down