Skip to content

feat: Cache ballista clients on executor - #1578

Merged
milenkovicm merged 12 commits into
apache:mainfrom
milenkovicm:feat_pooled_clients
May 5, 2026
Merged

feat: Cache ballista clients on executor#1578
milenkovicm merged 12 commits into
apache:mainfrom
milenkovicm:feat_pooled_clients

Conversation

@milenkovicm

@milenkovicm milenkovicm commented Apr 26, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Closes #736.

Rationale for this change

As mentioned in #1388 (comment), we might run out of available ports to establish new remote connections. Furthermore, connection establishment can sometimes be costly, such as during a TLS handshake. Therefore, we need a mechanism to cache established connections.

What changes are included in this PR?

  • A new pluggable trait BallistaClientPool allows for different client caching strategies.
  • DefaultBallistaClientPool implementation

DefaultBallistaClientPool does not use GRPC channel "clone and use" as it might be harder to configure property, hence pool may have one or more cached connections for same endpoint.

Are there any user-facing changes?

Change is NOT backward compatible for implementors of custom executors.

At the moment client pool is disabled, executors behave same like before. To enable it executors should be started with --connection-cache option

cargo run --bin ballista-executor -- --connection-cache 30

After trail period we will make caching default.

TODO:

  • provide a way to disable purging thread
  • wire up with executor (expose pool configuration on executor side)

Note: this change supersedes #1388

@milenkovicm
milenkovicm force-pushed the feat_pooled_clients branch from 03513f4 to fc5ac1a Compare April 26, 2026 16:50
@milenkovicm milenkovicm changed the title feat: Support cacheing remote shuffle reader clients in executor. feat: Support caching remote shuffle reader clients in executor. Apr 26, 2026
@milenkovicm
milenkovicm force-pushed the feat_pooled_clients branch 2 times, most recently from 0df68d7 to e5ec6ee Compare April 26, 2026 20:06
@milenkovicm milenkovicm changed the title feat: Support caching remote shuffle reader clients in executor. feat: Support caching remote shuffle reader clients Apr 26, 2026
@milenkovicm
milenkovicm force-pushed the feat_pooled_clients branch from e5ec6ee to 6b2e375 Compare April 27, 2026 08:37
@milenkovicm milenkovicm changed the title feat: Support caching remote shuffle reader clients feat: Cache remote shuffle reader clients on executor Apr 27, 2026

@andygrove andygrove left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Really like the direction here. Caching shuffle clients should make a big difference for clusters that hit a lot of executors. Left a few inline thoughts.

Comment thread ballista/executor/src/executor.rs
Comment thread ballista/core/src/execution_plans/shuffle_reader.rs
Comment thread ballista/core/src/client_pool.rs Outdated
Comment thread ballista/core/src/client_pool.rs Outdated
Comment thread ballista/core/src/client_pool.rs Outdated
Comment thread ballista/executor/src/config.rs Outdated
Comment thread ballista/core/src/client_pool.rs Outdated
Comment thread ballista/core/Cargo.toml Outdated
@milenkovicm milenkovicm changed the title feat: Cache remote shuffle reader clients on executor feat: Cache ballista clients on executor Apr 28, 2026
@milenkovicm
milenkovicm marked this pull request as ready for review April 28, 2026 17:09
@milenkovicm
milenkovicm requested a review from andygrove April 28, 2026 17:10
@milenkovicm

Copy link
Copy Markdown
Contributor Author

@martin-g @danielhumanmod @sandugood it would be great if you could review this change. thanks a lot

/// creates a ballista client to be used for testing
/// it connects lazily and which can not really
/// be reconfigured.
pub fn new_for_test(host: &str, port: u16) -> Self {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There is no #[cfg(test)].
Does it need to be here ? It could be a helper method in mod tests too

@milenkovicm milenkovicm Apr 29, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It should but apparently it does not work across different crates, or I'm doing something wrong

Comment thread ballista/executor/src/client_pool.rs
Comment thread ballista/core/src/execution_plans/shuffle_reader.rs Outdated
Comment thread ballista/executor/src/client_pool.rs Outdated
Comment thread ballista/executor/src/client_pool.rs Outdated
Comment thread ballista/executor/src/client_pool.rs Outdated
});

let weak: Weak<Inner> = Arc::downgrade(&inner);
// TODO: do we limit minimum interval here?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since we add this in the user-facing config:
If the user sets the client_ttl in the (1, 45) range it will be transformed into 15. Maybe add a warning when user sets this value in the config and it is in the (1, 45) range?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

maybe it would make sense to have warning for ttl < 15 but then there would be a bit of explaining needed.
i was thinking to add it to cli help, but this is implementation specific as well.
I'd propose to keep it as it is and add it later if needed

@milenkovicm
milenkovicm requested a review from martin-g April 29, 2026 19:58
@andygrove

Copy link
Copy Markdown
Member

Thanks @milenkovicm. I will try and start reviewing this one tonight.

@milenkovicm
milenkovicm force-pushed the feat_pooled_clients branch from 7477071 to 85b99b8 Compare April 29, 2026 20:48
Comment thread ballista/executor/src/client_pool.rs
Comment thread ballista/core/src/client_pool.rs Outdated
config: &GrpcClientConfig,
customize_endpoint: Option<Arc<BallistaConfigGrpcEndpoint>>,
) -> Result<PooledClient> {
let key = (host.to_string(), port, config.clone());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

key is missing customize_endpoint?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Customise endpoint is compile time, it should not change. I propose it ignore it for now

Comment thread ballista/executor/src/execution_engine.rs Outdated
Comment thread ballista/core/src/lib.rs Outdated
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.

[Shuffle] Support cache remote shuffle reader client in executor.

5 participants