© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•10mo ago•
100 replies
Juicy

API performance acting weird

I dont get why sometimes when im calling my endpoint the api is taking 20 ms but then bam the occasional 500ms or even 7600ms up to ive seen even 9000ms response for the same endpoint, just by calling the same endpoint with a few second delays. Is it something im doing wrong code-wise? For example this endpoint:

[HttpGet("{productId:guid}/all")]
    public async Task<IActionResult> GetLicensesOnProduct(Guid productId)
    {
        var licenses = await licenseService.GetLicensesOnProduct(productId);
        var response = licenses.Select(license => new LicenseResponse(
            license.Id,
            license.Key,
            license.Duration,
            license.Note,
            license.DurationUnit,
            license.Role,
            license.CreatedByInternalUserId,
            license.UserId,
            license.CreatedOnUtc,
            license.RedeemedOnUtc,
            license.ExpirationDate,
            license.Type,
            license.State));

        return Ok(response);
    }
[HttpGet("{productId:guid}/all")]
    public async Task<IActionResult> GetLicensesOnProduct(Guid productId)
    {
        var licenses = await licenseService.GetLicensesOnProduct(productId);
        var response = licenses.Select(license => new LicenseResponse(
            license.Id,
            license.Key,
            license.Duration,
            license.Note,
            license.DurationUnit,
            license.Role,
            license.CreatedByInternalUserId,
            license.UserId,
            license.CreatedOnUtc,
            license.RedeemedOnUtc,
            license.ExpirationDate,
            license.Type,
            license.State));

        return Ok(response);
    }


    public async Task<IEnumerable<License>> GetLicensesOnProduct(Guid productId)
    {
        var product = await productRepository.GetByIdAsync(productId);
        if (product is null)
        {
            throw new ProductNotFoundException(productId);
        }

        var licenses = await licenseRepository.GetAllAsync(productId);
        return licenses;
    }
    public async Task<IEnumerable<License>> GetLicensesOnProduct(Guid productId)
    {
        var product = await productRepository.GetByIdAsync(productId);
        if (product is null)
        {
            throw new ProductNotFoundException(productId);
        }

        var licenses = await licenseRepository.GetAllAsync(productId);
        return licenses;
    }


    public async Task<IEnumerable<License>> GetAllAsync(Guid productId, CancellationToken cancellationToken = default)
    {
        return await dbContext.Set<License>()
            .Where(l => l.ProductId == productId)
            .ToListAsync(cancellationToken);
    }
    public async Task<IEnumerable<License>> GetAllAsync(Guid productId, CancellationToken cancellationToken = default)
    {
        return await dbContext.Set<License>()
            .Where(l => l.ProductId == productId)
            .ToListAsync(cancellationToken);
    }
image.png
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements
Next page

Similar Threads

✅ my program is acting weird
C#CC# / help
2y ago
❔ Weird performance behavior with sorting algorithms.
C#CC# / help
3y ago
Function acting funny
C#CC# / help
2y ago
✅ How to parse this weird API ?
C#CC# / help
3y ago