API 版本控制位居 CPU 首位
我使用默认的 .Net CPU 版本控制来处理 API 的 2 个版本,但我在 AWS ECS 监视器上注意到我的 CPU 使用率稳定达到 100%,但事实不应该是这样。
我正在使用 Microsoft 的所有样板代码来配置和处理此版本控制。
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;
});
控制器:
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)
{
// ...
}
}
}
有人遇到过这个问题吗?
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
Have anyone faced this issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论