yusuke
❔ ✅ Need help to reuse RequireAuthorization() method on a different project
I was wondering if since I have project A project as the main project to have the login/register endpoints and I create a second project where I just use the RequireAuthorization() method on my endpoints, would the second project endpoints work if i supply a token from the first project? I'm trying to avoid needing to call httpclient to check if the token is valid.
Im using dotnet 8, EFCore, IdentityServer and postgres. I basically followed this video from Nick Chapsas https://www.youtube.com/watch?v=sZnu-TyaGNk&t=302s and was wondering if I can't have the RequireAuthorization method on my endpoints from my second project?
111 replies
❔ ✅ Can I make this faster or should I start looking at load balancing? tell me your api speeds too
Am I hitting the ceiling as far performance goes for web api and caching?
So I have a .net 3.1(have no choice about this) web api application that gets data from the database Postgres and gets queried based on odata query strings in the url. I am also using imemorycache. My average speed without cache is 50-100ms and with caching is 20-40ms, this is the total time it takes for the rest api to fire. I was wondering is there more I can do? Or am I at a point where I need to start load balancing? Thank you everyone.
From a previous post I learned a bit about k6, currently I am only able to handle 60 requests concurrently. I get status code 500 that the server is just unresponsive.
code:
[HttpGet]
[ODataRoute("Stocks")]
[ResponseCache(Duration = 600)]
public async Task<IActionResult> Get(ODataQueryOptions<Stock> options)
{
try
{
var key = "Stocks-" + HttpContext.Request.QueryString;
if (_memoryCache.TryGetValue(key, out List<Stock> query))
return await Task.FromResult<IActionResult>(Ok(query));
var settings = new ODataValidationSettings
{
MaxNodeCount = 10000
};
var cacheOptions = new MemoryCacheEntryOptions()
.SetSlidingExpiration(TimeSpan.FromMinutes(5))
.SetAbsoluteExpiration(TimeSpan.FromMinutes(10));
var stockQuery = _stockService.GetStock();
stocks = options.GetEntitiesFromODataQuery(stockQuery, settings);
_memoryCache.Set(key, stocks, cacheOptions);
return await Task.FromResult<IActionResult>(Ok(stocks));
}
catch (Exception exception)
{
throw new ApiGeneralException(exception.Message, exception);
}
}
225 replies