Hi,
I would like to write High perfomance server using C#. It would be desirable to hear offers and advices on this subject

Dani AI

Generated

A short, practical checklist for building a high‑performance C# server that complements the thread comments from , , and .

Start at the right layer: if the server speaks HTTP, prefer a purpose-built HTTP host (Kestrel in modern ASP.NET Core) rather than reinventing the stack; for custom TCP/UDP protocols, design around asynchronous I/O and a zero-copy pipeline. See Kestrel for HTTP and System.IO.Pipelines for efficient stream processing: Kestrel docs and System.IO.Pipelines.

Key implementation practices

  • Use nonblocking async I/O (await/Task) or low-level async patterns (SocketAsyncEventArgs) to avoid per-connection threads.
  • Minimize allocations: use Span<T>/Memory<T>, ArrayPool<T> and buffer pooling; process bytes in-place with pipelines.
  • Tune runtime: enable Server GC for throughput, set sensible ThreadPool minimums during warmup, and avoid heavy locking or frequent context switches. See .NET GC fundamentals for configuration.
  • Prefer per-core/event-loop or connection-shard designs to reduce contention.

Measure and tune, don’t guess

  • Profile under realistic load before optimizing; use tools like PerfView or dotnet-trace to find allocation/CPU hotspots.
  • Load-test at scale (use realistic message sizes and concurrency), then iterate: sometimes a simple architectural change (batching, backpressure, or offloading TLS to a proxy) yields bigger wins than micro-optimizations.

Notes on tradeoffs

  • ’s OS point matters: modern .NET is cross‑platform and will use IOCP on Windows or epoll on Linux, so choose the OS you can tune and operate well.
  • ’s suggestion of third‑party components can speed development; validate them with benchmarks and profiling to ensure they meet your latency/throughput needs.

Checklist: pick the right host, use async + pipelines, pool buffers, enable server GC, profile, and iterate.

Recommended Answers

All 3 Replies

Sorry, clarify your question.

Writing a server in c#? You'd better be off with unix if it is a whole server :p.

http://www.linuxfromscratch.org/, if you have WAAAYYY too much time and patience on your hands.

If you don't mean server, but something like 'monitoring application', you'd better clarify your question.

Greetings, jens

Take a look at xf.server(www.kodart.com), that's a nice component for client server development in .NET

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.