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

#632: Feature: KeepAlive and Timeout Support mechanism #1052

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

Dev79844
Copy link
Contributor

@Dev79844 Dev79844 commented Oct 10, 2024

Issue: #632

Summary:
Added timeouts and keep alive mechanism for workers.

Changes:
Added client and connection in worker struct
Added functions related to keep alive and timeouts in workers.go

@@ -419,3 +457,28 @@ func (w *BaseWorker) Stop() error {
w.Session.Expire()
return nil
}

func (w *BaseWorker) updateLastActivity() {
w.lastActivityMux.Lock()
Copy link
Contributor

Choose a reason for hiding this comment

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

On each event on channels we're taking locks, I believe this would affect the performance adversely.
Can you please add some before/after benchmarks?
cc: @soumya-codes / @AshwinKul28 please add your inputs on this.

Copy link
Contributor Author

@Dev79844 Dev79844 Oct 11, 2024

Choose a reason for hiding this comment

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

Hey @lucifercr07
Should I write a benchmark for start method with locks and without locks in updateLastActivity function?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, ideally we should analyse the perf impact.
cc: @soumya-codes @AshwinKul28 thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok. Will add those benchmarks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey @lucifercr07
Can you guide me on how can I mock the base worker in benchmark?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hello @lucifercr07
I have ran the benchmarks with and without locks in the updateActivityMethod.

With lock:
Screenshot 2024-11-14 at 9 10 44 AM

Without lock:
Screenshot 2024-11-14 at 9 11 13 AM

@soumya-codes
Copy link
Contributor

@Dev79844 we already have the timeout capability added to the connection instance itself.
Please check here.
https://github.com/DiceDB/dice/blob/master/internal/clientio/iohandler/netconn/netconn.go#L100

Can we figure out similar way to add keepalive?

@Dev79844
Copy link
Contributor Author

Hey @soumya-codes
As far as I understand the design, since each worker manages a client connection, the keep alive should be kept around a worker. Connection timeout is handled by the connection itself so I think keep alive should be managed by the worker itself. Would like to know your thoughts about this?

@Dev79844
Copy link
Contributor Author

Hey @lucifercr07 @soumya-codes @apoorvyadav1111
I have added a basic code for bencmarking start method but I am not sure if it is correct. It would be great if you can provide feedback.

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.

3 participants