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

SQSclient http issue under highload #1438

Closed
Lapeno94 opened this issue Oct 28, 2019 · 6 comments
Closed

SQSclient http issue under highload #1438

Lapeno94 opened this issue Oct 28, 2019 · 6 comments

Comments

@Lapeno94
Copy link

SQS client cause socket exceptions under high load in .net core.

Expected Behavior

Sqsclient should able to manage the httpclient lifetime with the applications.

Resused the httpclients and not consume all of the ports. 8124

Current Behavior

Clientconfig httpclient factory is null. Therefore no disposable httpclients. Cache is increasing to the maximum.

Possible Solution

    public class SqsHttpClientFactory : Amazon.Runtime.HttpClientFactory
    {
        private readonly IHttpClientFactory _httpClientFactory;

        public SqsHttpClientFactory(IHttpClientFactory httpClientFactory)
        {
            _httpClientFactory = httpClientFactory;
        }

        public override HttpClient CreateHttpClient(IClientConfig clientConfig)
        {
            return _httpClientFactory.CreateClient();
        }
    }
            services.AddAWSService<IAmazonSQS>();
            services.AddSingleton<IAmazonSQS>(x => new AmazonSQSClient(new AmazonSQSConfig
            {
                HttpClientFactory = new SqsHttpClientFactory(x.GetRequiredService<IHttpClientFactory>())
            }));

Steps to Reproduce (for bugs)

Create ecs fargate cluster. Run a task where the container runs a .net core app on linux.

Context

Services goes against high load. Not supports the SLAs which are defined for sqs.

Are you sure about the http a best protocol for messaging?

Your Environment

  • AWSSDK.Core version used: newest
    Ecs Fargate via linux containers.

.NET Core Info

  • .NET Core version used for development: 2.2
  • .NET Core version installed in the environment where application runs: 2.2
@klaytaybai klaytaybai added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Oct 29, 2019
@klaytaybai
Copy link
Contributor

What do you have set in the client config around this topic? Is CacheHttpClient true?

@Lapeno94
Copy link
Author

Lapeno94 commented Oct 29, 2019

Yes I am using .net core. I think the problem could be the targeting. (Using .net standart 1.3 and not the 2.0 httpclient)
public abstract class HttpClientFactory
{
///


/// Create and configure an HttpClient.
///

///
public abstract HttpClient CreateHttpClient(IClientConfig clientConfig);

        /// <para>
        /// This is a switch used for performance testing and is not intended for production applications 
        /// to change. This switch may be removed in a future version of the SDK as the .NET Core platform matures.
        /// </para>
        /// <para>
        /// If true, the HttpClient is cached and reused for every request made by the service client 
        /// and shared with other service clients.
        /// </para>
        /// <para>
        /// For the .NET Core platform this is default to true because the HttpClient manages the connection
        /// pool.
        /// </para>
        /// </summary>
        bool CacheHttpClient { get; }```

@klaytaybai klaytaybai removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Nov 18, 2019
@chillbilly79
Copy link

I am also having this issue. Is there a suggested way to use the SQSClient without consuming all the connections?

@Lapeno94
Copy link
Author

I spoke with the aws support through my company, and they wont solve it,bc there is workaround for it.
What I mentioned above. SqsHttpClientFactory with asp.net core httpclientfactory
pros.: solve the issue
cons: asyncblock the client (if u want to consume and produce) So everything which is could be event-sourcing

#565

Implementation guide:
https://www.stevejgordon.co.uk/httpclient-connection-pooling-in-dotnet-core

same issues:
#1339
#971

@ashishdhingra ashishdhingra added bug This issue is a bug. module/sdk-core needs-triage This issue or PR still needs to be triaged. labels Aug 7, 2020
@ashishdhingra ashishdhingra added B and removed needs-triage This issue or PR still needs to be triaged. labels Oct 6, 2020
@KevinThomas1712
Copy link

This was really useful for adding poly policies and using reflection for adding tests. Thanks.

@github-actions
Copy link

We have noticed this issue has not received attention in 1 year. We will close this issue for now. If you think this is in error, please feel free to comment and reopen the issue.

@github-actions github-actions bot added closing-soon This issue will automatically close in 4 days unless further comments are made. closed-for-staleness and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels Jun 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants