-
Notifications
You must be signed in to change notification settings - Fork 1.5k
SelfHost: Change to callback based responses for better performance #2856
base: 1.x-WorkingBranch
Are you sure you want to change the base?
Conversation
try | ||
{ | ||
var nancyRequest = this.ConvertRequestToNancyRequest(ctx.Request); | ||
this.engine.HandleRequest(nancyRequest, onComplete, onError); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is this overload defined? I think I must be blind, cause I just can't find it 😕
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m on my phone so I can’t be sure, but I believe this is it. Note that this is on the 1.x branch since I was working against stable.
Nancy/src/Nancy/NancyEngineExtensions.cs
Line 78 in b826aaf
public static void HandleRequest( |
But that overload isn't there in 2.0. We've moved everything over to async/await and Tasks. |
I can try to check this out in 2.x - it may not be an issue in the new versions, but was an issue in the current stable. |
@jocull yeah it would be great if you could check if it happens on |
@thecodejunkie Alright, so here's what I turned up:
Along the way I noticed that |
Prerequisites
Description
I noticed that the SelfHost was not performing well when using
async
methods. You can test a simple endpoint usingawait Task.Delay(100)
and see them queue up as the engine handle blocks waiting for the task. This change converts it to complete/error callbacks so they no longer block. Hope it helps, and please let me know if I missed anything! I'm new here :)