Scenario : n number of vehicles create tcp socket connections with the tcp server. Server then dumps incoming messages to a DB. Admins can send commands to the vehicles through the sockets as well so sockets have to be persistent.
Problem : Currently, there is only single tcp server and DB sever.
Question : How to make this architecture scalable in .NET. We want to have more tcp servers and DBs. Whats the best method/technology stack.
Thanks
1 Answer 1
I believe what you are looking for is a messaging infrastructure, there are several well established libraries/products in this section( e.g. RabbitMQ, ZeroMQ, ...)
almost all of them supports patterns for distributing message across several producers/consumers, which makes writing scalable applications easier, ZeroMQ is something in the middle and the usage is very similar to sockets.
Aside from library selection I suggest you to have a look at ZMQ Guide, it describes patterns and best practices for writing an scalable application.
Socket.Begin/EndXXX
,Socket.XXXAsync
(not task-based),NetworkStream.XXXAsync
(task-based), etc.. The non-task-basedXXXAsync
approach has the best out-of-the-box scalability, but in every case scalability depends on a lot more than just the network API being used. As stated, your question is too broad. Try something, see how it works, and then if you have problems, ask a specific question about how to improve on what you have.