danielhumanmod commented on code in PR #1578:
URL: 
https://github.com/apache/datafusion-ballista/pull/1578#discussion_r3172123992


##########
ballista/executor/src/client_pool.rs:
##########
@@ -0,0 +1,352 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Connection pool for `BallistaClient` instances.
+//!
+//! `DefaultBallistaClientPool` maintains a `VecDeque` of idle clients per
+//! `(host, port, config)` key backed by a `DashMap`. Callers 
`BallistaClientPool::acquire`
+//! a `PooledClient` guard; when the guard is dropped the underlying client is
+//! returned to the idle deque automatically.
+//!
+//! Connections could be discarded calling `PooledClient::discard` which will 
result
+//! of dropping connection rather than returning it to the pool. This could be
+//! used for error handling.
+//!
+//! A optional background tokio task evicts idle connections that have not 
been used
+//! within the configured `idle_timeout`.
+
+use async_trait::async_trait;
+use ballista_core::client::BallistaClient;
+use ballista_core::client_pool::{BallistaClientPool, PooledClient};
+use ballista_core::error::Result;
+use ballista_core::extension::BallistaConfigGrpcEndpoint;
+use ballista_core::utils::GrpcClientConfig;
+use dashmap::DashMap;
+use std::collections::VecDeque;
+use std::fmt::Debug;
+use std::sync::{Arc, Weak};
+use std::time::{Duration, Instant};
+
+// ---------------------------------------------------------------------------
+// DefaultBallistaClientPool
+// ---------------------------------------------------------------------------
+
+struct IdleEntry {
+    client: BallistaClient,
+    idle_since: Instant,
+}
+
+type IdleMap = DashMap<(String, u16, GrpcClientConfig), VecDeque<IdleEntry>>;

Review Comment:
   Based on my understanding, the current pool is TTL-based and only evicts 
clients once they have been idle longer than the configured TTL.
   
   One of my two-cent thought: should we also consider a per-endpoint or global 
max idle limit, and evict/drop clients when that limit is reached? That would 
help prevent the pool from retaining too many idle clients after a burst of 
high-concurrency shuffle fetches.
   
   Not a blocker tho, we can also consider adding that if we meet this kind of 
issue
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to