Skip to content

[Performance] Reuse clients for better performance #98

@alukach

Description

@alukach

In #95, we refactored the Source API code to persist the reqwest::Client across requests, taking advantage of connection pooling.

The same logic should be applied when creating clients on our S3 interface code (I currently see 11 instances of client creation):

let client = reqwest::Client::new();

let client = self.create_client()?;

(etc...)

Note that this will be a bit more involved than #95 as the S3Repository and AzureRepository isn't currently persisted across requests in the manner that the SourceApi is. The repositories are created on each call to api_client.get_backend_client():

Ok(Box::new(S3Repository {
account_id: account_id.to_string(),
repository_id: repository_id.to_string(),
region,
bucket,
base_prefix: prefix,
auth_method: auth.auth_type,
access_key_id: auth.access_key_id,
secret_access_key: auth.secret_access_key,
}))
}
"az" => {
let account_name: String = data_connection
.details
.account_name
.clone()
.unwrap_or_default();
let container_name: String = data_connection
.details
.container_name
.clone()
.unwrap_or_default();
let base_prefix: String = data_connection
.details
.base_prefix
.clone()
.unwrap_or_default();
Ok(Box::new(AzureRepository {
account_id: account_id.to_string(),
repository_id: repository_id.to_string(),
account_name,
container_name,
base_prefix: format!("{}{}", base_prefix, repository_data.prefix),
}))

While the SourceApi is created just once at application startup:

let source_api = web::Data::new(SourceApi::new(
source_api_url,
source_api_key,
source_api_proxy_url,
));

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions