Assume you have an SF application with 20 microservices running on the same node.
And each of these microservice writes 1000 datapoints every 2 seconds. Windows OS has default setting [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\ Services\Tcpip\ Parameters\ TcpTimedWaitDelay] 240 seconds. Eventually, you will experience TCP port exhaustion.
private async Task SendInternalAsync(ICollection<Datapoint> datapoints, CancellationToken cancellationToken)
{
TcpClient client;
if (UseDualStack)
{
**client = new TcpClient(AddressFamily.InterNetworkV6) {Client = {DualMode = true}};**
}
else
{
**client = new TcpClient();**
}
using (client)
{
await client.ConnectAsync(Host, Formatter.Port).ConfigureAwait(false);
cancellationToken.ThrowIfCancellationRequested();
using (var stream = client.GetStream())
{
await Formatter.WriteAsync(stream, datapoints, cancellationToken).ConfigureAwait(false);
}
}
}