### Run RPC Benchmark Server Source: https://github.com/actuallab/fusion.samples/blob/master/docs/rpc-benchmark.md Command to start the RPC benchmark server. Ensure this is run before starting client tests. ```bash Run-RpcBenchmark-Server.cmd ``` -------------------------------- ### Start RPC Benchmark Server with Core Constraint Source: https://github.com/actuallab/fusion.samples/blob/master/docs/rpc-benchmark.md Starts the RPC benchmark server and pins it to the first N CPU cores. The default is 6 cores. ```bash Run-RpcBenchmark-Server.cmd ``` -------------------------------- ### Global Usings Example Source: https://github.com/actuallab/fusion.samples/blob/master/CODING_STYLE.md Demonstrates how global usings can be declared in Directory.Build.props files. Avoid explicit usings for these globally declared namespaces. ```xml ``` -------------------------------- ### Run Fusion Samples Locally Source: https://github.com/actuallab/fusion.samples/blob/master/README.md Build and run the Fusion samples locally using the .NET SDK. Ensure you have the .NET 10 SDK installed. ```bash dotnet build dotnet run ``` -------------------------------- ### Run RPC Benchmark Client with Server Core Constraint (Example) Source: https://github.com/actuallab/fusion.samples/blob/master/docs/rpc-benchmark.md Executes the RPC benchmark client with specific options, including a wait flag and defined worker and concurrency counts, against a server constrained to 6 cores. ```bash Run-RpcBenchmark-Client.cmd -wait -cc 100 -w 10000 ``` -------------------------------- ### RPC API Interface Example Source: https://github.com/actuallab/fusion.samples/blob/master/CODING_STYLE.md Illustrates the recommended ordering for methods in an RPC API interface, with read methods (ComputeMethod) preceding write methods (CommandHandler). ```csharp public interface IMediaBackend : IComputeService, IBackendService { [ComputeMethod] Task Get(MediaId? mediaId, CancellationToken cancellationToken); [ComputeMethod] Task GetByMediaIdScope(string mediaIdScope, CancellationToken cancellationToken); [ComputeMethod] Task GetByContentId(string contentId, CancellationToken cancellationToken); [CommandHandler] Task OnChange(MediaBackend_Change command, CancellationToken cancellationToken); [CommandHandler] Task OnCopyChat(MediaBackend_CopyChat command, CancellationToken cancellationToken); } ``` -------------------------------- ### Class Member Ordering Example Source: https://github.com/actuallab/fusion.samples/blob/master/CODING_STYLE.md Demonstrates the recommended order for members within a C# class, including static fields, injected services, read methods, write methods, and private helpers. ```csharp public class Chats(IServiceProvider services) : IChats { // 1. Static fields public static readonly TileStack ServerIdTileStack = Constants.Chat.ServerIdTileStack; // 2. Dependency-injected services private IAccounts Accounts { get; } = services.GetRequiredService(); private IPlaces Places => field ??= services.GetRequiredService(); private ICommander Commander { get; } = services.Commander(); private ILogger Log { get; } = services.LogFor(); // 3. Public read methods (e.g., compute methods) public virtual async Task Get(Session session, ChatId chatId, CancellationToken cancellationToken) { /* ... */ } // 4. Public write methods (e.g., command handlers) // [CommandHandler] public virtual async Task OnChange(Chats_Change command, CancellationToken cancellationToken) { /* ... */ } // Protected methods // 5. Protected/internal methods [ComputeMethod] protected virtual async Task GetReadPositionsStatInternal(ChatId chatId, CancellationToken cancellationToken) { /* ... */ } // Private methods private async Task GetOwnPrincipalId(Session session, ChatId chatId, CancellationToken cancellationToken) { /* ... */ } } ``` -------------------------------- ### Run RPC Benchmark Client with Server Core Constraint Source: https://github.com/actuallab/fusion.samples/blob/master/docs/rpc-benchmark.md Runs the RPC benchmark client against a server that is constrained to a specific number of CPU cores. This command is used in conjunction with the server start command. ```bash Run-RpcBenchmark-Client.cmd [url] [client options] ``` -------------------------------- ### Bidirectional RPC with Server-to-Client Callbacks Source: https://context7.com/actuallab/fusion.samples/llms.txt Demonstrates ActualLab.Rpc without Fusion, including server-initiated callbacks to clients using a reversed IClientNotifier proxy. Server-side setup includes adding RPC services and configuring outbound call options for routing. ```csharp // HelloRpc/Greeter.cs public interface IGreeter : IRpcService { Task SayHello(string name, CancellationToken cancellationToken = default); } public class Greeter(IClientNotifier clientNotifier) : IGreeter { public async Task SayHello(string name, CancellationToken cancellationToken = default) { // Access the inbound RPC peer and start sending notifications back StartClientNotifications(RpcInboundContext.Current!.Peer); return new Message($"Hello, {name}!"); } private void StartClientNotifications(RpcPeer peer) { lock (_notificationTasks) { if (_notificationTasks.ContainsKey(peer)) return; _notificationTasks[peer] = Task.Run(async () => { while (true) { await Task.Delay(1000, peer.StopToken); await clientNotifier.Notify(peer.Ref.Address, DateTime.Now, peer.StopToken); } }); } } } ``` ```csharp // Server-side setup var rpc = builder.Services.AddRpc(); rpc.AddWebSocketServer(); rpc.AddServer(); rpc.AddClient(); // Route IClientNotifier calls to the specific connected client peer builder.Services.AddSingleton(_ => RpcOutboundCallOptions.Default with { RouterFactory = methodDef => args => methodDef.Service.Type == typeof(IClientNotifier) ? RpcPeerRef.FromAddress(args.Get(0)) : RpcPeerRef.Default }); // Client-side setup var rpc = services.AddRpc(); rpc.AddWebSocketClient(baseUrl); rpc.AddClient(); rpc.AddServer(); // serve the callback interface ``` -------------------------------- ### Build Project with CI Solution Filter Source: https://github.com/actuallab/fusion.samples/blob/master/CLAUDE.md Build your project using the preferred CI solution filter file (.CI.slnf) to exclude projects that require specific workloads. Alternatively, use the main solution file (.sln) if all workloads are installed. ```bash # Preferred — uses CI solution filter (excludes workload-heavy projects) dotnet build .CI.slnf ``` ```bash # Only if you have all workloads installed (including maui-android, etc.) dotnet build .sln ``` -------------------------------- ### RPC Benchmark Results - No Concurrency Source: https://github.com/actuallab/fusion.samples/blob/master/docs/rpc-benchmark.md Example output from the RPC benchmark test with 1 client concurrency and 200 workers. This shows performance with minimal parallelization. ```text ActualLab.Rpc: Sum : 125.10K 123.65K 124.99K 124.50K -> 125.10K calls/s GetUser : 105.78K 103.09K 103.36K 103.45K -> 105.78K calls/s SayHello : 94.78K 94.30K 92.85K 94.26K -> 94.78K calls/s SignalR: Sum : 112.24K 112.34K 112.34K 112.20K -> 112.34K calls/s GetUser : 107.77K 106.51K 107.55K 107.55K -> 107.77K calls/s SayHello : 89.65K 89.70K 89.49K 89.58K -> 89.70K calls/s StreamJsonRpc: Sum : 69.17K 69.62K 69.13K 69.55K -> 69.62K calls/s GetUser : 59.95K 59.17K 60.06K 58.99K -> 60.06K calls/s SayHello : 36.99K 36.78K 36.34K 36.95K -> 36.99K calls/s MagicOnion: Sum : 46.67K 43.72K 46.57K 45.26K -> 46.67K calls/s GetUser : 41.46K 46.81K 42.38K 42.05K -> 46.81K calls/s SayHello : 42.11K 40.16K 39.90K 41.01K -> 42.11K calls/s gRPC: Sum : 49.02K 49.17K 47.57K 35.68K -> 49.17K calls/s GetUser : 45.34K 44.85K 44.69K 45.57K -> 45.57K calls/s SayHello : 44.93K 44.20K 42.64K 44.65K -> 44.93K calls/s HTTP: Sum : 117.98K 118.84K 119.00K 119.27K -> 119.27K calls/s GetUser : 116.55K 115.95K 116.99K 115.95K -> 116.99K calls/s SayHello : 88.41K 89.24K 88.63K 89.26K -> 89.26K calls/s ``` -------------------------------- ### RPC Benchmark Results - Low Concurrency Source: https://github.com/actuallab/fusion.samples/blob/master/docs/rpc-benchmark.md Example output from the RPC benchmark test with 10 client concurrency. Note the potential for connection refusals in some frameworks under lower concurrency. ```text System-wide settings: Thread pool settings: 48+ worker, 48+ I/O threads ByteSerializer.Default: MessagePack Client settings: Server URL: https://192.168.1.11:22444/ Test plan: 5.00s warmup, 4 x 5.00s runs Total worker count: 10000 Client concurrency: 10 Client count: 1000 ActualLab.Rpc: Sum : 542.45K 497.41K 548.56K 498.03K -> 548.56K calls/s GetUser : 489.61K 461.83K 457.90K 413.73K -> 489.61K calls/s SayHello : 352.40K 345.78K 366.69K 327.86K -> 366.69K calls/s SignalR: Sum : 322.26K 318.24K 318.07K 326.15K -> 326.15K calls/s GetUser : 359.93K 350.13K 360.51K 355.77K -> 360.51K calls/s SayHello : 281.83K 279.91K 288.70K 263.40K -> 288.70K calls/s StreamJsonRpc: Sum : 143.00K 136.94K 142.42K 136.68K -> 143.00K calls/s GetUser : 115.00K 116.07K 116.07K 110.61K -> 116.07K calls/s SayHello : 57.15K 53.85K 50.96K 52.62K -> 57.15K calls/s MagicOnion: Failed with HttpRequestException: The server refused the connection. gRPC: Failed with HttpRequestException: The server refused the connection. HTTP: Sum : 90.51K 91.96K 95.20K 95.78K -> 95.78K calls/s GetUser : 94.84K 94.09K 94.29K 95.17K -> 95.17K calls/s SayHello : 82.65K 85.96K 86.53K 86.38K -> 86.53K calls/s ``` -------------------------------- ### RPC Benchmark Results - High Concurrency Source: https://github.com/actuallab/fusion.samples/blob/master/docs/rpc-benchmark.md Example output from the RPC benchmark test with 500 client concurrency. Shows calls per second for various RPC methods and frameworks. ```text System-wide settings: Thread pool settings: 48+ worker, 48+ I/O threads ByteSerializer.Default: MessagePack Client settings: Server URL: https://192.168.1.11:22444/ Test plan: 5.00s warmup, 4 x 5.00s runs Total worker count: 10000 Client concurrency: 500 Client count: 20 ActualLab.Rpc: Sum : 862.27K 1.19M 1.17M 1.19M -> 1.19M calls/s GetUser : 821.86K 809.93K 807.60K 811.07K -> 821.86K calls/s SayHello : 482.01K 479.82K 480.23K 480.94K -> 482.01K calls/s SignalR: Sum : 800.22K 801.45K 794.29K 791.82K -> 801.45K calls/s GetUser : 625.54K 624.14K 627.01K 621.87K -> 627.01K calls/s SayHello : 340.64K 345.35K 342.72K 332.22K -> 345.35K calls/s StreamJsonRpc: Sum : 173.71K 171.64K 161.88K 167.82K -> 173.71K calls/s GetUser : 133.28K 132.31K 131.10K 129.99K -> 133.28K calls/s SayHello : 57.82K 54.53K 56.34K 53.51K -> 57.82K calls/s MagicOnion: Sum : 117.05K 120.05K 119.03K 116.09K -> 120.05K calls/s GetUser : 113.83K 113.36K 101.22K 94.55K -> 113.83K calls/s SayHello : 91.09K 88.23K 90.37K 90.13K -> 91.09K calls/s gRPC: Sum : 109.37K 104.45K 102.33K 99.85K -> 109.37K calls/s GetUser : 106.62K 102.25K 102.97K 103.16K -> 106.62K calls/s SayHello : 99.42K 98.16K 101.81K 100.55K -> 101.81K calls/s HTTP: Sum : 76.65K 95.31K 96.05K 96.96K -> 96.96K calls/s GetUser : 97.02K 95.65K 93.25K 95.62K -> 97.02K calls/s SayHello : 82.91K 87.30K 86.83K 87.68K -> 87.68K calls/s ``` -------------------------------- ### Run HelloBlazorServer Sample with Dotnet CLI Source: https://github.com/actuallab/fusion.samples/blob/master/README.md Command to run the HelloBlazorServer sample and instructions to open it in a browser. ```bash dotnet run -p src/HelloBlazorServer/HelloBlazorServer.csproj + open http://localhost:5005/ ``` -------------------------------- ### Automatic Dependency-Tracked Caching with [ComputeMethod] Source: https://context7.com/actuallab/fusion.samples/llms.txt Decorate virtual methods of IComputeService implementations with [ComputeMethod] to enable automatic result caching and dependency tracking. Nested [ComputeMethod] calls become dependencies. Use Invalidation.Begin() to start an invalidation scope and mark results as stale. This example demonstrates registering services, adding projects, capturing live computed handles, and watching for invalidations. ```csharp // HelloWorld/IncrementalBuilder.cs public class IncrementalBuilder : IComputeService { private readonly ConcurrentDictionary _projects = new(); private readonly ConcurrentDictionary _versions = new(); // This method's output is cached. Any nested [ComputeMethod] calls // automatically become dependencies. [ComputeMethod] public virtual async Task GetOrBuild( string projectId, CancellationToken cancellationToken = default) { var project = _projects[projectId]; var version = _versions.AddOrUpdate(projectId, _ => 1, (_, v) => v + 1); // Recursive calls to [ComputeMethod] register dependencies: await Task.WhenAll(project.DependsOn.Select( depId => GetOrBuild(depId, cancellationToken))); await Task.Delay(100); // simulate build return new ProjectBuildResult { Project = project, Version = version, Artifacts = $"{projectId}.lib" }; } public void InvalidateGetOrBuildResult(string projectId) { using var invalidating = Invalidation.Begin(); // Start invalidation scope _ = GetOrBuild(projectId, default); // Mark result as stale } } // Registration and usage var services = new ServiceCollection() .AddFusion(f => f.AddService()) .BuildServiceProvider(); var builder = services.GetRequiredService(); await builder.AddOrUpdate(new Project("Abstractions")); await builder.AddOrUpdate(new Project("Client", "Abstractions")); // Capture a live IComputed handle var computed = await Computed.Capture(() => builder.GetOrBuild("Client", default)); Console.WriteLine(computed.Value); // ProjectBuildResult { ... } // Watch for future invalidations while (true) { await computed.WhenInvalidated(); computed = await computed.Update(); // re-execute and get fresh value Console.WriteLine(computed.Value); } ``` -------------------------------- ### Run HelloBlazorServer Sample with Docker Compose Source: https://github.com/actuallab/fusion.samples/blob/master/README.md Command to run the HelloBlazorServer sample with Docker Compose and instructions to open it in a browser. ```bash docker-compose run --build --service-ports sample_hello_blazor_server + open http://localhost:5005/ ``` -------------------------------- ### Run HelloWorld Sample with Dotnet CLI Source: https://github.com/actuallab/fusion.samples/blob/master/README.md Command to run the HelloWorld sample using its specific project file. ```bash dotnet run -p src/HelloWorld/HelloWorld.csproj ``` -------------------------------- ### Run HelloWorld Sample with Docker Compose Source: https://github.com/actuallab/fusion.samples/blob/master/README.md Command to run the HelloWorld sample using Docker Compose. ```bash docker-compose run --build sample_hello_world ``` -------------------------------- ### Build Individual Sample Project Source: https://github.com/actuallab/fusion.samples/blob/master/AGENTS.md Build a specific sample project by providing its .csproj file path. ```powershell dotnet build src/HelloWorld/HelloWorld.csproj ``` -------------------------------- ### Run TodoApp Sample with Dotnet CLI Source: https://github.com/actuallab/fusion.samples/blob/master/README.md Command to run the TodoApp sample and instructions to open it in a browser. ```bash dotnet run -p src/TodoApp/Host/Host.csproj + open http://localhost:5005/ ``` -------------------------------- ### Run HelloBlazorHybrid Sample with Dotnet CLI Source: https://github.com/actuallab/fusion.samples/blob/master/README.md Command to run the HelloBlazorHybrid sample and instructions to open it in a browser. ```bash dotnet run -p src/HelloBlazorHybrid/Server/Server.csproj + open http://localhost:5005/ ``` -------------------------------- ### Run Blazor/Web Samples Source: https://github.com/actuallab/fusion.samples/blob/master/AGENTS.md Launch Blazor and other web-based sample projects. Access them via http://localhost:5005/ after running. ```powershell dotnet run -p src/HelloBlazorServer/HelloBlazorServer.csproj dotnet run -p src/Blazor/Server/Server.csproj dotnet run -p src/TodoApp/Host/Host.csproj ``` -------------------------------- ### Run Blazor Sample with Dotnet CLI Source: https://github.com/actuallab/fusion.samples/blob/master/README.md Command to run the Blazor sample and instructions to open it in a browser. ```bash dotnet run -p src/Blazor/Server/Server.csproj + open http://localhost:5005/ ``` -------------------------------- ### Run HelloBlazorHybrid Sample with Docker Compose Source: https://github.com/actuallab/fusion.samples/blob/master/README.md Command to run the HelloBlazorHybrid sample with Docker Compose and instructions to open it in a browser. ```bash docker-compose run --build --service-ports sample_hello_blazor_hybrid + open http://localhost:5005/ ``` -------------------------------- ### Run Console Samples Source: https://github.com/actuallab/fusion.samples/blob/master/AGENTS.md Execute console-based sample projects using their respective .csproj files. ```powershell dotnet run -p src/HelloWorld/HelloWorld.csproj dotnet run -p src/HelloCart/HelloCart.csproj ``` -------------------------------- ### Run TodoApp Sample with Docker Compose Source: https://github.com/actuallab/fusion.samples/blob/master/README.md Command to run the TodoApp sample with Docker Compose and instructions to open it in a browser. ```bash docker-compose run --build --service-ports sample_todoapp + open http://localhost:5005/ ``` -------------------------------- ### Explicit Cache Invalidation with Invalidation.Begin() Source: https://context7.com/actuallab/fusion.samples/llms.txt Use `Invalidation.Begin()` to mark compute outputs as stale. Calls within this scope trigger cache eviction without re-executing the method body. Ensure `Get` methods are called within this scope to notify observers. ```csharp // HelloCart/v1/InMemoryCartService.cs public class InMemoryCartService(IProductService products) : ICartService { private readonly ConcurrentDictionary _carts = new(); public virtual Task Edit(EditCommand command, CancellationToken cancellationToken = default) { var (cartId, cart) = command; if (cart is null) _carts.Remove(cartId, out _); else _carts[cartId] = cart; // All callers observing Get(cartId) will be notified: using var _ = Invalidation.Begin(); _ = Get(cartId, default); return Task.CompletedTask; } public virtual Task Get(string id, CancellationToken cancellationToken = default) => Task.FromResult(_carts.GetValueOrDefault(id)); // GetTotal depends on Get(id) and on products.Get(...), // so it is invalidated automatically when either is invalidated. public virtual async Task GetTotal(string id, CancellationToken cancellationToken = default) { var cart = await Get(id, cancellationToken); if (cart is null) return 0; var total = 0M; foreach (var (productId, quantity) in cart.Items) { var product = await products.Get(productId, cancellationToken); total += (product?.Price ?? 0M) * quantity; } return total; } } ``` -------------------------------- ### Run RpcBenchmark Sample with Dotnet CLI Source: https://github.com/actuallab/fusion.samples/blob/master/README.md Command to run the RpcBenchmark sample in Release configuration using its specific project file. ```bash dotnet run -c:Release -p src/RpcBenchmark/RpcBenchmark.csproj ``` -------------------------------- ### Connect Playwright to Host Chrome Source: https://github.com/actuallab/fusion.samples/blob/master/CLAUDE.md Use this code to connect Playwright to a Chrome instance running on the host machine. Ensure Chrome is started with remote debugging enabled on port 9222. This is useful when running Playwright within a Docker container that uses host networking. ```typescript import { chromium } from 'playwright'; // Connect to host Chrome on standard debug port const browser = await chromium.connectOverCDP('http://localhost:9222'); const page = await browser.newPage(); await page.goto('https://example.com'); // ... user sees this in their Chrome window ``` -------------------------------- ### Run HelloCart Sample with Dotnet CLI Source: https://github.com/actuallab/fusion.samples/blob/master/README.md Command to run the HelloCart sample using its specific project file. ```bash dotnet run -p src/HelloCart/HelloCart.csproj ``` -------------------------------- ### Run Blazor Sample with Docker Compose Source: https://github.com/actuallab/fusion.samples/blob/master/README.md Command to run the Blazor sample with Docker Compose and instructions to open it in a browser. ```bash docker-compose run --build --service-ports sample_blazor + open http://localhost:5005/ ``` -------------------------------- ### Running RpcBenchmark Source: https://github.com/actuallab/fusion.samples/blob/master/docs/rpc-benchmark.md Use this command to run the benchmark from the cloned repository. Specify the configuration using command-line arguments. ```bash dotnet run -c Release --project src/RpcBenchmark/RpcBenchmark.csproj ``` -------------------------------- ### Run Benchmark Sample with Dotnet CLI Source: https://github.com/actuallab/fusion.samples/blob/master/README.md Command to run the Benchmark sample in Release configuration using its specific project file. ```bash dotnet run -c:Release -p src/Benchmark/Benchmark.csproj ``` -------------------------------- ### Run Benchmark Samples Source: https://github.com/actuallab/fusion.samples/blob/master/AGENTS.md Execute benchmark projects in Release configuration to measure performance. ```powershell dotnet run -c:Release -p src/Benchmark/Benchmark.csproj dotnet run -c:Release -p src/RpcBenchmark/RpcBenchmark.csproj ``` -------------------------------- ### Run RpcBenchmark Sample with Docker Compose Source: https://github.com/actuallab/fusion.samples/blob/master/README.md Command to run the RpcBenchmark sample using Docker Compose. ```bash docker-compose run --build sample_rpc_benchmark ``` -------------------------------- ### Build Entire Solution Source: https://github.com/actuallab/fusion.samples/blob/master/AGENTS.md Use this command to build all projects within the solution. ```powershell dotnet build Samples.sln ``` -------------------------------- ### Build Fusion Project with Dotnet CLI Source: https://github.com/actuallab/fusion.samples/blob/master/README.md Run this command first to build the entire Fusion project using the dotnet CLI. ```bash dotnet build ``` -------------------------------- ### RpcBenchmark Command Line Options Source: https://github.com/actuallab/fusion.samples/blob/master/docs/rpc-benchmark.md These are the available command-line options for running RpcBenchmark, including server and client configurations, test parameters, and library selection. ```bash Run-RpcBenchmark.cmd dotnet run -c Release --project src/RpcBenchmark/RpcBenchmark.csproj -- ``` -------------------------------- ### Run HelloCart Sample with Docker Compose Source: https://github.com/actuallab/fusion.samples/blob/master/README.md Command to run the HelloCart sample using Docker Compose. ```bash docker-compose run --build sample_hello_cart ``` -------------------------------- ### Run Benchmark Sample with Docker Compose Source: https://github.com/actuallab/fusion.samples/blob/master/README.md Command to run the Benchmark sample using Docker Compose. ```bash docker-compose run --build sample_benchmark ``` -------------------------------- ### Run MiniRpc Sample with Dotnet CLI Source: https://github.com/actuallab/fusion.samples/blob/master/README.md Command to run the MiniRpc sample using its specific project file. ```bash dotnet run -p src/MiniRpc/MiniRpc.csproj ``` -------------------------------- ### Build Fusion Project with Docker Compose Source: https://github.com/actuallab/fusion.samples/blob/master/README.md Run this command first to build all services defined in the Docker Compose file. ```bash docker-compose build ``` -------------------------------- ### Run MultiServerRpc Sample with Dotnet CLI Source: https://github.com/actuallab/fusion.samples/blob/master/README.md Command to run the MultiServerRpc sample using its specific project file. ```bash dotnet run -p src/MultiServerRpc/MultiServerRpc.csproj ``` -------------------------------- ### Run MiniRpc Sample with Docker Compose Source: https://github.com/actuallab/fusion.samples/blob/master/README.md Command to run the MiniRpc sample using Docker Compose. ```bash docker-compose run --build sample_mini_rpc ``` -------------------------------- ### Run MultiServerRpc Sample with Docker Compose Source: https://github.com/actuallab/fusion.samples/blob/master/README.md Command to run the MultiServerRpc sample using Docker Compose. ```bash docker-compose run --build sample_multi_server_rpc ``` -------------------------------- ### Run RPC Benchmark with Default Settings Source: https://github.com/actuallab/fusion.samples/blob/master/docs/rpc-benchmark.md Executes the RPC benchmark using default system and client settings. This provides a baseline performance measurement for various RPC frameworks. ```bash Run-RpcBenchmark.cmd test ``` -------------------------------- ### Alternative RPC Benchmark Client Execution Source: https://github.com/actuallab/fusion.samples/blob/master/docs/rpc-benchmark.md Provides an alternative command to run the RPC benchmark client using the dotnet CLI. This is equivalent to the Run-RpcBenchmark-Client.cmd command. ```bash dotnet run -c Release --project src/RpcBenchmark/RpcBenchmark.csproj -- client [url] [client options] ``` -------------------------------- ### Run RPC Benchmark Commands Source: https://github.com/actuallab/fusion.samples/blob/master/docs/rpc-benchmark.md Use these commands to run the RPC benchmark server and client. Adjust client parameters like '-cc' (client concurrency) and '-w' (total worker count) for different load tests. ```bash Run-RpcBenchmark-Server.cmd ``` ```bash Run-RpcBenchmark-Client.cmd -wait -cc 1000 -w 10000 ``` -------------------------------- ### Run RPC Benchmark Client - Low Concurrency Source: https://github.com/actuallab/fusion.samples/blob/master/docs/rpc-benchmark.md Command to run the RPC benchmark client with low concurrency (10 clients). This is useful for observing performance with fewer simultaneous connections. ```bash Run-RpcBenchmark-Client.cmd https://192.168.1.11:22444/ -cc 10 -w 10000 ``` -------------------------------- ### Host Registration with Sharding Configuration Source: https://context7.com/actuallab/fusion.samples/llms.txt Configures the application host by registering database services, including sharding capabilities for multi-tenant support. Sets up Fusion RPC services and authentication. ```csharp // Host registration with sharding (TodoApp/Host/Program.cs) services.AddDbContextServices(db => { db.AddOperations(ops => ops.AddFileSystemOperationLogWatcher()); db.AddEntityResolver(); db.AddSharding(sharding => { sharding.AddShardRegistry(Enumerable.Range(0, tenantCount).Select(i => $"tenant{i}")); sharding.AddTransientShardDbContextFactory(ConfigureShardDbContext); }); }); var fusion = services.AddFusion(RpcServiceMode.Server, true); fusion.AddServer(); fusion.AddServer(); fusion.AddDbAuthService(); ``` -------------------------------- ### Run Local Benchmark Source: https://github.com/actuallab/fusion.samples/blob/master/Benchmarks.md Execute the benchmark for a simple repository-style user lookup service. This command measures the throughput of regular and Fusion services. ```powershell dotnet run -c Release --project src/Benchmark/Benchmark.csproj --no-launch-profile ``` -------------------------------- ### Restore Dependencies and Tools Source: https://github.com/actuallab/fusion.samples/blob/master/AGENTS.md Run these commands to restore project dependencies and tools before building. ```powershell dotnet restore dotnet tool restore ``` -------------------------------- ### Implementing Database-Backed Compute Services with EF Core Source: https://context7.com/actuallab/fusion.samples/llms.txt This service extends `DbServiceBase` to handle product data operations. It utilizes `DbHub.CreateOperationDbContext` to enroll database writes in the Operations Framework, ensuring changes are replicated. It also demonstrates adding operation events for logging. ```csharp // HelloCart/v2/DbProductService.cs public class DbProductService(IServiceProvider services) : DbServiceBase(services), IProductService { public virtual async Task Edit( EditCommand command, CancellationToken cancellationToken = default) { var (productId, product) = command; if (Invalidation.IsActive) { // Runs AFTER the DB write on every server that processes the operation log _ = Get(productId, default); return; } // CreateOperationDbContext enrolls this DB write in the Operations Framework await using var dbContext = await DbHub.CreateOperationDbContext(cancellationToken); var dbProduct = await dbContext.Products.FindAsync(DbKey.Compose(productId), cancellationToken); if (product is null) { if (dbProduct is not null) dbContext.Remove(dbProduct); } else { if (dbProduct is not null) dbProduct.Price = product.Price; else dbContext.Add(new DbProduct { Id = productId, Price = product.Price }); } await dbContext.SaveChangesAsync(cancellationToken); // Attach an event to be re-played on all servers var context = CommandContext.GetCurrent(); context.Operation.AddEvent(new LogMessageCommand( Ulid.NewUlid().ToString(), product is null ? $ ``` -------------------------------- ### Run MeshRpc Sample with Docker Compose Source: https://github.com/actuallab/fusion.samples/blob/master/README.md Command to run the MeshRpc sample using Docker Compose. ```bash docker-compose run --build sample_mesh_rpc ``` -------------------------------- ### Run MeshRpc Sample with Dotnet CLI Source: https://github.com/actuallab/fusion.samples/blob/master/README.md Command to run the MeshRpc sample using its specific project file. ```bash dotnet run -p src/MeshRpc/MeshRpc.csproj ``` -------------------------------- ### RPC Benchmark Configuration and Results Source: https://github.com/actuallab/fusion.samples/blob/master/docs/rpc-benchmark.md This output displays system-wide and client-specific settings used for the benchmark, along with the performance metrics (calls/s) for different RPC frameworks. It highlights the throughput achieved by each framework under the specified load. ```text System-wide settings: Thread pool settings: 48+ worker, 48+ I/O threads ByteSerializer.Default: MessagePack Client settings: Server URL: https://localhost:22444/ Test plan: 5.00s warmup, 4 x 5.00s runs Total worker count: 10000 Client concurrency: 1000 Client count: 10 ActualLab.Rpc: Sum : 959.11K 912.14K 910.62K 888.58K -> 959.11K calls/s GetUser : 624.38K 615.48K 623.40K 631.55K -> 631.55K calls/s SayHello : 409.44K 423.51K 414.74K 421.74K -> 423.51K calls/s SignalR: Sum : 843.17K 847.50K 844.43K 843.37K -> 847.50K calls/s GetUser : 646.71K 642.96K 656.32K 637.99K -> 656.32K calls/s SayHello : 252.49K 271.26K 260.31K 268.19K -> 271.26K calls/s StreamJsonRpc: Sum : 115.51K 117.17K 115.91K 116.46K -> 117.17K calls/s GetUser : 85.15K 87.24K 87.65K 85.81K -> 87.65K calls/s SayHello : 48.47K 49.09K 47.96K 49.99K -> 49.99K calls/s MagicOnion: Sum : 88.01K 85.13K 87.55K 88.55K -> 88.55K calls/s GetUser : 84.86K 86.22K 83.73K 84.63K -> 86.22K calls/s SayHello : 79.11K 79.12K 77.69K 79.11K -> 79.12K calls/s gRPC: Sum : 91.05K 86.54K 91.77K 91.46K -> 91.77K calls/s GetUser : 89.83K 88.54K 88.19K 90.39K -> 90.39K calls/s SayHello : 86.63K 87.43K 83.50K 85.47K -> 87.43K calls/s HTTP: Sum : 75.60K 76.56K 76.91K 76.18K -> 76.91K calls/s GetUser : 74.40K 74.27K 74.48K 74.57K -> 74.57K calls/s SayHello : 60.99K 58.05K 61.97K 59.36K -> 61.97K calls/s ``` -------------------------------- ### Run RPC Benchmark (Streaming) Source: https://github.com/actuallab/fusion.samples/blob/master/Benchmarks.md Compare ActualLab.Rpc, gRPC, and SignalR performance for RPC streaming. This command specifies message pack format and enables serialization. ```powershell dotnet run -c Release --project src/RpcBenchmark/RpcBenchmark.csproj --no-launch-profile -- test -b streams -l rpc,grpc,signalr -f msgpack6c -s -n 6 ``` -------------------------------- ### Configure Fusion RPC Server and Client Source: https://context7.com/actuallab/fusion.samples/llms.txt Set up a Fusion RPC server to expose services via WebSocket and a client to consume them with transparent proxies. Use Computed.Capture to watch for automatic updates. ```csharp // HelloCart/v4/AppV4.cs — Server side var builder = WebApplication.CreateBuilder(); builder.Services.AddFusion(RpcServiceMode.Server, fusion => { fusion.AddWebServer(); fusion.AddService(); fusion.AddService(); }); var app = builder.Build(); app.UseWebSockets(); app.MapRpcWebSocketServer(); // Exposes all services at /rpc/ws await app.RunAsync("http://localhost:7005"); // Client side — the proxy is used identically to a local service var clientServices = new ServiceCollection() .AddFusion(fusion => { fusion.Rpc.AddWebSocketClient("http://localhost:7005"); fusion.AddClient(); // transparent RPC proxy fusion.AddClient(); }) .BuildServiceProvider(); var productService = clientServices.GetRequiredService(); // Watch cart total — updates automatically when server invalidates anything var computed = await Computed.Capture( () => clientServices.GetRequiredService() .GetTotal("cart1(apple=1,banana=2)", default)); while (true) { Console.WriteLine($"Cart total: {computed.Value}"); await computed.WhenInvalidated(); computed = await computed.Update(); } ``` -------------------------------- ### Run RPC Benchmark (Calls) Source: https://github.com/actuallab/fusion.samples/blob/master/Benchmarks.md Compare ActualLab.Rpc, gRPC, and SignalR performance for RPC calls. This command specifies message pack format and enables serialization. ```powershell dotnet run -c Release --project src/RpcBenchmark/RpcBenchmark.csproj --no-launch-profile -- test -b calls -l rpc,grpc,signalr -f msgpack6c -s -n 6 ``` -------------------------------- ### Run RPC Benchmark with Optimized gRPC and MagicOnion Settings Source: https://github.com/actuallab/fusion.samples/blob/master/docs/rpc-benchmark.md Executes the RPC benchmark with specific client configurations optimized for gRPC and MagicOnion. This test uses a higher client concurrency and limits the tested protocols. ```bash Run-RpcBenchmark.cmd test -cc 1000 -b grpc,mo ``` -------------------------------- ### Run RPC Benchmark Client - High Concurrency Source: https://github.com/actuallab/fusion.samples/blob/master/docs/rpc-benchmark.md Command to run the RPC benchmark client with high concurrency (500 clients). This tests the server's performance under heavy load. ```bash Run-RpcBenchmark-Client.cmd https://192.168.1.11:22444/ -cc 500 -w 10000 ```