Git Product home page Git Product logo

csharp-tcp-server-benchmark's Introduction

CSarpで高速なTCP Serverの実装を行うための調査

CSharpでTCP Serverを実装するためのアプローチが複数提供される中で、現時点ではawait/asyncのモデルがパフォーマンスとメンテナンスの両面おいて優れていると聞く
それが「どの程度」優れているかを調査する

比較対象

  1. await/asyncを使った非同期モデル(非同期TcpClient)
  2. BeginRecieve()などを使った非同期モデル(非同期Socket)
  3. ThreadPoolを使った同期的モデル(同期ThreadPool)

検証環境

同時接続数 : 1,000接続 パケット本体 : 1,000byte 1接続辺りリクエスト数 : 1,00回 CPU : Core i7 3770 Memory: 16G OS : Windows 7

検証結果

実装方法 行数 難易度 秒間リクエスト数
async/await 101 易しい 56,916
非同期ソケット 170 難しい 68,272
ThreadPool 97 易しい 51,129

考察

  1. ThreadPoolはThreadPool.SetMinThreads()でworkerスレッドを同時接続数と同等程度に設定しないと上記の性能が出ない
  2. async/awaitは予想よりも遅い、特に非同期ソケットと比べると有意な差が見られる

csharp-tcp-server-benchmark's People

Contributors

pyramidmine avatar hythof avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.