-
Notifications
You must be signed in to change notification settings - Fork 65
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
Make pubsub optional #415
Make pubsub optional #415
Conversation
Signed-off-by: Anton Dort-Golts <dortgolts@gmail.com>
Signed-off-by: Anton Dort-Golts <dortgolts@gmail.com>
7c30999
to
b18a678
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for jumping in here! I left a couple comments around semantics, otherwise LGTM.
common/common.go
Outdated
@@ -180,6 +182,13 @@ func WithNetGRPCOptions(opts ...grpc.ServerOption) NetOption { | |||
} | |||
} | |||
|
|||
func WithPubSubDisabled() NetOption { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about WithNetPubsub
, and when setting up NetConfig
, set PubSub
to true by default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opps, I forgot NetConfig
is public. In any case, given your findings, I'm fine with letting pubsub be off by default. So, same comment as before around semantics, but no need to have PubSub
true by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(We can do a minor version bump)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, now it looks more consistent.
common/common.go
Outdated
ConnManager cconnmgr.ConnManager | ||
Debug bool | ||
GRPCOptions []grpc.ServerOption | ||
PubSubDisabled bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To go along with the comment below, this would just be PubSub
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
// If this is just a public key, the service itself won't be able to create records. | ||
// In other words, all records must be pre-created and added with AddRecord. | ||
// If no log key is provided, one will be created internally. | ||
func WithNewLogKey(key crypto.Key) NewOption { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! For some reason I assumed this wouldn't be desired at the DB level.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It actually slipped into the PR, but anyway we have db failures without it.
Signed-off-by: Anton Dort-Golts <dortgolts@gmail.com>
common/common.go
Outdated
@@ -180,6 +182,13 @@ func WithNetGRPCOptions(opts ...grpc.ServerOption) NetOption { | |||
} | |||
} | |||
|
|||
func WithNetPubSub() NetOption { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more nit: Can you make this more like the debug option that makes using an upstream bool
a little nicer, as in: WithNetPubSub(enabled bool)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
Signed-off-by: Anton Dort-Golts <dortgolts@gmail.com>
Looks like test failures from pubsub not being default. Can you
|
Signed-off-by: Anton Dort-Golts <dortgolts@gmail.com>
Maybe it's better to make a major version bump as it changes default behavior? |
Yeah, good idea. Do you need a release right away? |
No, it's not urgent. |
* NewDB: add the option to pass logKey Signed-off-by: Anton Dort-Golts <dortgolts@gmail.com> * Feature: optionally disable pubsub Signed-off-by: Anton Dort-Golts <dortgolts@gmail.com> * Change option semantics and disable pubsub by default Signed-off-by: Anton Dort-Golts <dortgolts@gmail.com> * Use explicit flag in pubsub option Signed-off-by: Anton Dort-Golts <dortgolts@gmail.com> * Fix: use NetOption to explicitly enable pubsub Signed-off-by: Anton Dort-Golts <dortgolts@gmail.com> Co-authored-by: requilence <requilence@gmail.com>
Running nodes for some time we've detected that pubsub mechanism combined with threads may produce a lot of unneccesary traffic.
Assuming that every thread has corresponding topic propagated through the pubsub, long-running high-degree nodes accumulate a lot of topics during its lifetime. When some other node establishes connection, it will respond with a huge hello-packet, containing all the topics seen so far, mostly irrelevant to the caller.
Taking into account that pubsub is in fact a secondary channel of event propagation, we can alleviate the problem by making it optional. Pubsub stays enabled by default, so the change won't affect any existing setup, and there is a new NetOption allowing to disable pubsub subsystem in threads completely.