Skip to content
This repository was archived by the owner on Aug 18, 2021. It is now read-only.
This repository was archived by the owner on Aug 18, 2021. It is now read-only.

Correctly use HttpClient instances across the entire framework #20

Open
@guilhermeluizsp

Description

@guilhermeluizsp

HttpClient is intended to be reused as much as possible throughout the entire application.
Internally, it uses an object of type HttpClientHandler, which actually makes the HTTP requests. By default, even when disposed, the underlying socket will not be immediately released, keeping them with the TIME_WAIT state. When in TIME_WAIT, the socket cannot be reused, and under heavy loading it can cause a socket exhaustion, preventing the system from making more requests (for a limited amount of time).

LightAPI uses an instance of HttpClient under the hood, obviously using one instance for each LightAPI instance.
As it doesn't change the default implementation of HttpClientHandler, we will inevitably face the problem above.

To fix this problem, Microsoft created a library called HttpClientFactory, which managed the creation of HttpClient instances and their HttpClientHandler's.

The Liquid Framework should use this library by default when dealing with HttpClient-based requests.

HttpClientFactory can also be extended. By default, it has options for setting up resilient requests for every HttpClient created (the same thing as LightAPI does, and it also uses Polly)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcomplexity:highThe complexity of the issue is highsize:largeThe size of the issue is large

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions