Home > Net >  Keep the heart at any time waiting for the server command, use the Socket and Http which good
Keep the heart at any time waiting for the server command, use the Socket and Http which good

Time:01-28

Say first scene, currently has a server, and 400 clients,
Client needs to constantly to equipment information (information such as battery, charging status, task schedule),
Server can have certain distributed task (perhaps control to restart a device, or control a certain equipment shutdown),
.
The current solution is, the service side wrote a asp.net API interface, the client always reported,
Originally, I am a report, once per second, the load is too big, reduced to 10 seconds to report for the last time,,, later changed to 30 seconds to report time,
And as a consequence, issued an order of a service is no longer in a timely manner, such as a page I saw devices, the need to capture,
By this time the service side issued a screenshot of the order, bad luck, after 30 seconds, the screen picture early changes,
.
At that time I thought, there are other solutions, the socket can be, should be in real time,
This contact is not much, I only study, made several TCP and udp demo, not really in the aspects of load,
.
Write here, suddenly feel problem some slanting, the forehead, the load of the socket, should with the client by the frequency with the reported data,
I suppose, the socket client report the frequency of the data and HTTP,
More accurately, I keep long links, only want to achieve two purposes: (1, heartbeat, whether live monitoring equipment, 2, command issued in a timely manner),

I don't know the socket to keep long link mechanism, do not know that has been connected together, will have the data exchange, will increase the load, since the ask a question,
If there is because they don't understand and ask more silly, also please forgive me,,, alas,

CodePudding user response:

WebSocket

CodePudding user response:

This scenario is the need for a TCP server, rather than the HTTP server
If due to other reasons must be HTTP, also can use the websocket

Hundreds of long connection to the server is not what is it

CodePudding user response:

Give a priority task, real-time task priority, high priority, free routine tasks in execution,

So is a reality, "preferred customer complaints handling, regular development delay"

Can also like reality, separate the complaint and the development, the company is also commonly in so doing, have development to do, to do support to deal with complaints

So, the newly built "support group" -- -- -- -- -- -- -- -- -- redis, etcd, consel, your "complaints" (that is, you say regular information report) directly this way,

Need of real-time control, in addition, sokect, kafaka, mq, websockect, RPC, all personal advice kafaka, mq, because or "separate" train of thought, complex network, it is best not to direct, separate processing, of course it is asynchronous, this isn't what way, after all the network there, delay, there you are to use teamview remote management, as well as delay, network is bad, teamview 30 seconds delay don't also is very normal

CodePudding user response:

Battery, charging status -- -- -- -- -- - is regular, high frequency, the data can be abandoned, system needs, but it doesn't have to be strictly implemented, 10 seconds before the power of the most important, in fact, not important, so even if 10 seconds before the battery I received is no problem, only you now the latest battery I received, of course, if I received the latest 2 minutes, I will ask, are you still gone

CodePudding user response:

Same as above, what are you doing control?
Personal advice to build the TCP server

CodePudding user response:

Know the websocket you will know how bad ajax long training in rotation and HTTP connection with the

CodePudding user response:

You need a server push this requirement, but not push HTTP, can use the websocket or write a TCP server

CodePudding user response:

1. TCP bring live mechanism, but it is said that have a pit, so, the most insurance method, is your own heartbeat package, in fact is the time to send a parcel to go, so you can know whether the equipment in time in the online, because sometimes, may be a network failure, or equipment failure, the possibility is very much, you only need to monitor the client's background package, more than one time, 2 s didn't receive the data, for example, can think rolled off the production line equipment.

2, 400 for a tcpserver connection is something at the same time

So, think about your needs, please don't use the HTTP protocol, directly use TCP protocol, with c/s do a tcpserver can directly
  • Related