Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3995,7 +3995,7 @@ namespace Akka.IO
}
public class Bind : Akka.IO.Tcp.Command
{
public Bind(Akka.Actor.IActorRef handler, System.Net.EndPoint localAddress, int backlog = 100, System.Collections.Generic.IEnumerable<Akka.IO.Inet.SocketOption> options = null, bool pullMode = False) { }
public Bind(Akka.Actor.IActorRef handler, System.Net.EndPoint localAddress, int backlog = 1024, System.Collections.Generic.IEnumerable<Akka.IO.Inet.SocketOption> options = null, bool pullMode = False) { }

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Significantly increased the default backlog to a much more reasonable 1024, which is the default in Akka.Remote.

public int Backlog { get; }
public Akka.Actor.IActorRef Handler { get; }
public System.Net.EndPoint LocalAddress { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3985,7 +3985,7 @@ namespace Akka.IO
}
public class Bind : Akka.IO.Tcp.Command
{
public Bind(Akka.Actor.IActorRef handler, System.Net.EndPoint localAddress, int backlog = 100, System.Collections.Generic.IEnumerable<Akka.IO.Inet.SocketOption> options = null, bool pullMode = False) { }
public Bind(Akka.Actor.IActorRef handler, System.Net.EndPoint localAddress, int backlog = 1024, System.Collections.Generic.IEnumerable<Akka.IO.Inet.SocketOption> options = null, bool pullMode = False) { }
public int Backlog { get; }
public Akka.Actor.IActorRef Handler { get; }
public System.Net.EndPoint LocalAddress { get; }
Expand Down
10 changes: 3 additions & 7 deletions src/core/Akka.Tests/IO/TcpListenerSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ class TestSetup
private readonly IActorRef _handlerRef;
private readonly TestProbe _bindCommander;
private readonly TestProbe _parent;
private readonly TestProbe _selectorRouter;
private readonly TestActorRef<ListenerParent> _parentRef;

public TestSetup(TestKitBase kit, bool pullMode)
Expand All @@ -87,7 +86,7 @@ public TestSetup(TestKitBase kit, bool pullMode)
_handlerRef = _handler.Ref;
_bindCommander = kit.CreateTestProbe();
_parent = kit.CreateTestProbe();
_selectorRouter = kit.CreateTestProbe();
SelectorRouter = kit.CreateTestProbe();

_parentRef = new TestActorRef<ListenerParent>(kit.Sys, Props.Create(() => new ListenerParent(this, pullMode)));
}
Expand Down Expand Up @@ -115,10 +114,7 @@ public async Task AttemptConnectionToEndpoint()

public IActorRef Listener { get { return _parentRef.UnderlyingActor.Listener; } }

public TestProbe SelectorRouter
{
get { return _selectorRouter; }
}
public TestProbe SelectorRouter { get; }

public TestProbe BindCommander { get { return _bindCommander; } }
public TestProbe Parent { get { return _parent; } }
Expand All @@ -128,7 +124,7 @@ public TestProbe SelectorRouter
internal void AfterBind(Socket socket)
=> LocalEndPoint = (IPEndPoint)socket.LocalEndPoint;

class ListenerParent : ActorBase
private class ListenerParent : ActorBase
{
private readonly TestSetup _test;
private readonly bool _pullMode;
Expand Down
42 changes: 42 additions & 0 deletions src/core/Akka.Tests/IO/TcpSettingsSpec.cs

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a spec to validate the TcpSettings from HOCON configuration

Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//-----------------------------------------------------------------------
// <copyright file="TcpSettingsSpec.cs" company="Akka.NET Project">
// Copyright (C) 2009-2022 Lightbend Inc. <http://www.lightbend.com>
// Copyright (C) 2013-2025 .NET Foundation <https://github.com/akkadotnet/akka.net>
// </copyright>
//-----------------------------------------------------------------------

using System;
using Akka.Actor;
using Akka.Configuration;
using Akka.IO;
using FluentAssertions;
using Xunit;

namespace Akka.Tests.IO
{
public class TcpSettingsSpec
{
[Fact]
public void TcpSettings_should_parse_all_akka_io_tcp_config_values_correctly()
{
// Arrange: load the default reference config
var config = ConfigurationFactory.Default();
var tcpConfig = config.GetConfig("akka.io.tcp");
var settings = TcpSettings.Create(tcpConfig);

// Assert: all values match akka.conf reference
settings.BufferPoolConfigPath.Should().Be("akka.io.tcp.disabled-buffer-pool");
settings.InitialSocketAsyncEventArgs.Should().Be(32);
settings.TraceLogging.Should().BeFalse();
settings.BatchAcceptLimit.Should().Be(Environment.ProcessorCount * 2);
settings.RegisterTimeout.Should().Be(TimeSpan.FromSeconds(5));
settings.ReceivedMessageSizeLimit.Should().Be(int.MaxValue);
settings.ManagementDispatcher.Should().Be("akka.actor.internal-dispatcher");
settings.FileIODispatcher.Should().Be("akka.actor.default-blocking-io-dispatcher");
settings.TransferToLimit.Should().Be(524288); // 512 KiB
settings.FinishConnectRetries.Should().Be(5);
settings.OutgoingSocketForceIpv4.Should().BeFalse();
settings.WriteCommandsQueueMaxSize.Should().Be(-1);
}
}
}
7 changes: 5 additions & 2 deletions src/core/Akka/Configuration/akka.conf
Original file line number Diff line number Diff line change
Expand Up @@ -763,8 +763,11 @@ akka {

# The maximum number of connection that are accepted in one go,
# higher numbers decrease latency, lower numbers increase fairness on
# the worker-dispatcher
batch-accept-limit = 10
# the worker-dispatcher.
#
# By default we scale to logical CPUs * 2, but you can set this to an
# integer value greater than 0.
batch-accept-limit = scale-to-cpus

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our default is going to be "scale SAEA to the CPUs"


# The duration a connection actor waits for a `Register` message from
# its commander before aborting the connection.
Expand Down
4 changes: 2 additions & 2 deletions src/core/Akka/IO/Tcp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,12 @@ public class Bind : Command
/// </summary>
/// <param name="handler">The actor who will be handling the TCP listener.</param>
/// <param name="localAddress">The local endpoint we are binding to.</param>
/// <param name="backlog">TCP backlog - the number of pending connections that the queue will hold.</param>
/// <param name="backlog">TCP backlog - the number of pending connections that the queue will hold. Defaults to 1024.</param>
/// <param name="options">A set of socket options.</param>
/// <param name="pullMode">Specifies whether we're running in "pull mode" or not.</param>
public Bind(IActorRef handler,
EndPoint localAddress,
int backlog = 100,
int backlog = 1024,
IEnumerable<Inet.SocketOption> options = null,
bool pullMode = false)
{
Expand Down
Loading
Loading