0

I use default .Net CPU Versioning to handle 2 versions of my API, but I noticed on AWS ECS monitors that my CPU usage is hitting steadily 100%, which should not be the case.

I'm using all boilerplate code from Microsoft to configure and handle this versioning.

Startup.cs:

        public void ConfigureServices(IServiceCollection services)
        {
            // ...

            services.AddApiVersioning(config =>
            {
               config.DefaultApiVersion = new ApiVersion(1, 0);
               config.AssumeDefaultVersionWhenUnspecified = true;
               config.ReportApiVersions = true;
            });

            services.AddVersionedApiExplorer(p =>
            {
               p.GroupNameFormat = "'v'VVV";
               p.SubstituteApiVersionInUrl = true;
            });

Controller:

using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Swashbuckle.AspNetCore.Annotations;
using System.Linq;
using System.Threading.Tasks;

namespace API.src.v1.controller
{
    [ApiVersion("1.0")]
    [Route("api/v{version:apiVersion}/Model/")]
    [ApiController]
    public class AuthorizerController : ControllerBase
    {
        [HttpGet("models/{id}")]
        [SwaggerOperation(Summary = "Retrieve model by Id")]
        public async Task<ActionResult<Model>> GetModel([IsUUID] string id)
        {
            // ...
        }
    }
}

With that, I'm consuming 100% average of CPU enter image description here

Have anyone faced this issue?

Thiago Cardoso
  • 503
  • 7
  • 13
  • Q1: What version of API Versioning are you using? Q2: Are you saying this CPU utilization only happens when you add API Versioning (but not without)? The one and only case this has ever been known to happen is in a dictionary contention [issue](https://github.com/dotnet/aspnet-api-versioning/issues/306); however, that was fixed in 2.3+ four years ago. With a bit more information, I can provide a complete answer. – Chris Martinez Apr 06 '22 at 01:45
  • @ChrisMartinez I saw this issue, but to be quite frank I understood nothing. I mean, what should I put in a dictionary? Where to put it? I really got nothing from it – Thiago Cardoso Apr 07 '22 at 20:45
  • you weren't supposed to _do_ anything. I was simply pointing out that a **long** time ago there was such an issue, but it has been long resolved. If you can clarify which package version you are using, that would be a good start. If you can confirm, this only happens after adding API Versioning, that would also be helpful. – Chris Martinez Apr 08 '22 at 21:14

0 Answers0