markvincze / rest-api-helpers

Collection of extensions for ASP.NET MVC helping implementing Rest Apis
20 stars 6 forks source link

Please update it according to asp.net core 3.1 #3

Open KamranShahid opened 4 years ago

KamranShahid commented 4 years ago

Please update it according to asp.net core 3.1

markvincze commented 4 years ago

Hey @KamranShahid,

I've stopped actively using and maintaining this library. But it doesn't contain much code, so I'd recommend you just taking the pieces of code you use, and adding them to your own APIs or base library.

ggonzalez94 commented 4 years ago

Hi! @markvincze I have the need to do something very similar to what you have done in the ApiWarmer. Do you still take that approach or do you do something different for aspnet core 3.1? Im experiencing major latency on first requests on almost all endpoints(not only on first request overall). We are using aspnet boilerplate and the issue seems related to CastleWindsor and that we are abusing injection overall, but the best solution that comes to my mind right now is calling GET endpoints for all controllers of the API at startup. Any thoughts?

markvincze commented 4 years ago

Hi @ggonzalez94,

(Sorry for the late response.) Yeah, I still haven't found a better way to avoid the first request slowness. The only other solution we tried besides the ApiWarmer in this repo, is to implement a common base controller class, something like this:

    public abstract class WarmUpController : Controller
    {
        [HttpGet("warmup")]
        public ActionResult WarmUp()
        {
            return Ok();
        }
    }

We make all of the real controllers derive from WarmupController. And we run a piece of code on application startup, which goes over all the controllers, and call their /warmup method. (And this is connected to our Kubernetes health probe configuration, so that the application doesn't get any actual traffic until this happens.)
This seems to work nicely in practice.

KamranShahid commented 4 years ago

Thanks @markvincze Will try this