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

[ADD] account specific in/out msgs/bytes stats to CONNS #3187

Merged
merged 5 commits into from Jun 28, 2022

Conversation

matthiashanel
Copy link
Contributor

This subject $SYS.ACCOUNT.%s.SERVER.CONNS will now respond with account
specific datastats for Received and sent messages as well as number of slow
consumers for the account.

Signed-off-by: Matthias Hanel mh@synadia.com

Benchmarks ran are PubSub and Pub0b_Payload 3 times each.
Without then with this change.
The impact seems small enough to prefer the straight forward solution.
If deemed not so, I can try to also delete the server counter and aggregate its value from account based ones.

First set of 3 is without this change.

> go test -v -vet=off -bench='PubSub$' -run=X
goos: darwin
goarch: amd64
pkg: github.com/nats-io/nats-server/v2/test
cpu: Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
Benchmark_____________PubSub
Benchmark_____________PubSub-16    	 5629795	       203.8 ns/op
Benchmark__DenyMsgNoWCPubSub
Benchmark__DenyMsgNoWCPubSub-16    	 5474841	       203.9 ns/op
Benchmark_DenyMsgYesWCPubSub
Benchmark_DenyMsgYesWCPubSub-16    	 5560723	       206.4 ns/op
PASS
ok  	github.com/nats-io/nats-server/v2/test	4.631s
> go test -v -vet=off -bench='PubSub$' -run=X
goos: darwin
goarch: amd64
pkg: github.com/nats-io/nats-server/v2/test
cpu: Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
Benchmark_____________PubSub
Benchmark_____________PubSub-16    	 5586711	       203.5 ns/op
Benchmark__DenyMsgNoWCPubSub
Benchmark__DenyMsgNoWCPubSub-16    	 5466132	       205.7 ns/op
Benchmark_DenyMsgYesWCPubSub
Benchmark_DenyMsgYesWCPubSub-16    	 5449238	       206.3 ns/op
PASS
ok  	github.com/nats-io/nats-server/v2/test	4.617s
> go test -v -vet=off -bench='PubSub$' -run=X
goos: darwin
goarch: amd64
pkg: github.com/nats-io/nats-server/v2/test
cpu: Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
Benchmark_____________PubSub
Benchmark_____________PubSub-16    	 5619054	       204.3 ns/op
Benchmark__DenyMsgNoWCPubSub
Benchmark__DenyMsgNoWCPubSub-16    	 5584328	       205.3 ns/op
Benchmark_DenyMsgYesWCPubSub
Benchmark_DenyMsgYesWCPubSub-16    	 5423282	       208.1 ns/op
PASS
ok  	github.com/nats-io/nats-server/v2/test	4.647s
> go test -v -vet=off -bench="Pub0b_Payload" -run=X
goos: darwin
goarch: amd64
pkg: github.com/nats-io/nats-server/v2/test
cpu: Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
Benchmark______Pub0b_Payload
Benchmark______Pub0b_Payload-16    	15054192	        67.94 ns/op	 161.91 MB/s
Benchmark__AuthPub0b_Payload
Benchmark__AuthPub0b_Payload-16    	 7577354	       149.2 ns/op	  73.72 MB/s
PASS
ok  	github.com/nats-io/nats-server/v2/test	2.818s
> go test -v -vet=off -bench="Pub0b_Payload" -run=X
goos: darwin
goarch: amd64
pkg: github.com/nats-io/nats-server/v2/test
cpu: Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
Benchmark______Pub0b_Payload
Benchmark______Pub0b_Payload-16    	15259664	        67.75 ns/op	 162.37 MB/s
Benchmark__AuthPub0b_Payload
Benchmark__AuthPub0b_Payload-16    	 7556667	       149.9 ns/op	  73.39 MB/s
PASS
ok  	github.com/nats-io/nats-server/v2/test	2.838s
> go test -v -vet=off -bench="Pub0b_Payload" -run=X
goos: darwin
goarch: amd64
pkg: github.com/nats-io/nats-server/v2/test
cpu: Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
Benchmark______Pub0b_Payload
Benchmark______Pub0b_Payload-16    	15028556	        68.19 ns/op	 161.31 MB/s
Benchmark__AuthPub0b_Payload
Benchmark__AuthPub0b_Payload-16    	 7491639	       149.5 ns/op	  73.56 MB/s
PASS
ok  	github.com/nats-io/nats-server/v2/test	2.814s

Second set of 3 is with this change.

> git stash apply
Auto-merging server/events_test.go
Auto-merging server/client.go
On branch main
Your branch is up to date with 'origin/main'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   ../server/accounts.go
	modified:   ../server/client.go
	modified:   ../server/events.go
	modified:   ../server/events_test.go

Untracked files:
  (use "git add <file>..." to include in what will be committed)
	../dist/
	../vendor/

no changes added to commit (use "git add" and/or "git commit -a")
> go test -v -vet=off -bench='PubSub$' -run=X
goos: darwin
goarch: amd64
pkg: github.com/nats-io/nats-server/v2/test
cpu: Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
Benchmark_____________PubSub
Benchmark_____________PubSub-16    	 5527941	       203.8 ns/op
Benchmark__DenyMsgNoWCPubSub
Benchmark__DenyMsgNoWCPubSub-16    	 5517493	       204.6 ns/op
Benchmark_DenyMsgYesWCPubSub
Benchmark_DenyMsgYesWCPubSub-16    	 5486712	       210.7 ns/op
PASS
ok  	github.com/nats-io/nats-server/v2/test	4.712s
> go test -v -vet=off -bench='PubSub$' -run=X
goos: darwin
goarch: amd64
pkg: github.com/nats-io/nats-server/v2/test
cpu: Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
Benchmark_____________PubSub
Benchmark_____________PubSub-16    	 5561923	       204.8 ns/op
Benchmark__DenyMsgNoWCPubSub
Benchmark__DenyMsgNoWCPubSub-16    	 5458404	       204.9 ns/op
Benchmark_DenyMsgYesWCPubSub
Benchmark_DenyMsgYesWCPubSub-16    	 5397844	       205.2 ns/op
PASS
ok  	github.com/nats-io/nats-server/v2/test	4.597s
> go test -v -vet=off -bench='PubSub$' -run=X
goos: darwin
goarch: amd64
pkg: github.com/nats-io/nats-server/v2/test
cpu: Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
Benchmark_____________PubSub
Benchmark_____________PubSub-16    	 5502734	       204.0 ns/op
Benchmark__DenyMsgNoWCPubSub
Benchmark__DenyMsgNoWCPubSub-16    	 5579556	       205.4 ns/op
Benchmark_DenyMsgYesWCPubSub
Benchmark_DenyMsgYesWCPubSub-16    	 5502544	       215.5 ns/op
PASS
ok  	github.com/nats-io/nats-server/v2/test	4.682s
> go test -v -vet=off -bench="Pub0b_Payload" -run=X
goos: darwin
goarch: amd64
pkg: github.com/nats-io/nats-server/v2/test
cpu: Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
Benchmark______Pub0b_Payload
Benchmark______Pub0b_Payload-16    	15086301	        67.56 ns/op	 162.83 MB/s
Benchmark__AuthPub0b_Payload
Benchmark__AuthPub0b_Payload-16    	 7361306	       148.4 ns/op	  74.13 MB/s
PASS
ok  	github.com/nats-io/nats-server/v2/test	2.779s
> go test -v -vet=off -bench="Pub0b_Payload" -run=X
goos: darwin
goarch: amd64
pkg: github.com/nats-io/nats-server/v2/test
cpu: Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
Benchmark______Pub0b_Payload
Benchmark______Pub0b_Payload-16    	15156819	        67.78 ns/op	 162.30 MB/s
Benchmark__AuthPub0b_Payload
Benchmark__AuthPub0b_Payload-16    	 7549778	       148.5 ns/op	  74.09 MB/s
PASS
ok  	github.com/nats-io/nats-server/v2/test	2.810s
> go test -v -vet=off -bench="Pub0b_Payload" -run=X
goos: darwin
goarch: amd64
pkg: github.com/nats-io/nats-server/v2/test
cpu: Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
Benchmark______Pub0b_Payload
Benchmark______Pub0b_Payload-16    	15042363	        67.78 ns/op	 162.28 MB/s
Benchmark__AuthPub0b_Payload
Benchmark__AuthPub0b_Payload-16    	 7392249	       149.7 ns/op	  73.48 MB/s
PASS
ok  	github.com/nats-io/nats-server/v2/test	2.797s
>

Copy link
Member

@derekcollison derekcollison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general LGTM, few minor comments/questions.

server/client.go Outdated Show resolved Hide resolved
server/events.go Show resolved Hide resolved
@derekcollison
Copy link
Member

ok looks good. ping me when you any changes have been pushed.

Copy link
Member

@derekcollison derekcollison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@matthiashanel matthiashanel marked this pull request as ready for review June 14, 2022 17:34
This subject $SYS.ACCOUNT.%s.SERVER.CONNS will now respond with account
specific datastats for Received and sent messages as well as number of slow
consumers for the account.

Signed-off-by: Matthias Hanel <mh@synadia.com>
Signed-off-by: Matthias Hanel <mh@synadia.com>
Signed-off-by: Matthias Hanel <mh@synadia.com>
Signed-off-by: Matthias Hanel <mh@synadia.com>
@derekcollison derekcollison self-requested a review June 21, 2022 23:43
Copy link
Member

@derekcollison derekcollison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@derekcollison
Copy link
Member

Anything else you need before merging?

server/reload.go Outdated Show resolved Hide resolved
Signed-off-by: Matthias Hanel <mh@synadia.com>
@matthiashanel matthiashanel merged commit aba1da0 into main Jun 28, 2022
@matthiashanel matthiashanel deleted the account-conns-stats branch June 28, 2022 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants