Are sockets reliable?

Is it good to use sockets to send data between two servers, or should I use something like MQ to move data.

My questions are: are sockets reliable if I only need / guaranteed data delivery?

Are there any other solutions?

Thanks.

+6
sockets communication reliability qos
source share
8 answers

Sockets are an application-level API for performing network communication. The reliability of sockets depends on the network protocol that you choose when creating the socket. If you choose TCP / IP, you will get a "reliable" transmission ... to the limit. If you select UDP / IP, you will receive an โ€œunreliableโ€ transmission.

As indicated in other answers, TCP ensures that you do not lose or corrupt data to a specific point:

  • if there is a sufficiently long disconnect network or the sender or receiver, the TCP / IP connection is killed and you lose data if you do not take steps to connect.
  • if there is a level network, there is little chance that it will not be detected by checksums.

For higher levels of reliability than TCP / IP, you need to implement more sensitive checksums and guaranteed delivery mechanisms at the top of your application. Or use a message queue product that will make it very difficult.

So, the answer to your question is that it depends on how you use Sockets and at what level of reliability your system requires.

+12
source share

Sockets are as reliable as your implementation, and are based on basic hardware. If you donโ€™t need the hassle of providing a guaranteed delivery service (under what conditions 100% will never happen), a message queuing system is a good bet. The message queue will implement all the constants, queues, retries, etc. that you will need to implement yourself if you go with standard sockets.

+2
source share

You should probably use MQ if you need guaranteed delivery no matter what happens (for example, if the other side is disabled for maintenance) and you donโ€™t want to write all the logic yourself. Sockets are what you use to connect to the other side, regardless of whether that side is MQ or the ultimate recipient of the message.

+2
source share

Socket is reliable because every message runs on top of it, including MQ.

But you can add some guaranteed delivery with MQ to increase the reliability of your application. What is it? guaranteed delivery ensures that your message is processed at least once and not more than once by the consumer. Is the consumer disconnected? Is the producer disabled? Is the MQ server turned off? does the disk fall? thanks to MQ, no message will be lost, no matter what happens (provided that your administrator knows his work). In addition to this, if you reload the user, not a single message will be processed twice. This can be important if messages contain millions of dollars in transfers. But this does not guarantee that your message has been processed for a considerable time. and processing time is more important than guaranteed delivery, depending on your application.

It is up to you to choose the best way to communicate between servers depending on your needs. Guaranteed delivery delivery has both financial and operational costs, so it should be used only if necessary (for example, transfers in millions of dollars).

For most applications, you can achieve something that satisfies only by repeating your messages, and then crashing. But this is not a real guaranteed delivery only once and for all. do not try to implement it yourself, this is very difficult material, which only a few can achieve. It is recommended that you consider reprogramming software as complex as MQ or Apache AQ.

Hope this helps.

  • Jab
+2
source share

Sockets are a raw mechanism for transferring data. Everything else is implemented on top of this. In the OSI network model, they belong to layer 4. Although they provide a reliable end-to-end connection, they are rarely used as the final protocol, you almost always need to implement the application layer. What this will depend on your application (you need to transfer files or just send messages) and your network infrastructure.

+1
source share

If you use a stream socket , the TCP protocol ensures that data is not lost during transmission and is unlikely to be corrupted (although you need to decide if its 16-bit checksums are sufficient or if you need an application-level checksum mechanism).

What MQ systems provide, and what you may or may not need, is reliability

0
source share

Depending on the type of data, a simple web service may be the fastest solution. They are relatively easy to configure and verify. Although for some specific examples I need to know what data and environment you are using.

0
source share

It depends on the type of application you are developing. This is you writing a program in which you need a response or a response from a sent message, then TCP sockets are good. But, if you are running any workflow scenario, you must use message queues.

0
source share

All Articles