Skip to content
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

Slow response on .Net 6 and IIS 10 #1657

Closed
vladkhnu opened this issue May 23, 2023 · 4 comments
Closed

Slow response on .Net 6 and IIS 10 #1657

vladkhnu opened this issue May 23, 2023 · 4 comments
Assignees
Labels
bug Identified as a potential bug invalid Not actually an issue wontfix No plan to include this issue in the Ocelot core functionality.

Comments

@vladkhnu
Copy link

I'm having issues when trying to use Ocelot with .Net version 6 deployed on IIS 10.

Previously I used .Net 3.1 with Ocelot 16 and everything were fine, pages opened with expected delay, but after upgrading to .Net 6 usage of every version of Ocelot (16, 17, 18) resulted in extremely big delay:
image

Issue is happens periodically, after couple of requests to different endpoints behind Ocelot and persist only in chromium-based browsers (Chrome and Edge) and everything is fine in Firefox.

Ocelot itself does not log any errros and seems works fine but after a number of quick requests issue appears again and again.
IIS is configured according to Microsoft suggestions and best practices, like I have App Pool in AlwaysRunning Start mode, preload of site is enabled, etc.

@raman-m raman-m added bug Identified as a potential bug invalid Not actually an issue question Initially seen a question could become a new feature or bug or closed ;) needs validation Issue has not been replicated or verified yet needs feedback Issue is waiting on feedback before acceptance waiting Waiting for answer to question or feedback from issue raiser labels May 26, 2023
@raman-m
Copy link
Member

raman-m commented May 26, 2023

@vladkhnu Hi Vladyslav!
Thanks for so big interest in Ocelot gateway!

First,
The periodical appearance of the bug with no logs on Ocelot's side mean that this is not an issue of Ocelot.

Second,
You said you use different browsers and behavior is different using those browsers. Pay attention that browsers have different default settings, default environments for building real protocol HTTP-based request.
Moreover browsers have different tracers and network tools to catch requests/responses. That's why you can see strange behavior in different browsers.
I recommend you to switch your work to canonical API tracking tools like Postman.

Third,
Hosting Ocelot in IIS environment is bad idea. Ocelot is not tested well for IIS scenarios. Because it is legacy architectural and hosting approach to deploy gateways at IIS machine.
You should know that IIS model is hard, complex and full of useless extra middleware modules of IIS pipeline for hosting full sized ASP.NET web apps with rich frontends like ASP.NET Razor and ASP.NET MVC. So, IIS is optimized for classic ASP.NET web apps.
So, you need to stop using IIS deployments, even for localhost scenarios, because it is not necessary.

Fifth,
Start using self-hosted Kestrel and Docker image deployments for your API gateway solution. Ocelot is optimized for lightweight API apps deployments in Kestrel web server.

Sixth,
Sometimes, and it is best practice for microservices, the client should send pre-flight aka OPTIONS request to wake up a service including gateway service. This is cloud-based problem of readiness and health of a service. Pre-flight request makes a service ready to process real requests (API warm up problem).
So, ensure you've sent OPTIONS request before real communication to a service.

Finally,
Could you upgrade/prepare new .NET 7 solution referencing Ocelot 19.0.2 package (.NET 7, latest release) please?
Use all my recommendations and let us know a new feedback please!

Good luck in your endeavor with Ocelot! 🧒

P.S. Ocelot team considers real exception/error logs of Ocelot app.
Next time you need to show real problem in Ocelot app logs.

@raman-m
Copy link
Member

raman-m commented Jun 15, 2023

Vladyslav,

Could you inform on this issue please?
Have you resolved the issue?

Please host gateway app by Kestrel, simple Visual Studio running of web host in console, and let us know the results please!
I believe there will be no delays in browsers.

The time is over. The issue cannot be in open state for a months. We need to communicate.

Let's find some workaround within one week please!
Your issue will be accepted or declined until June 23.

@vladkhnu
Copy link
Author

Sorry for the delay - we found the solution that makes us able to host Gateway on IIS. Before that we tried different combination of .Net and Gateway version with no luck. So the solution was to use Out-of-process hosting model instead of In-process - https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/out-of-process-hosting?view=aspnetcore-6.0

@raman-m
Copy link
Member

raman-m commented Jun 16, 2023

Aha...
You are right.
InProcess model is for Kestrel vs Docker, vs Console hosting.
OutOfProcess model is for IIS (Express) web server hosting.

Yeah, it was the root cause of the issue! 👍
Glad that your team has found this solution and adapt it to company hosting model.

Thanks for closing the issue!

@raman-m raman-m added wontfix No plan to include this issue in the Ocelot core functionality. and removed question Initially seen a question could become a new feature or bug or closed ;) needs validation Issue has not been replicated or verified yet needs feedback Issue is waiting on feedback before acceptance waiting Waiting for answer to question or feedback from issue raiser labels Jun 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Identified as a potential bug invalid Not actually an issue wontfix No plan to include this issue in the Ocelot core functionality.
Projects
None yet
Development

No branches or pull requests

2 participants