Giter Site home page Giter Site logo

gobench-io / gobench Goto Github PK

View Code? Open in Web Editor NEW
64.0 8.0 14.0 70.86 MB

A benchmark framework based on Golang

License: Apache License 2.0

Go 5.84% Makefile 0.05% JavaScript 37.05% Shell 0.05% SCSS 3.67% Dockerfile 0.01% HTML 50.40% CSS 2.92%
mqtt nats http distributed metrics histograms gauge counter benchmark gobench

gobench's Introduction

A benchmark framework with Golang.

Note: Gobench is under heavy development.

Targets:

  1. Supporting more than HTTP. We are having MQTT, NATs. Websocket, graphQL will be added.
  2. Having complicated benchmarking scenario in Golang. Yo no DSL, and Golang is easy to pickup.
  3. (WIP) To support more than one million connection concurrently.

Build Status codecov

Usage

Install from source

Requirements:

  • golang to compile your scenario
  • gcc to build sqlite3 embedded database

Install the command line tool first

For Go 1.17+

go install github.com/gobench-io/gobench@master

For Go 1.16 and below

go get github.com/gobench-io/gobench

This mechanism will install a build of master at $GOPATH/bin. To test your installation:

$ gobench
{"level":"info","ts":1601432777.7513623,"caller":"master/master.go:71","msg":"new master program","port":8080,"home directory":"/home/nqd/.gobench"}
{"level":"info","ts":1601432777.9341393,"caller":"web/web.go:161","msg":"web server start","port":":8080"}

After that, open http://localhost:8080 to see the dashboard.

Run from docker

docker run -p 8080:8080 nqdinh/gobench:latest

After that, open http://localhost:8080 to see the dashboard.

To setup admin password, add --admin-password to argument. To save the results to the host machine, mount /root/.gobench (the default --dir) to a host path. For example, save the result data to /tmp/abc and set admin password to supertest with the following command:

docker run -p 8080:8080 -v "/tmp/abc:/root/.gobench" nqdinh/gobench:latest --admin-password supertest

Quick start

Start the Gobench server, go to http://localhost:8080 dashboard, create new application.

Input scenario as the following go code. gomod and gosum are used to control specific version of dependency packages. We will leave them empty now.

// Test a server running on a local machine on port 8080.
// Send 10 requests per second for 2 minute from 5 nodes in parallel,
// which totals up to 50 requests per second altogether.

package main

import (
    "context"
    "log"
    "time"

    httpClient "github.com/gobench-io/gobench/clients/http"
    "github.com/gobench-io/gobench/dis"
    "github.com/gobench-io/gobench/executor/scenario"
)

func export() scenario.Vus {
    return scenario.Vus{
        {
            Nu:   5,
            Rate: 1000,
            Fu:   f,
        },
    }
}

func f(ctx context.Context, vui int) {
    client, err := httpClient.NewHttpClient(ctx, "home")
    if err != nil {
        log.Println("create new client fail: " + err.Error())
        return
    }

    url1 := "http://localhost:8080"

    timeout := time.After(2 * time.Minute)

    for {
        select {
        case <-timeout:
            return
        default:
            go client.Get(ctx, url1, nil)
            dis.SleepRatePoisson(10)
        }
    }
}

From the dashboard, you will see the live result:

You also see the status of the host running Gobench: Load average, CPU utilization, RAM usage, network in/out.

How to write scenario

Scenario is a go file that must have a func export() scenario.Vus {...} function. This function return an array of scenario.Vu struct.

Each scenario.Vu defines behavior of a type of virtual user (vu). In previous example, the vu is defines as

{
    Nu:   5,
    Rate: 1000,
    Fu:   f,
}

, on which:

  • Nu defines the number of virtual users for this type of user
  • Rate is the startup rate for all virtual users with Poisson distribution. In this case 1000 virtual users are created in one second.
  • Fu defines the behavior of a virtual user. Fu must be define as func f(ctx context.Context, vui int) {...}.

When your benchmark scenario is more complecated, you can define multiple virtual user types

func export() scenario.Vus {
    return scenario.Vus{
        {
            Nu:   5,
            Rate: 1000,
            Fu:   adminF,
        },
        {
            Nu:   7,
            Rate: 1000,
            Fu:   userF,
        },
    }
}

How to write a new worker

Gobench is supporting 3 clients: HTTP, MQTT, NATs. Creating a new type of worker for Gobench is very simple. The worker has to have the following properties.

Expose the metrics

Exposes to gobench via executor.Setup(groups) calling where groups is []metrics.Group{} structure.

For convenience, one should call the metrics setup at the end of constructor like NewHttpClient on which calling executor.Setup.

Gobench strictly force you to create the metrics hierarchy. Group name (Group.Name) must be unique globally. Also metric title (Metric.Title) must be unique globally.

Gobench is supporting 3 kinds of metric: counter, histogram, and gauge.

Notify the metric

Notify to gobench via executor.Notify(metric name, value).

See clients/http for HTTP worker example.

Benchmark the benchmark

Right, the benchmark tool should show the ability to generate a good amount of traffic given RAM, CPU resources. For HTTP, we compare Gobench with k6 (v0.29.0), hey (v0.1.4), Artillery (v1.6.1), Jmeter (v5.2.1). For MQTT, we compare Gobench with eqmtt_bench.

We benchmark the benchmarks with two c5.4xlarge (16 core CPU, 32 GB RAM) VM. For HTTP case, the server is the high speed Nginx. Each client gets the main Nginx page with vu = 30 during 120 seconds.

HTTP client CPU (%) RAM (MB) RPS
hey 218 150 27220
k6 342 556.3 26314
Jmeter 199 814.6 26259
Gobench 281 114.5 25686
Artillery 107 145.3 1197

For MQTT case, the server is Vernemq. Each client run two scenarios: (1) Just create n clients that to Vernemq with 10 seconds heartbeat, and (2) create n clients, each publishes 1 message per second to topic bench/$i where i is the client id. We choose n = 250, 11250, 25000.

MQTT client CPU (%) RAM (MB)
Gobench 250 conn 12 225
Gobench 11250 conn 31 536.5
Gobench 25000 conn 52 1024
emqtt_bench 250 conn 12 147
emqtt_bench 11250 conn 37 643
emqtt_bench 25000 conn 49 1485
Gobench 250 pub 85 267.3
Gobench 11250 pub 286 741.9
Gobench 25000 pub 669 1450.0
emqtt_bench 250 pub 52 252
emqtt_bench 11250 pub 297 995
emqtt_bench 25000 pub 850 2847

Sponsor

gobench's People

Contributors

dependabot[bot] avatar duyndh avatar hieu-lethanh avatar hieult1393 avatar nguyencatpham avatar nqd avatar thoverik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gobench's Issues

[API] Dashboard statistic counter

Provide an API for Frontend to get some statistic counters like total Gobench applications, total healthy agents, total scenarios, etc.

[UI] Able to export results for reporting

Description:

πŸš€ We are looking for contributors to enhance the UI functionality of Gobench v2! Our goal is to introduce a new feature that enables users to export benchmark results for easy reporting and analysis.

πŸ” Task:
Implement a user-friendly export feature that allows users to download benchmark results in various formats, such as CSV, JSON, or PDF. This functionality will empower users to generate reports, share data with stakeholders, and perform further analysis.

πŸ’» Skills Needed:

  • Proficiency in UI/UX design and development
  • Experience with frontend technologies (HTML, CSS, JavaScript, etc.)
  • Familiarity with data export libraries or APIs is advantageous but not required

πŸ™Œ Join our open-source community and contribute to the success of Gobench v2. Your efforts will facilitate seamless data reporting and add value to users' benchmarking experience.

πŸ“Œ If you're interested in collaborating with us on this UI enhancement, leave a comment on this issue to express your interest. Let's work together to make data export a breeze for our users!

image

Gobench v2 Wireframes

Objective: Create wireframes for Gobench v2 web app UI to visualize layout and interactions.

Requirements:

Homepage Wireframe: Create a wireframe for the homepage that showcases key features, project statistics, and navigation elements. Consider the layout, call-to-action buttons, and any important information that should be displayed on the homepage.

Benchmarking Scenario Creation: Design wireframes for the benchmarking scenario creation process. This includes defining the inputs, parameters, and options for setting up different benchmark scenarios. Consider providing clear guidance and validation messages to assist users in creating scenarios correctly.

Scenario Dashboard: Create wireframes for the scenario dashboard, where users can view and manage their created benchmark scenarios. Include options for editing, duplicating, and deleting scenarios, as well as relevant statistics and status indicators.

Result Visualization: Design wireframes for visualizing benchmarking results. Include graphs, charts, and other visual elements to represent data in an informative and easy-to-understand manner.

User Settings and Authentication: Create wireframes for user settings and authentication pages, allowing users to manage their accounts, update preferences, and securely log in/out of the application.

Responsive Design: Ensure that the wireframes consider responsive design principles, providing a consistent and user-friendly experience across different devices and screen sizes.

[UI] Able to GET/SET target server information in a Gobench application

Description:

πŸš€ We are seeking contributions to enhance the UI functionality of Gobench v2! We aim to implement a new feature that allows users to easily GET/SET target server resource information within the Gobench application. This feature might link to Grafana or get metrics from other metric servers like Prometheus.

πŸ” Task:
Create an intuitive user interface that enables users to input and modify target server resource information, such as CPU, Memory, Network In/Out, and other relevant metrics. Additionally, implement a feature to fetch and display the existing server resource information for reference.

πŸ’‘ Possible Integrations:
Explore the possibility of integrating Gobench with Grafana or other metric servers like Prometheus. Users should be able to seamlessly import resource metrics from these external sources and utilize them for more comprehensive benchmarking analysis.

πŸ’» Skills Needed:

  • Proficiency in UI/UX design and development
  • Experience with frontend technologies (HTML, CSS, JavaScript, etc.)
  • Familiarity with RESTful APIs or backend integration is advantageous but not required

πŸ™Œ Join our open-source community and contribute to the success of Gobench v2. Your contributions will empower users to seamlessly configure their target server resource information, link to external metrics sources, and streamline the benchmarking process with valuable insights.

πŸ“Œ If you're interested in collaborating with us on this UI enhancement, leave a comment on this issue to express your interest. Let's work together to make target server resource management and metric integration a breeze for our users!

image

Support for Deployment Options

I want to enhance Gobench with support for multiple deployment options to make it more accessible and convenient for users. The following deployment options should be considered:

  • Manual install
  • Docker Container
  • Kubernetes (K8s) Helm chart
  • Terraform

By supporting these deployment options, we aim to make Gobench more accessible and adaptable to various deployment scenarios. I welcome input, contributions, and suggestions from the community to help implement and improve these deployment options.

Please share your thoughts, ideas, or any additional deployment options that you think would be valuable for Gobench.

Thank you for your support and collaboration!

Here are a few suggestions to consider when adding support for deployment options in Gobench

Documentation: Create clear and detailed documentation for each deployment option, including step-by-step instructions, configuration parameters, and any prerequisites or dependencies. This will help users understand how to deploy Gobench using different methods.

Examples and Templates: Provide sample configurations, Dockerfiles, Kubernetes manifests, Helm charts, and Terraform scripts as examples. These examples will serve as starting points for users to customize and adapt Gobench deployment to their specific needs.

Integration Testing: Set up automated integration tests that validate the deployment options. This will help ensure that Gobench can be successfully deployed and run using different methods, providing confidence to users.

Version Compatibility: Specify the compatibility of Gobench with different deployment options, including the minimum required versions of Docker, Kubernetes, Helm, and Terraform. Regularly update and test Gobench against new versions to ensure ongoing compatibility.

Continuous Integration/Deployment (CI/CD): Integrate Gobench's deployment options into Github Action to automate the building and testing of Docker images, Helm charts, and Terraform scripts. This ensures that changes and updates to the deployment options are thoroughly tested.

heartbeat for agent discovery

When running in distributed mode, the master needs to know the working agents.

We will implement a simple heartbeat via gRPC to check for liveness of master and agent.

Tech tasks:

  • define gRPC schema
  • implement the heartbeat

Support for slow connection

Sometimes, the Gobench UI show popup request failed or request data not found or request data does not exist. It's might be a problem when we deploy Gobench on a cross-region. For example, I deployed Gobench in the US but I access the Gobench UI from Vietnam. So, the response time for each request is high and the request was time out.

Screen shoots

image

Solution

I increase the request timeout for Axios (an HTTP client library).

Avoid using caret in versioning of Go and Node in CI Job

I think we should not use caret when setting up the environment in CI to avoid compatible issues between deps.

Currently:

- name: Set up Go 1.16
  uses: actions/setup-go@v2
  with:
    go-version: ^1.16
  id: go

- name: Set up Nodejs 14
  uses: actions/setup-node@v2
  with:
    node-version: ^14.15
  id: node

CI will use Go 1.20.5 and Node 14.21.3

[UI] Able to compare benchmark results of 2 Gobench applications

Description:

πŸš€ We need your help to enhance the UI functionality of Gobench v2! We are looking to add a new feature that allows users to compare benchmark results of two Gobench applications effortlessly.
The UI feature enables users to select and view benchmark results from two different Gobench applications side by side, facilitating comparison between the two sets of data. This can be valuable for users who want to analyze and contrast the performance or metrics of their applications under different conditions or configurations.
By offering the ability to compare benchmark results, users can gain deeper insights into their application's performance and identify any variations or improvements between the two test runs.

πŸ” Task:
Implement a side-by-side comparison view where users can select and visualize the benchmark results from two different Gobench applications. This feature will empower users to analyze performance variations, identify trends, and make data-driven decisions for their applications.

πŸ’» Skills Needed:

  • Proficiency in UI/UX design and development
  • Experience with frontend technologies (HTML, CSS, JavaScript, etc.)
  • Familiarity with Gobench or benchmarking tools is a plus, but not required

πŸ™Œ Join our open-source community and make a significant impact on the Gobench project. Your contributions will help users gain deeper insights into their applications' performance and foster better decision-making.

πŸ“Œ If you're excited to collaborate with our team and tackle this UI challenge, leave a comment on this issue to express your interest and get started!

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.