Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Why slow response in .NET 6 vs IIS ? #1591

Closed
gramirez897 opened this issue Jul 28, 2022 · 8 comments
Closed

Why slow response in .NET 6 vs IIS ? #1591

gramirez897 opened this issue Jul 28, 2022 · 8 comments
Assignees
Labels
IIS Internet Information Services (IIS) for Windows® Server question Initially seen a question could become a new feature or bug or closed ;)

Comments

@gramirez897
Copy link

gramirez897 commented Jul 28, 2022

I'm having an issue upgrading the project to .NET 6 and version 18.0.0.

In .NET 5, version 17.0.1 the API Gateway works great, but I 've tried several times to upgrade to .NET 6 and Ocelot version 18.0.0 and the response become extremely slow. They queue for minutes or just hang and the app gets no response. The first time this happened, I just upgraded the project to .NET 6, but stayed with Ocelot 17, for which I could say it might be an issue with .NET 6.

I have followed the latest documentation for .NET 6 and keep getting the same results.

This is my Program file:

using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;

namespace ApiGateway
{
    public class Program
    {
        public static void Main(string[] args)
        {
            CreateHostBuilder(args).Build().Run();
        }

        public static IHostBuilder CreateHostBuilder(string[] args) =>
            Host.CreateDefaultBuilder(args)
                .ConfigureAppConfiguration((hostingContext, configuration) =>
                {
                    configuration.Sources.Clear();

                    configuration
                       .AddJsonFile("appsettings.json", true, true)
                       .AddJsonFile("ocelot.json", false, true)
                       .AddEnvironmentVariables();
                })
                .ConfigureWebHostDefaults(webBuilder =>
                {
                    webBuilder.UseStartup<Startup>();
                });
    }
}

My Startup file:

using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Ocelot.DependencyInjection;
using Ocelot.Middleware;

namespace ApiGateway
{
    public class Startup
    {
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        public IConfiguration Configuration { get; }

        public void ConfigureServices(IServiceCollection services)
        {
            services.AddSingleton(x => Configuration);

            services.AddCors(options =>
            {
                options.AddDefaultPolicy(
                    builder =>
                    {
                        if (Configuration.GetValue<string>("AllowedHosts") == "*")
                            builder.AllowAnyOrigin();
                        else
                            builder.WithOrigins(Configuration.GetValue<string>("AllowedHosts"));

                        builder
                        .AllowAnyMethod()
                        .AllowAnyHeader();
                    });
            });

            services.AddOcelot(Configuration);
        }

        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseHttpsRedirection();
            app.UseRouting();
            app.UseCors();
            app.UseOcelot().Wait();
        }
    }
}

Any help on this would be appreciated.

  • Version: 18.0.0
  • Platform: .NET 6
@canertosuner
Copy link

canertosuner commented Aug 11, 2022

Having the same problem with net6 and ocelot 18.0 any update on it ?
Here is the ss from newrelic dashboard showing the time spent in .NET, almost x2
oie_5fM1IzcaClEQ

@ToniSoriano
Copy link

I have the same problem. It only happens on net 6.

@GIGA-DEV-ad
Copy link

Can we post metrics showing the speed issue between .net 5 and .net 6?

@fastfastgogo
Copy link

I have same problem too,why?

@ToniSoriano
Copy link

In .net 6 these are the times:
image

however in .net 5 the times are much better.
image

@ToniSoriano
Copy link

In .net 6 these are the times: image

however in .net 5 the times are much better. image

This test has been done with the version 17.0.1. With the version 18.0.0 the same results are obtained.

@gramirez897
Copy link
Author

I have been doing some tests for this issue and I've almost arrived at the conclusion that my issue is caused by IIS Express.

I tried following this tutorial for the latest Ocelot implementation and when I created a new VS ASP.Net Core 7 Empty project it runs in the a debug console instead of IIS Express. This way the gateway works perfectly.

https://www.youtube.com/watch?v=k4l3Ptd4yjw

After that I tried changing the launchSettings.json file so that the application would run with IIS Express instead and the problem started again. The requests get queued for at least 2 minutes when upgrading from .net 5 to 6 or 7.

I still can't explain why it would behave this way with IIS Express only though.

@raman-m
Copy link
Member

raman-m commented Oct 20, 2023

@gramirez897 commented on Dec 2, 2022

Check the solution please in #1657. You have to use Out-of-process hosting.
Let me know the testing results please!

@raman-m raman-m self-assigned this Oct 20, 2023
@raman-m raman-m added the IIS Internet Information Services (IIS) for Windows® Server label Oct 20, 2023
@raman-m raman-m changed the title Slow Response in .NET 6 Why slow response in .NET 6 vs IIS ? Dec 15, 2023
@raman-m raman-m added the question Initially seen a question could become a new feature or bug or closed ;) label Dec 15, 2023
@ThreeMammals ThreeMammals locked and limited conversation to collaborators Dec 15, 2023
@raman-m raman-m converted this issue into discussion #1854 Dec 15, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
IIS Internet Information Services (IIS) for Windows® Server question Initially seen a question could become a new feature or bug or closed ;)
Projects
None yet
Development

No branches or pull requests

6 participants