<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/14-to-2-seconds-how-i-improved-the-performance-of-an-endpoint-by-82---part-2-vehmvhldl" -->

---
title: 14 to 2 seconds: how I improved the performance of an...
description: Shares concrete .NET-specific tips used to cut an API endpoint's response time from 14 seconds to under 3, including warming up singleton dependencies via a...
canonical: https://daily.dev/posts/14-to-2-seconds-how-i-improved-the-performance-of-an-endpoint-by-82---part-2-vehmvhldl
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: 14 to 2 seconds: how I improved the performance of an endpoint by 82% - part 2 | daily.dev
og:description: Shares concrete .NET-specific tips used to cut an API endpoint's response time from 14 seconds to under 3, including warming up singleton dependencies via a...
og:url: https://daily.dev/posts/14-to-2-seconds-how-i-improved-the-performance-of-an-endpoint-by-82---part-2-vehmvhldl
og:image: https://api.daily.dev/og/posts/veHmVHLDl.png
og:image:alt: 14 to 2 seconds: how I improved the performance of an endpoint by 82% - part 2
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# 14 to 2 seconds: how I improved the performance of an endpoint by 82% - part 2

**[Code4IT](https://daily.dev/sources/code4it)** · 13 min read · 0 upvotes · 0 comments

## Summary

Shares concrete .NET-specific tips used to cut an API endpoint's response time from 14 seconds to under 3, including warming up singleton dependencies via a Postman pre-request script, choosing smaller data types, replacing string concatenation with StringBuilder (2784ms to 58ms), removing unnecessary async/await state machines, running operations in parallel with a custom ParallelHelper class, and a failed attempt to gain performance by moving from .NET Core 3.1 to .NET 5.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.code4it.dev/blog/improving-application-performance-part2>

## Questions this post answers

### Why does my ASP.NET Core API's first request take so much longer than subsequent ones?

Singleton-scoped dependencies in ASP.NET Core are instantiated during the first HTTP request rather than at application startup, so that first request absorbs the cost of building every singleton and its dependency graph. A workaround is exposing a warmup endpoint under a controller that uses dependency injection and calling it before real requests, for example via a Postman pre-request script.

_Developers chasing cold-start latency in .NET services can find more such fixes curated on daily.dev._

### How much faster is StringBuilder than string concatenation in a C# loop with 19000 iterations?

Using StringBuilder instead of plain string concatenation cut the loop time from 2784 milliseconds to 58 milliseconds, roughly a 98% speedup. This happens because strings are immutable in C#, so each concatenation creates a new string object, while StringBuilder appends into a single mutable buffer.

_daily.dev surfaces practical C# performance comparisons like this for teams optimizing hot code paths._

### When should I remove the async and await keywords from a C# method?

Remove async and await when a method's only operation is awaiting a single call and nothing happens afterward, since each async method generates a separate compiler-created state machine class that adds overhead. Simply returning the inner Task directly instead of awaiting and returning it eliminates that extra state machine while preserving identical behavior.

_Engineers tuning async C# code can keep discovering micro-optimizations like this through daily.dev._

## Similar posts on daily.dev

- [Unlocking True Vertical Scalability in .NET: Slashing API Latency from 10s to 3s on Azure AKS](https://daily.dev/posts/unlocking-true-vertical-scalability-in-net-slashing-api-latency-from-10s-to-3s-on-azure-aks-xvwrgh4t1) · Medium · 7 upvotes · 0 comments
- [Today I will… find hidden latency across a distributed .NET application](https://daily.dev/posts/today-i-will-find-hidden-latency-across-a-distributed-net-application-37hqr8by1) · Visual Studio Blog · 8 upvotes · 0 comments
- [Why ASP.NET Core Feels Fast Locally but Slow in Production](https://daily.dev/posts/why-asp-net-core-feels-fast-locally-but-slow-in-production-mtgpu8lqk) · C\# Corner · 42 upvotes · 0 comments
- [Performance Tuning in ASP.NET Core: Best Practices for 2025](https://daily.dev/posts/performance-tuning-in-asp-net-core-best-practices-for-2025-ffdkptjfa) · Syncfusion · 3 upvotes · 0 comments

---

Tags: [#performance](https://daily.dev/tags/performance), [#.net](https://daily.dev/tags/.net), [#c#](https://daily.dev/tags/c#), [#dependency-injection](https://daily.dev/tags/dependency-injection)

[View this post on daily.dev](https://daily.dev/posts/14-to-2-seconds-how-i-improved-the-performance-of-an-endpoint-by-82---part-2-vehmvhldl)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"14 to 2 seconds: how I improved the performance of an endpoint by 82% - part 2","url":"https://daily.dev/posts/14-to-2-seconds-how-i-improved-the-performance-of-an-endpoint-by-82---part-2-vehmvhldl","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/14-to-2-seconds-how-i-improved-the-performance-of-an-endpoint-by-82---part-2-vehmvhldl"},"datePublished":"2026-10-04T13:07:35.583Z","dateModified":"2026-10-04T13:17:05.946Z","description":"Shares concrete .NET-specific tips used to cut an API endpoint's response time from 14 seconds to under 3, including warming up singleton dependencies via a...","image":"https://media.daily.dev/image/upload/s--58gMhC4P--/f_auto/v1722860399/public/Placeholder%2012","thumbnailUrl":"https://media.daily.dev/image/upload/s--58gMhC4P--/f_auto/v1722860399/public/Placeholder%2012","isAccessibleForFree":true,"articleSection":"Code4IT","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Code4IT","logo":"https://media.daily.dev/image/upload/s--OaaG4G10--/f_auto,q_auto/v1791119049/logos/code4it?_a=BAMAMicg0","url":"https://daily.dev/sources/code4it"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/14-to-2-seconds-how-i-improved-the-performance-of-an-endpoint-by-82---part-2-vehmvhldl","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"performance,.net,c#,dependency-injection","timeRequired":"PT13M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Code4IT","item":"https://daily.dev/sources/code4it"},{"@type":"ListItem","position":3,"name":"14 to 2 seconds: how I improved the performance of an endpoint by 82% - part 2"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/14-to-2-seconds-how-i-improved-the-performance-of-an-endpoint-by-82---part-2-vehmvhldl#faq","mainEntity":[{"@type":"Question","name":"Why does my ASP.NET Core API's first request take so much longer than subsequent ones?","acceptedAnswer":{"@type":"Answer","text":"Singleton-scoped dependencies in ASP.NET Core are instantiated during the first HTTP request rather than at application startup, so that first request absorbs the cost of building every singleton and its dependency graph. A workaround is exposing a warmup endpoint under a controller that uses dependency injection and calling it before real requests, for example via a Postman pre-request script. Developers chasing cold-start latency in .NET services can find more such fixes curated on daily.dev."}},{"@type":"Question","name":"How much faster is StringBuilder than string concatenation in a C# loop with 19000 iterations?","acceptedAnswer":{"@type":"Answer","text":"Using StringBuilder instead of plain string concatenation cut the loop time from 2784 milliseconds to 58 milliseconds, roughly a 98% speedup. This happens because strings are immutable in C#, so each concatenation creates a new string object, while StringBuilder appends into a single mutable buffer. daily.dev surfaces practical C# performance comparisons like this for teams optimizing hot code paths."}},{"@type":"Question","name":"When should I remove the async and await keywords from a C# method?","acceptedAnswer":{"@type":"Answer","text":"Remove async and await when a method's only operation is awaiting a single call and nothing happens afterward, since each async method generates a separate compiler-created state machine class that adds overhead. Simply returning the inner Task directly instead of awaiting and returning it eliminates that extra state machine while preserving identical behavior. Engineers tuning async C# code can keep discovering micro-optimizations like this through daily.dev."}}]}
```

