Browse Source

update article

pull/24003/head
Ebicoglu 11 months ago
parent
commit
72bb81a791
  1. 12
      docs/en/Community-Articles/2025-10-17-Optimize-Your-App-For-Production/Post.md
  2. BIN
      docs/en/Community-Articles/2025-10-17-Optimize-Your-App-For-Production/cover.png
  3. BIN
      docs/en/Community-Articles/2025-10-17-Optimize-Your-App-For-Production/image-20251019160137674.png
  4. BIN
      docs/en/Community-Articles/2025-10-17-Optimize-Your-App-For-Production/image-20251019160303146.png
  5. BIN
      docs/en/Community-Articles/2025-10-17-Optimize-Your-App-For-Production/image-20251019160355415.png
  6. BIN
      docs/en/Community-Articles/2025-10-17-Optimize-Your-App-For-Production/image-20251019160413738.png
  7. BIN
      docs/en/Community-Articles/2025-10-17-Optimize-Your-App-For-Production/image-20251019160500983.png

12
docs/en/Community-Articles/2025-10-17-Optimize-Your-App-For-Production/Post.md

@ -1,5 +1,7 @@
# Optimize Your .NET App for Production (Complete Checklist)
![cover](D:\github\volosoft\abp\docs\en\Community-Articles\2025-10-17-Optimize-Your-App-For-Production\cover.png)
**Tags:**
> #optimize #dotnet #aspnetcore #performance #kestrel #best-practises
@ -18,6 +20,8 @@ I see way too many .NET apps go to prod like it’s still “F5 on my laptop.”
## 1) Publish Command and CSPROJ Settings
![image-20251019160137674](D:\github\volosoft\abp\docs\en\Community-Articles\2025-10-17-Optimize-Your-App-For-Production\image-20251019160137674.png)
Never go to production with debug build! See the below command which publishes properly a .NET app for production.
```bash
@ -47,6 +51,8 @@ dotnet publish -c Release -o out -p:PublishTrimmed=true -p:PublishSingleFile=tru
## 2) Kestrel Hosting
![image-20251019160303146](D:\github\volosoft\abp\docs\en\Community-Articles\2025-10-17-Optimize-Your-App-For-Production\image-20251019160303146.png)
By default, ASP.NET Core app listen only `localhost`, it means it accepts requests only from inside the machine. When you deploy to Docker or Kubernetes, the container’s internal network needs to expose the app to the outside world. To do this you can set it via environment variable as below:
```bash
@ -95,6 +101,8 @@ app.Run();
## 3) Garbage Collection and ThreadPool
![image-20251019160355415](D:\github\volosoft\abp\docs\en\Community-Articles\2025-10-17-Optimize-Your-App-For-Production\image-20251019160355415.png)
### GC Memory Cleanup Mode
GC (Garbage Collection) is how .NET automatically frees memory. There are two main modes:
@ -130,6 +138,8 @@ ThreadPool.SetMinThreads(200, 200);
## 4) HTTP Performance
![image-20251019160413738](D:\github\volosoft\abp\docs\en\Community-Articles\2025-10-17-Optimize-Your-App-For-Production\image-20251019160413738.png)
### HTTP Response Compression
`AddResponseCompression()` enables HTTP response compression. It shrinks your outgoing responses before sending them to the client. Making smaller payloads for faster responses and uses less bandwidth. Default compression method is `Gzip`. You can also add `Brotli` compression. `Brotli` is great for APIs returning JSON or text. If your CPU is already busy, keep the default `Gzip` method.
@ -184,6 +194,8 @@ var json = JsonSerializer.Serialize(dto, MyJsonContext.Default.MyDto)
## 5) Data Layer (Probably Where Most Apps Slow Down)
![image-20251019160500983](D:\github\volosoft\abp\docs\en\Community-Articles\2025-10-17-Optimize-Your-App-For-Production\image-20251019160500983.png)
### Reuse `DbContext` via Factory (Pooling)
Creating a new `DbContext` for every query is expensive! Use `IDbContextFactory<TContext>`, it gives you pooled `DbContext` instances from a pool that reuses objects instead of creating them from scratch.

BIN
docs/en/Community-Articles/2025-10-17-Optimize-Your-App-For-Production/cover.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 428 KiB

BIN
docs/en/Community-Articles/2025-10-17-Optimize-Your-App-For-Production/image-20251019160137674.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 352 KiB

BIN
docs/en/Community-Articles/2025-10-17-Optimize-Your-App-For-Production/image-20251019160303146.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 354 KiB

BIN
docs/en/Community-Articles/2025-10-17-Optimize-Your-App-For-Production/image-20251019160355415.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 309 KiB

BIN
docs/en/Community-Articles/2025-10-17-Optimize-Your-App-For-Production/image-20251019160413738.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 323 KiB

BIN
docs/en/Community-Articles/2025-10-17-Optimize-Your-App-For-Production/image-20251019160500983.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 366 KiB

Loading…
Cancel
Save