How. NET handles high-concurrency sockets to build a high-performance, robust socket service

Source: Internet
Author: User
Tags hosting

1. Using SuperSocket

    • High-performance event-driven communication;
    • very simple to use; You just need to create a few classes to get a robust Socket server;
    • The built-in command-line protocol allows you to quickly create a network command-line interface server;
    • Powerful and high-performance protocol resolution implementation tools to simplify the analysis of network data;
    • Flexible configuration features and friendly configuration API;
    • Multi-listener support; Allows you to listen to multiple ports within a single server instance;
    • Support for multi-server instance hosting allows you to face complex deployment requirements;
    • application domain and process-level isolation can satisfy most of your hosting scenarios;
    • Built-in SSL/TLS encryption support;
    • Session-level Send queues allow you to send data concurrently through sessions and maintain high performance and controllability;
    • SuperSocket's command-handling mode makes your business logic clearer and more organized;
    • Excellent extensible API Support: Command filter, Connection filter, command Loader;
    • The replaceable log schema allows you to use your favorite log components;
    • Support for dynamic languages; Allows you to implement commands in a scripting language such as Python;
    • Compatible with Mono/linux to maintain binary level;
    • Support for Windows Azure;
    • Built-in Socket policy server that you can use directly for Flash or Silverlight clients;

Website address: http://www.supersocket.net/

SuperSocket level

SuperSocket Object Model Diagram

SuperSocket Request Processing Model

SuperSocket Isolation Model

See a question that says how to keep 5000-10000+ 's robust socket service.

Beginners are sure to open a thread for each connection to listen. It's a waste of resources.

It usually takes only a few threads (dynamically) to hold 3,000 long connection sessions.
"Open a new thread for each listener" This is a design error. You can use the asynchronous read of NetworkStream without blocking the thread in the absence of the message.

Depending on the operating system, the constraints of multithreading are also different. When you find that there are more than 1000 worker threads, or more than 800 IOCP (IO completion port) threads, you should quickly break down the server for maintenance.
First, there is a sense that using a few, more than 10 threads is enough to handle thousands of common business connections.
Some people say, "If I want to keep 1000 client connections, I have to open 1001 threads to receive Data", this is purely nonsense. Be sure to pay attention.

I say "worker threads" means the total number of worker threads used in your process, not Windows only.

In your windows, more than 1500 of the number of bus threads is a common thing. You can open your process manager to see the CPU metrics and see how many threads are currently being used in the switch. It's probably over 1500. However, you can monitor each individual process and see its number of threads, usually only about 10 (only 100 of the system threads).

And your server process, the number of worker threads should not be too high. Normally, only more than 10 threads are sufficient to handle thousands of of clients.

If you are using. NET development, you can use SuperSocket this is what I am currently developing more comprehensive, or with a more fastsocket, also good (related lighter).

How. NET handles high-concurrency sockets to build a high-performance, robust socket service

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.