R
R
Roman Vasilenko2012-11-14 14:22:31
linux
Roman Vasilenko, 2012-11-14 14:22:31

A single NIO channel or a pool of NIO channels for data exchange between services on the same server?

Hello!

I need two services to communicate as quickly as possible. Unfortunately, I cannot specify what the load will be, so we will not take this factor into account.

Services run on a computer with Ubuntu, written in Java, the exchange of information will take place in many packages of different sizes (from 50 bytes to 100 kilobytes). There may be more than two services and a one-to-many ratio.

For some reason, I cannot implement all the functionality in one service, just a few of them are needed.

Offhand, I see three options:
1. Open one channel between each two applications and exchange through it.
2. Open a fixed number of channels between applications and use them in turn.
3. Open a personal channel for each session, exchange through it, and close it at the end of the session.

What do you advise?

Thank you.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
I
ivnik, 2012-11-14
@ivnik

I would try sctp protocol, 7th java has support in jdk. Unlike tcp, the protocol is message-oriented (i.e. there is no need to encode data in some way in the case of tcp), you can set the receipt of messages as they arrive (rather than in order). There is one thing, however, the size of the message is limited to 64 kb. But it is enough to open only 1 connection. Look at the wiki: en.wikipedia.org/wiki/SCTP
If you use classic tcp and the latency requirements are strict, then most likely you would make a pool of channels.
PS JMX not considering due to performance requirements?

R
relgames, 2012-11-14
@relgames

If there is no JMS, then it is best to open one channel for each service-to-service connection
Opening channels with each message is very expensive, and keeping one channel for all services is also not very good - let's say service 1 sent 100 packets, and service 2 sent 1 packet , then until 100 packets from the first are read from the channel, 1 packet from the second will not be received.

S
synapse_people, 2015-09-28
@synapse_people

hessian won't work?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question