Netty High performance reason, Netty tuning

Source: Internet
Author: User
Tags memory usage serialization
From a large perspective, Netty performance is mainly reflected in: 1.io threading Model using reactor mode, synchronous non-blocking. This determines that more can be done with the least amount of resources. 2. Memory 0 copies use direct caching 3. Memory pool design application memory can be reused, mainly direct memory. The internal implementation is to manage memory allocations with a binary lookup tree. 4. The serialization processing socket reads and writes, avoids the lock, namely one specifies the socket the message is the serialization processing. This performance is better than multiple threads processing a single socket counterpart message at the same time, because multithreading can have locks. 5. Provide support for high performance serialization protocols such as Protobuf
Application Netty Tuning: 1. If you only want the handler to finish processing, to the next handler processing, then call: Channelhandlercontext Fireread, and so on. Direct through Channel.read or write will trigger the complete handler processing chain.
The message is automatically released when the 2.SimpleChannelInboundHandler is finished and all handler are processed. Channelinboundhandleradapter does not automatically release messages.
The 3.ServerSocketChannel loop defaults to a maximum of 16 client connections, mainly because the server has a large number of clients that guarantee higher throughput. Corresponding parameter: max_messages_per_read
4. Write_buffer_low_water_mark can be used to do flow control needs to apply call iswritable method, if return false temporarily write failure.
5. Direct memory usage, 0 copies. Direct memory block cache pool design.
6. Avoid multithreading in the memory block cache to get blocks of memory blocking competition, small block of memory size from the thread unique cache to get.
7.reactor mode core is to handle the most things with minimal resources, a reactor thread is responsible for viewing registered care events
8. Soft interrupt Linux 2.6.35 The above version can be set RPS, the main purpose is the processing of packets evenly scattered on each CPU. Improve network processing capabilities. 9. Set TCP parameters is mainly to receive buffer size: SO_RCVBUF, and send buffer size: so_sndbuf. Turn off the So_tcpnodelay for applications that require little delay.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.