Platform |
Build Status |
Ubuntu latest |
![blast_ubuntu_latest](https://github.com/SarthakMakhija/blast-core/actions/workflows/build_ubuntu_latest.yml/badge.svg) |
macOS 12 |
![blast_macos_12](https://github.com/SarthakMakhija/blast-core/actions/workflows/build_macos_12.yml/badge.svg) |
blast is a load generator for TCP servers, especially if such servers maintain persistent connections.
Content Organization
Why blast
I am a part of the team that is developing a strongly consistent distributed key/value storage engine with support for rich queries.
The distributed key/value storage engine has TCP servers that implement Single Socket Channel and Request Pipeline
.
We needed a way to send load on our servers and get a report with details including total connections established, total requests sent, total responses read and time to get those responses back etc.
Another detail, our servers accept protobuf encoded messages as byte slices, so the tool should be able to send the load (/byte slice) in a format that the target servers
can decode. Almost all distributed systems accept payloads in a very specific format. For example, JunoDB sends (and receives) OperationalMessage encoded as byte slice.
All we needed was a tool that can send load (or specific load) on target TCP servers, read responses from those servers and present a decent :) report. This was an opportunity to build blast. blast is inspired from hey, which is an HTTP load generator in golang.
blast-core
blast-core is the heart of blast CLI. It provides support for sending requests, reading payload from file, reading responses and generating reports.
It also provides support parsing command line arguments to simplify building a custom CLI. More on this in the FAQs.
Features
blast-core provides the following features:
- Support for sending N requests to the target server.
- Support for reading N total responses from the target server.
- Support for reading N successful responses from the target server.
- Support for customizing the load duration. By default, blast runs for 20 seconds.
- Support for sending N requests to the target server with the specified concurrency level.
- Support for establishing N connections to the target server.
- Support for specifying the connection timeout.
- Support for specifying requests per second (also called throttle).
- Support for printing the report.
- Support for sending dynamic payloads with PayloadGenerator.
FAQs
- How does blast-core support dynamic payload?
blast-core provides an interface called PayloadGenerator
and ships with an implementation called ConstantPayloadGenerator
. Anyone can implement
the interface PayloadGenerator
to generate dynamic payload.
- Does blast (CLI) provide support for dynamic payload?
No, blast CLI does not provide support for dynamic payload. To implement dynamic payload, one needs to create their
own CLI. blast-core makes it easy to build a thin CLI. Creating a custom CLI involves the following:
- Express the dependency on blast-core in
go.mod
- Write a thin
main
function that provides the implementation of PayloadGenerator
The main
looks like the following:
func main() {
commandArguments := blast.NewCommandArguments()
blastInstance := commandArguments.ParseWithDynamicPayload(executableName, <<An implementation of PayloadGenerator>>)
interruptChannel := make(chan os.Signal, 1)
signal.Notify(interruptChannel, os.Interrupt)
go func() {
<-interruptChannel
blastInstance.Stop()
}()
blastInstance.WaitForCompletion()
}
- Can I create custom CLI without using the parsing of command line arguments supported by blast-core?
Yes, you can always create a custom CLI that leverages blast-core's features. The custom CLI must create an
instance of Blast struct which acts as an orchestrator between Workers
, ResponseReader
and Reporter
.
References
hey
The logo is built using logo.com.