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

Support show bytes sent/received on the connection #627

Open
lance6716 opened this issue Nov 29, 2022 · 8 comments
Open

Support show bytes sent/received on the connection #627

lance6716 opened this issue Nov 29, 2022 · 8 comments

Comments

@lance6716
Copy link
Contributor

Due to some billing requirements, I want to know how many bytes this client sent/received with TiKV. Currrently I want to wrap a net.Conn with customized Read Write method to add the IO byte number to an atomic variable, like

https://github.com/pingcap/tiflow/blob/7f27730235f94859692b9da561f50c491e483427/dm/syncer/dbconn/utils.go#L102-L127

Is this OK? can you give some advice

@lance6716
Copy link
Contributor Author

@Defined2014 @xiongjiwei ptal

@Defined2014
Copy link
Contributor

Is this added to every TCP connection? Will it be too heavy to add atomic variables here which have a big impact on performance?

@lance6716
Copy link
Contributor Author

Is this added to every TCP connection? Will it be too heavy to add atomic variables here which have a big impact on performance?

It should be an option like WithDialer or something, but when it enables, all connections to the endpoint should use the atomic counter.

And I think the performance is not a big problem, because IO duration is much higher than atomic operations

@sticnarf
Copy link
Collaborator

It sounds okay but I'm not sure whether it is a better idea to count at upper layers for more flexibility. If one client could support multiple tenants, counting bytes by connection may be not enough.

@Defined2014
Copy link
Contributor

It sounds okay but I'm not sure whether it is a better idea to count at upper layers for more flexibility. If one client could support multiple tenants, counting bytes by connection may be not enough.

Agree. Do you have a spec about this requirement? I am not fully understand about this feature.

According to my understanding, a TiDB-Server may only have one tenant, do we need to count traffic by TCP connection, maybe by instance is enough (not sure)?.

@lance6716
Copy link
Contributor Author

lance6716 commented Nov 29, 2022

As my plan, it's used by lightning to import data to tikv. We want to know the network IO of this import task

@sticnarf
Copy link
Collaborator

sticnarf commented Nov 29, 2022

Is precision so important that we must wrap the connection? The protobuf bytes or the bytes you just want to import (oh it will) don't seem to differ a lot from the real IO bytes 🤔

@disksing
Copy link
Collaborator

Is precision so important that we must wrap the connection? The protobuf bytes or the bytes you just want to import (oh it will) don't seem to differ a lot from the real IO bytes 🤔

good point. I'm thinking of another example: if there are problems with environment and lead to network reconnection or data retransmission, we should not charge users for it.

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

No branches or pull requests

4 participants