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

Enhancements for the ChannelPool #35

Open
2 tasks
ccbond opened this issue Apr 24, 2023 · 5 comments
Open
2 tasks

Enhancements for the ChannelPool #35

ccbond opened this issue Apr 24, 2023 · 5 comments

Comments

@ccbond
Copy link

ccbond commented Apr 24, 2023

Background:

ChannelPool is a struct for managing gRPC client connections, providing basic connection pooling functionality. While it already offers some useful features, there are potential improvements and extensions that could further enhance performance, stability, and maintainability.

Proposed Features:

  • Maximum Connection Limit: To prevent creating too many simultaneous connections, consider adding a maximum connection limit to the ChannelPool struct. Concurrent connection creation can be controlled using a Semaphore or other concurrency control structures.

  • Connection Expiration: Add an expiration time for each connection in the ChannelPool. Connections exceeding this duration would be automatically closed, ensuring connections don't remain open indefinitely.

I chose to implement these two features because they can significantly improve performance and reduce resource usage. Additionally, these features lay the groundwork for future improvements.
There are also any other features about ChannelPool, for example :

  • Smarter Connection Recycling Strategy: The current implementation simply discards connections when they encounter errors. Implement a smarter recycling strategy, such as deciding when to close connections based on their usage frequency or idle time.

  • Connection Health Checks: Perform periodic health checks on connections to ensure that the connections in the pool are still functional. If unhealthy connections are discovered, remove them from the pool and create new connections as needed.

  • Connection Load Balancing: If connecting to a service with multiple backend instances, consider implementing connection load balancing. Choose between round-robin, least connections, or other load balancing strategies based on connection usage.

  • Detailed Error Handling and Logging: For easier debugging and troubleshooting, consider adding more detailed error handling and logging within the code.

  • Generics: The current implementation of the with_channel method requires a function returning a Result<T, Status>. Consider using a generic error type to make it more adaptable to different error handling requirements.

@willianfonseca
Copy link

Hey, @ccbond can I take this one?

@ccbond
Copy link
Author

ccbond commented Jul 3, 2023

Hey, @ccbond can I take this one?

yes!

@Doordashcon
Copy link

Hello @willianfonseca are you still working on this?

@Doordashcon
Copy link

Doordashcon commented Aug 26, 2023

Hello @ccbond would like to pick this up?

@Doordashcon
Copy link

@ccbond after going through src/channel.rs

I fail to see the scenario where multiple channels can be created. The public methods available are with_channel(), drop_channel() and the associative function new(...) or am I missing something here?

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

3 participants