-
Notifications
You must be signed in to change notification settings - Fork 240
echo benchmark for Websockets #1686
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
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
057859b
Add benchmark for websockets
kondratyev-nv 68453d0
Merge remote-tracking branch 'upstream/main' into main
kondratyev-nv 0686fd3
Minor fixes
kondratyev-nv 2249839
Fix link to imported yml
kondratyev-nv a549759
Review fixes
kondratyev-nv 034b163
Update Websocket server SDK verison
kondratyev-nv 01e3fe2
Merge remote-tracking branch 'upstream/main'
kondratyev-nv b2cee80
Randomly generate message
kondratyev-nv 251a498
Fix message type
kondratyev-nv 5c6016a
Add error counters, fix review comments
kondratyev-nv 53bcf41
Add warmup stage, minor fixes
kondratyev-nv f94ec14
Fixed measurements, cleanup
kondratyev-nv e9ca098
Fix usings
kondratyev-nv db9136d
Merge remote-tracking branch 'upstream/main'
kondratyev-nv 7617fa5
Fix usings p.2, warmup argument fix
kondratyev-nv 59f3b6f
Update websocket.benchmarks.yml
sebastienros 8f546a0
Update websocketServer.yml
sebastienros 7ebf22f
Update websocketclient.yml
sebastienros 9441f0c
Update build/websocket-scenarios.yml
kondratyev-nv c594209
Remove src/BenchmarksApps/Websocket/websocket.json
kondratyev-nv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| # Websocket scenarios | ||
|
|
||
| parameters: | ||
| - name: profile | ||
| type: string | ||
| default: '' | ||
| - name: warmup | ||
| type: number | ||
| default: 0 | ||
| - name: duration | ||
| type: number | ||
| default: 15 | ||
| - name: connection | ||
| type: string | ||
| default: '' | ||
|
|
||
| # Scenarios | ||
| - name: scenarios | ||
| type: object | ||
| default: | ||
|
|
||
| - displayName: Echo | ||
| arguments: --scenario websocket $(websocketJobs) --variable scenario=echo --property scenario=echo | ||
|
|
||
| steps: | ||
| - ${{ each s in parameters.scenarios }}: | ||
| - task: PublishToAzureServiceBus@1 | ||
| condition: succeededOrFailed() | ||
| displayName: ${{ s.displayName }} | ||
| inputs: | ||
| connectedServiceName: ${{ parameters.connection }} | ||
| waitForCompletion: true | ||
| messageBody: | | ||
| { | ||
| "timeout": "00:5:00", | ||
| "name": "crank", | ||
| "args": [ "${{ s.arguments }} --application.options.collectCounters true --load.options.collectCounters true --load.variables.warmup ${{ parameters.warmup }} --load.variables.duration ${{ parameters.duration }} --profile ${{ parameters.profile }} --load.channel edge --load.framework net6.0 --application.channel edge --application.framework net6.0 --session $(session) --table WebsocketBenchmarks --sql SQL_CONNECTION_STRING --chart --no-measurements --no-metadata --warmup.options.discardResults true" ] | ||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| # Examples: | ||
| # --config benchmarks.websocket.yml --scenario websocket --variable scenario=echo --profile asp-perf-lin | ||
|
|
||
| imports: | ||
| - https://raw.githubusercontent.com/aspnet/Benchmarks/main/src/WebsocketClient/websocketclient.yml | ||
| - https://raw.githubusercontent.com/aspnet/Benchmarks/main/src/BenchmarksApps/Websocket/websocketServer.yml | ||
| - https://github.com/aspnet/Benchmarks/blob/main/scenarios/aspnet.profiles.yml?raw=true | ||
|
|
||
| variables: | ||
| serverPort: 5000 | ||
| serverScheme: ws | ||
|
|
||
| scenarios: | ||
| websocket: | ||
| application: | ||
| job: websocketServer | ||
| load: | ||
| job: websocketClient | ||
| variables: | ||
| path: /Echo | ||
| warmup: 5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>net6.0</TargetFramework> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <None Remove="websocketServer.yml" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <Content Include="websocketserver.yml" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <Folder Include="wwwroot\" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="Microsoft.Crank.EventSources" Version="0.1.0-alpha.20501.1" /> | ||
| </ItemGroup> | ||
|
|
||
kondratyev-nv marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| </Project> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| // Copyright (c) .NET Foundation. All rights reserved. | ||
| // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
|
||
| using System; | ||
| using System.Diagnostics; | ||
| using Microsoft.AspNetCore.Builder; | ||
| using Microsoft.AspNetCore.Hosting; | ||
| using Microsoft.Extensions.Configuration; | ||
| using Microsoft.Extensions.Logging; | ||
|
|
||
| namespace BenchmarkServer | ||
| { | ||
| public class Program | ||
| { | ||
| public static void Main(string[] args) | ||
| { | ||
| Console.WriteLine($"Process ID: {Process.GetCurrentProcess().Id}"); | ||
|
|
||
| var config = new ConfigurationBuilder() | ||
| .AddEnvironmentVariables(prefix: "ASPNETCORE_") | ||
| .AddCommandLine(args) | ||
| .Build(); | ||
|
|
||
| var host = new WebHostBuilder() | ||
| .UseConfiguration(config) | ||
| .ConfigureLogging(loggerFactory => | ||
| { | ||
| if (Enum.TryParse(config["LogLevel"], out LogLevel logLevel)) | ||
| { | ||
| loggerFactory.AddConsole().SetMinimumLevel(logLevel); | ||
| } | ||
| }) | ||
| .UseKestrel() | ||
| .UseStartup<Startup>(); | ||
|
|
||
| host.Build().Run(); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| ## Purpose | ||
|
|
||
| This project is to assist in Benchmarking Websockets. | ||
| It makes it easier to test local changes than having the App in the Benchmarks repo by letting us make changes in websocket branches and using the example commandline below to run the benchmarks against our branches. | ||
|
|
||
| The WebsocketWorker that runs against this server is located at https://github.com/aspnet/benchmarks/blob/main/src/WebsocketClient/Program.cs. | ||
|
|
||
| ## Usage | ||
|
|
||
| 1. Push changes you would like to test to a branch on GitHub | ||
| 2. Clone aspnet/benchmarks repo to your machine or install the global BenchmarksDriver tool https://www.nuget.org/packages/BenchmarksDriver/ | ||
| 3. If cloned go to the BenchmarksDriver project | ||
| 4. Use the following command as a guideline for running a test using your changes | ||
|
|
||
| `benchmarks --config benchmarks.websocket.yml --scenario echo --variable serverUri=http://10.0.0.102 --load.endpoints http://10.0.0.102:5001 | ||
|
|
||
| 5. For more info/commands see https://github.com/aspnet/benchmarks/blob/main/src/BenchmarksDriver2/README.md |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| // Copyright (c) .NET Foundation. All rights reserved. | ||
| // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
|
||
| using System; | ||
| using System.Net; | ||
| using System.Net.WebSockets; | ||
| using System.Threading; | ||
| using System.Threading.Tasks; | ||
| using System.Web; | ||
| using Microsoft.AspNetCore.Builder; | ||
| using Microsoft.AspNetCore.Hosting; | ||
| using Microsoft.Extensions.Configuration; | ||
| using Microsoft.Extensions.DependencyInjection; | ||
| using Microsoft.Extensions.Logging; | ||
|
|
||
| namespace BenchmarkServer | ||
| { | ||
| public class Startup | ||
| { | ||
| public void ConfigureServices(IServiceCollection services) | ||
| { | ||
| services.AddRouting(); | ||
| } | ||
|
|
||
| public void Configure(IApplicationBuilder app) | ||
| { | ||
| app.UseRouting(); | ||
| app.UseWebSockets(); | ||
| app.Use(async (context, next) => | ||
| { | ||
| if (context.Request.Path == "/Echo") | ||
| { | ||
| if (context.WebSockets.IsWebSocketRequest) | ||
| { | ||
| using (WebSocket webSocket = await context.WebSockets.AcceptWebSocketAsync()) | ||
| { | ||
| await Echo(webSocket); | ||
| } | ||
| } | ||
| else | ||
| { | ||
| context.Response.StatusCode = (int)HttpStatusCode.BadRequest; | ||
| } | ||
| } | ||
| else | ||
| { | ||
| await next(); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| private async Task Echo(WebSocket webSocket) | ||
| { | ||
| var buffer = new byte[1024 * 4]; | ||
| var result = await webSocket.ReceiveAsync(new ArraySegment<byte>(buffer), CancellationToken.None); | ||
| while (!result.CloseStatus.HasValue) | ||
| { | ||
| await webSocket.SendAsync(new ArraySegment<byte>(buffer, 0, result.Count), result.MessageType, result.EndOfMessage, CancellationToken.None); | ||
| result = await webSocket.ReceiveAsync(new ArraySegment<byte>(buffer), CancellationToken.None); | ||
| } | ||
| await webSocket.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
|
|
||
| jobs: | ||
| websocketServer: | ||
| source: | ||
| repository: https://github.com/aspnet/benchmarks.git | ||
| branchOrCommit: main | ||
| project: src/BenchmarksApps/Websocket/BenchmarkServer.csproj | ||
| readyStateText: Application started | ||
| runtimeVersion: '6.0.*' | ||
| waitForExit: false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.