You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What would you like to be added:
The recent update regarding the Deactivate flow of the Client in PR #1036 has highlighted several performance-related issues, documented in the provided DB query and Client connection flow.
Here are the key areas identified for improvement:
Remove duplicate DB resource requests:
There are overlapping DB queries between clients.Deactivate and server.DetachDocument, specifically FindActiveClientInfo and FindDocInfoByRefKey. We need to eliminate these duplicate requests to enhance efficiency.
Optimize DocInfo query within clients.Deactivate:
When multiple documents are attached to a Client, we currently face an N+1 query problem. We should implement a way to fetch the list of documents attached to the Client in a single query to avoid performance degradation.
Improve ChangePack creation logic for p.Clear() operation:
In the current implementation, the server temporarily loads documents to create a ChangePack for presence clear operations. Given that creating documents from a given checkpoint through FindChangesBetweenServerSeqs is resource-intensive, we should explore a method to create the ChangePack more directly, reducing unnecessary DB resource requests.
Refactor clusterClient Connection management:
Currently, a new Client connection is established with each Deactivate call, which incurs substantial overhead. We need to consider ways to minimize this cost and implement appropriate timeout settings related to the connections.
// TODO(hackerwins): Introduce cluster client pool.
// - https://connectrpc.com/docs/go/deployment/
cli, err:=cluster.Dial(be.Config.GatewayAddr)
iferr!=nil {
returnnil, err
}
Why is this needed:
Enhancing the Deactivate flow will improve overall performance, reduce database load, and streamline the Client's lifecycle management, ultimately leading to a more efficient and responsive application.
The text was updated successfully, but these errors were encountered:
I've measured the execution time for each step in the client deactivation process.
This test was run on a client with a single attached document, and while results may vary based on document size, it provides a relative comparison across the steps.
Running locally, we observed the following execution times for a case with a total duration of 150ms:
FindActiveClientInfo, FindDocInfoByRefKey: ~3ms
BuildDocForCheckpoint: 100ms
clusterClient Connection: ~1ms
It’s clear that BuildDocForCheckpoint incurs a relatively higher processing cost compared to the other steps.
What would you like to be added:
The recent update regarding the Deactivate flow of the Client in PR #1036 has highlighted several performance-related issues, documented in the provided DB query and Client connection flow.
Here are the key areas identified for improvement:
Remove duplicate DB resource requests:
There are overlapping DB queries between
clients.Deactivate
andserver.DetachDocument
, specificallyFindActiveClientInfo
andFindDocInfoByRefKey
. We need to eliminate these duplicate requests to enhance efficiency.Optimize
DocInfo
query withinclients.Deactivate
:When multiple documents are attached to a Client, we currently face an N+1 query problem. We should implement a way to fetch the list of documents attached to the Client in a single query to avoid performance degradation.
yorkie/server/clients/clients.go
Lines 68 to 77 in 85aa05e
Improve ChangePack creation logic for
p.Clear()
operation:In the current implementation, the server temporarily loads documents to create a ChangePack for presence clear operations. Given that creating documents from a given checkpoint through
FindChangesBetweenServerSeqs
is resource-intensive, we should explore a method to create the ChangePack more directly, reducing unnecessary DB resource requests.yorkie/server/rpc/cluster_server.go
Lines 96 to 109 in 85aa05e
Refactor clusterClient Connection management:
Currently, a new Client connection is established with each Deactivate call, which incurs substantial overhead. We need to consider ways to minimize this cost and implement appropriate timeout settings related to the connections.
yorkie/server/clients/clients.go
Lines 60 to 65 in 85aa05e
Why is this needed:
Enhancing the Deactivate flow will improve overall performance, reduce database load, and streamline the Client's lifecycle management, ultimately leading to a more efficient and responsive application.
The text was updated successfully, but these errors were encountered: