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

Optimize Minio Client Usage by Reusing Across Requests #429

Closed
mojtaba-esk opened this issue Jun 6, 2024 · 0 comments · Fixed by #434
Closed

Optimize Minio Client Usage by Reusing Across Requests #429

mojtaba-esk opened this issue Jun 6, 2024 · 0 comments · Fixed by #434
Assignees
Labels

Comments

@mojtaba-esk
Copy link
Contributor

Description

Currently, our application creates a new Minio client (miniogo.Client) for each request. This approach can lead to performance inefficiencies due to the overhead associated with repeatedly initializing new clients, especially under high load.

Proposed Change

Refactor the application to instantiate a single Minio client and reuse it across multiple requests. This change aims to reduce initialization overhead and improve overall performance by leveraging connection pooling and reducing setup times.

Benefits

  • Reduced Latency: Minimizes the time spent in client setup for each request.
  • Improved Resource Utilization: Lessens the burden on system resources by reducing the number of client instances.
  • Enhanced Performance: Potentially increases throughput by reusing existing HTTP connections.

Implementation Outline

  1. Create a MinioService struct that includes a miniogo.Client as a field.
  2. Instantiate MinioService at application startup with a single Minio client.
  3. Refactor existing code to use the Minio client from MinioService instead of creating new instances.

Code Snippet

type MinioService struct {
    Client miniogo.Client
}
func NewMinioService(endpoint, accessKey, secretKey string) (MinioService, error) {
    cli, err := miniogo.New(endpoint, &miniogo.Options{
        Creds: credentials.NewStaticV4(accessKey, secretKey, ""),
        Secure: false,
})
if err != nil {
   return nil, err
}
return &MinioService{
       Client: cli,
    }, nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant