Too many TCP connections established
See original GitHub issueWhen I conduct the concurrent test of Minio, I find that if I upload files concurrently, a lot of TCP connections will be established and will not be released。 My test code is as follows: ` static void Main(string[] args) {
try
{
Run().Wait();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
Console.ReadLine();
}
private static async Task Run()
{
// Make a new bucket called mymusic.
var bucketName = "testsize"; //<==== change this
var location = "us-east-1";
var filePath = @"C:\Users\admin\Desktop\c143a9bc-be71-4475-9981-3c0d8f60d7f5";
var contentType = "application/octet-stream";
var endpoint = "192.168.1.14:9000";
var accessKey = "minioadmin";
var secretKey = "minioadmin";
try
{
//FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read);
var minio = new MinioClient(endpoint, accessKey, secretKey);
bool found = await minio.BucketExistsAsync(bucketName);
if (!found)
{
await minio.MakeBucketAsync(bucketName, location);
}
Console.WriteLine("10万个文件上传开始~~~~" + DateTime.Now);
Stopwatch stopwatch = Stopwatch.StartNew();
await Task.WhenAll(Enumerable.Range(0, 100_000)
.Select(_ => Task.Run(async () =>
{
//fileStream.Position = 0;
await minio.PutObjectAsync(bucketName, Guid.NewGuid().ToString("N"), filePath, contentType);
}))).ConfigureAwait(false);
stopwatch.Stop();
Console.WriteLine("10万个文件上传结束~~~~" + DateTime.Now);
Console.WriteLine("总共用时" + stopwatch.ElapsedMilliseconds / 1000 / 60 + "分钟");
//fileStream.Dispose();
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
`
At this time, I run the test code and view the TCP link through the tcpview tool。
Found that the TCP connection has been established and has not been released。At this time, the CPU of my local computer has gone up to 100%。
By looking at the source code, it is found that when communicating, the application is made by csharprest, and a method that has been abandoned is used. I don’t know if this is the reason。
the code like this
private async Task<IRestResponse> ExecuteTaskCoreAsync(IEnumerable<ApiResponseErrorHandlingDelegate> errorHandlers, IRestRequest request, CancellationToken cancellationToken = default(CancellationToken)) { ... //It's abandoned IRestResponse response = await this.restClient.ExecuteTaskAsync(request, cancellationToken).ConfigureAwait(false); ... }
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (3 by maintainers)
Fixed by #551 … and by #582
Hi @harshavardhana ,I tested the
RestSharp
components separately, and found that the problem of TCP leakage was caused by the HTTP component used. I tried to submit an issue to the official, hoping to solve it! https://github.com/restsharp/RestSharp/issues/1461