Description
Hello,
I have two ASP.NET Kestrel applications on Ubuntu 22.04.3 LTS dedicated server with two networks and two public IPs.
One ASP.NET application serves all request fine and whout any HTTP Response delays mostly.
For some reason the second ASP.NET application serves all HTTP requests with +30 seconds delay for no any observable reason.
Could you, please, help me to identify the issue if possible and in case this is really ASP.NET issue then it will help to improve ASP.NET itself.
Thank you for any ideas and assistance.
One of such HTTP method is:
app.MapGet("/getpendingaction", handler: getpendingaction);
public static async Task<IResult> getpendingaction(HttpContext context)
{
try
{
if (context.Request.Query.ContainsKey("ip") && allowedIPs.Contains(context.Request.Query["ip"] + ",", StringComparison.Ordinal))
{
Stopwatch m_sw = Stopwatch.StartNew();
string vip = context.Request.Query["ip"];
string retres = string.Empty;
VPS vps = null;
if (!vpsData.TryGetValue(vip, out vps))
{
vps = new VPS();
vps.IP = vip;
if (!vpsData.TryAdd(vps.IP, vps))
{
vpsData.TryGetValue(vip, out vps);
}
}
if (vps != null)
{
vps.NotResponding = false;
vps.LastUpdate = DateTime.UtcNow;
if (blkftp != null)
{
Stopwatch m_2sw = Stopwatch.StartNew();
try
{
retres = await logic?.GetPendingAction((string)context.Request.Query["ip"]);
}
catch (Exception ex)
{
Console.WriteLine("logic: " + ex);
}
m_2sw.Stop();
m_sw.Stop();
if (string.IsNullOrEmpty(retres))
{
retres = $"-1:-1:::::logic time {m_2sw.Elapsed.TotalMilliseconds} ms:webmethod time: {m_sw.Elapsed.TotalMilliseconds} ms";
}
else
{
retres += $"::logic time {m_2sw.Elapsed.TotalMilliseconds} ms:webmethod time: {m_sw.Elapsed.TotalMilliseconds} ms";
}
Interlocked.Exchange(ref avg_getpendingaction, (m_sw.Elapsed.TotalSeconds + avg_getpendingaction) / 2.0);
Interlocked.Exchange(ref max_getpendingaction, Math.Max(m_sw.Elapsed.TotalSeconds, max_getpendingaction));
}
context.Response.Headers.CacheControl = "no-cache, no-store, must-revalidate, max-age=0";
context.Response.Headers.Pragma = "no-cache";
context.Response.Headers.Expires = "0";
return Results.Content(retres);
}
}
else
{
if (context.Request.Query.ContainsKey("ip"))
{
unknownIPs.TryAdd(context.Request.Query["ip"], null);
}
return Results.Content("ok :)");
}
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
return Results.Content("ok :)");
}
so for this method we have the following times:
logic time 2092.7627 ms
webmethod time: 2092.7643 ms
but HTTP Response time +30 seconds which is measuerd with Development Tool in Google Chrome
Where should i start looking into? What to measure more? Any tools or suggestions?