Netty and mian comparison report
I. Data Test report
Brief description: 1. Start the server and wait until the client is connected
2. The client sends a link request. When the link is connected, record the current time and send about 50 m data to the server, 1 kb each time.
3. When the server receives the link and receives the data for the first time, it records the current time.
4. The server returns the received data to the client. When the server receives more than 50 m of data, it stops receiving and records the current time.
5. When the received data volume on the client exceeds 50 MB, record the current time. Terminate the link.
6. the execution time of the server and client is obtained.
Netty
Mina
Server
Client
Server
Client
First time
5076
5349
5051
5236
Second
5375
5490
4902
4976
Third time
5521
5280
4953
5053
Fourth
5367
5508
4980
5214
Note: When the transfer volume reaches MB, mina throws an exception: java. lang. OutOfMemoryError: Java heap space
Result: mina is more efficient and netty is more stable.
2. Comparison between codec and handler
The following is my practice. There may be other solutions.
1. Codec comparison
You can create an instance using the mina Decoder (codec) as follows:
1) create a codec instance for each received data
2) create a codec instance for all client connections
You can create an instance with the netty decoder as follows:
1) create a codec instance at each link
2) create a codec instance for all client connections
2. Handler comparison
The handler of Mina can create an instance with the following options:
1) create a codec instance for all client connections
You can create an instance with the Netty decoder as follows:
1) create a handler instance at each link
2) create a handler instance for all client connections
Iii. Document comparison
1. There are many netty and mina documents, but the mina documents are incomplete and the netty documents are clear.
Iv. UDP Transmission
1. netty exposes the non-connection characteristics of UDP. While mina abstracts UDP at an advanced level and regards UDP as a connection-oriented protocol, netty needs to manually handle the sequence, packet loss detection, resend, and so on.
V. Protocol Support
Netty architecture:
Mina Architecture
Not found, but there should be similar technical support.
Online rating:
1. mina's kernel is too closely linked with some features, making it impossible for users to break away when they don't need these features, and the performance will decline. netty solves this design problem.
2. the basic architecture of netty is almost the same as that of mina, and its usage is similar to that of idea. However, there are many details to improve (for example, the IoSession of mina calls flip () every time it is written (), netty channels are not used, and zero copy is supported ).
3. netty is easier to use than mina.
4. about UDP connections: mina processes TCP and UDP as "connected". a udp request generates a new IoSession according to the address, and the expiration time is 1 minute, the advantage of doing so is obvious, but it is not good for projects with performance requirements. For a connectionless thing cache for 1 minute, it may be a white cache most of the time and useless. In this case, Mina may use continuous decoding. For example, if a package is too large and has been transmitted twice, this design should be a big headache for udp.
Author: zhanghua.1199