Skip to content
Merged
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
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ Options:
--duration duration [client mode] measurement period (default 10s)
--enable-pprof [client mode] enable pprof profiling
--flavor string [client mode] connect behavior type 'persistent' or 'ephemeral' (default "persistent")
-h, --help show help information
--interval duration [client mode] interval for printing stats (default 5s)
--jsonlines [client mode] output results in JSON Lines format
--listen-addrs-file string [server mode] enable to pass a file including a pair of addresses and ports
Expand All @@ -132,16 +133,22 @@ Options:
--pprof-addr string [client mode] pprof listening address:port (default "localhost:6060")
--proto string [client mode] protocol (tcp or udp) (default "tcp")
--protocol string [server mode] listening protocol ('tcp' or 'udp') (default "all")
--rate int32 [client mode] New connections throughput (/s) (only for 'ephemeral') (default 100)
--rate int32 [client mode] Message throughput per connection (/s) (for 'persistent' and UDP) or new connections throughput (/s) (for 'ephemeral'). Total messages (CNT) = rate * duration * connections (for 'persistent') or rate * duration (for 'ephemeral') (default 100)
-s, --server run in server mode
--show-only-results [client mode] print only results of measurement stats
--version show version information

Output Format (Client Mode):
CNT: Total number of messages/requests sent (not connections)
For persistent mode: CNT = rate × duration × connections
For ephemeral mode: CNT = rate × duration

Examples:
tcpulse -s # Start server on default port 9100
tcpulse -s 0.0.0.0:8080 # Start server on port 8080
tcpulse -c localhost:9100 # Connect to server as client
tcpulse -c --connections 50 host:port # Connect with 50 connections
tcpulse -c --connections 1 --rate 1 --duration 1s host:port # Send exactly 1 message
```

## Examples
Expand Down Expand Up @@ -181,6 +188,11 @@ $ tcpulse -c --jsonlines --rate 1000 --duration 10s 127.0.0.1:9100

#### Standard Output Format

The standard output format includes the following columns:
- `CNT`: Total number of messages/requests sent (not connections)
- For persistent mode: CNT = rate × duration × connections
- For ephemeral mode: CNT = rate × duration

```shell-session
$ tcpulse -c --proto tcp --flavor ephemeral --rate 1000 --duration 15s 10.0.150.2:9200 10.0.150.2:9300
PEER CNT LAT_MAX(µs) LAT_MIN(µs) LAT_MEAN(µs) LAT_90p(µs) LAT_95p(µs) LAT_99p(µs) RATE(/s)
Expand All @@ -205,7 +217,7 @@ $ tcpulse -c --jsonlines --proto tcp --flavor ephemeral --rate 1000 --duration 1

The JSON Lines format includes the following fields:
- `peer`: Target server address
- `count`: Total number of successful connections/requests
- `count`: Total number of messages/requests sent (CNT in standard output)
- `latency_max_us`: Maximum latency in microseconds
- `latency_min_us`: Minimum latency in microseconds
- `latency_mean_us`: Mean latency in microseconds
Expand Down
9 changes: 7 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func init() {
pflag.Int32Var(&connections, "connections", 10,
fmt.Sprintf("[client mode] Number of concurrent connections to keep (only for '%s')", flavorPersistent))
pflag.Int32Var(&rate, "rate", 100,
fmt.Sprintf("[client mode] New connections throughput (/s) (for '%s') or message roundtrip throughput per connection (/s) (for '%s' and UDP)", flavorEphemeral, flavorPersistent))
fmt.Sprintf("[client mode] Message throughput per connection (/s) (for '%s' and UDP) or new connections throughput (/s) (for '%s'). Total messages (CNT) = rate * duration * connections (for '%s') or rate * duration (for '%s')", flavorPersistent, flavorEphemeral, flavorPersistent, flavorEphemeral))
pflag.DurationVar(&duration, "duration", 10*time.Second, "[client mode] measurement period")
pflag.Int32Var(&messageBytes, "message-bytes", 64, "[client mode] TCP/UDP message size (bytes)")
pflag.BoolVar(&showOnlyResults, "show-only-results", false, "[client mode] print only results of measurement stats")
Expand Down Expand Up @@ -167,11 +167,16 @@ func printUsage() {
fmt.Fprintf(os.Stderr, " -s, --server Run in server mode (accept connections)\n\n")
fmt.Fprintf(os.Stderr, "Options:\n")
pflag.PrintDefaults()
fmt.Fprintf(os.Stderr, "\nExamples:\n")
fmt.Fprintf(os.Stderr, "\nOutput Format (Client Mode):\n")
fmt.Fprintf(os.Stderr, " CNT: Total number of messages/requests sent (not connections)\n")
fmt.Fprintf(os.Stderr, " For persistent mode: CNT = rate × duration × connections\n")
fmt.Fprintf(os.Stderr, " For ephemeral mode: CNT = rate × duration\n\n")
fmt.Fprintf(os.Stderr, "Examples:\n")
fmt.Fprintf(os.Stderr, " %s -s # Start server on default port 9100\n", os.Args[0])
fmt.Fprintf(os.Stderr, " %s -s 0.0.0.0:8080 # Start server on port 8080\n", os.Args[0])
fmt.Fprintf(os.Stderr, " %s -c localhost:9100 # Connect to server as client\n", os.Args[0])
fmt.Fprintf(os.Stderr, " %s -c --connections 50 host:port # Connect with 50 connections\n", os.Args[0])
fmt.Fprintf(os.Stderr, " %s -c --connections 1 --rate 1 --duration 1s host:port # Send exactly 1 message\n", os.Args[0])
}

func runServer() error {
Expand Down