Turn from:http://blog.csdn.net/mindfloating/article/details/8622930performance evaluation and analysis of Netty and Mina in the popular NIO FrameworkTest method
Using Mina and Netty to implement a echoserver based on NIO to test the performance of network packets of different sizesTest environment
Client-server: model Name:intel (R) Core (TM) i5-2320 CPU @ 3.00ghz cache size:6144 kb cpu cores:4j
application of CPU resource tension, while CPU-intensive tasks can be referred to the thread pool in the business processing logic, such as Scenario 5. This scenario has a less obvious drawback, that the session is not prioritized, and all sessions are treated equally evenly across all the threads, which can cause the priority low-resource session to clog the high-priority session, But it seems that Netty
First, the concept
The unit of the network transmission is bytes, how to convert the application's data to bytes, and the conversion of bytes to the data of the application, it is necessary to mention the encoder and decoder we introduced in this article.
The components that convert the application's data to a network format and the data that transforms the network format into an application are called enc
Netty as a network component in the Java ecosystem has a pivotal position, all kinds of open source middleware use Netty for network communication, such as Dubbo, ROCKETMQ. It can be said that Netty is the encapsulation of Java NIO, such as the encapsulation of BYTEBUF, channel, etc. to make network programming easier.There are two things to know before you start
A good site for http://ifeve.com/
Directory of the authoritative guide for Netty , May 17, 2014
May 17, 2014 "Netty authoritative guide"--aio created timeclient source analysis (0)
May 16, 2014 "Netty authoritative guide"--nio client sequence diagram (0)
May 15, 2014 "Netty authoritative guide"--service End s
The first step of the first Netty application
Service side (Serverchannel)
Echoserverhandler simple receive print, return the received message to the sender
Flushes all pending messages to the remote node
After closing the channel, the operation is completed
Service-side (server)
Echoserver creating Eventloopgroup, Serverbootstrap
Speci
multiple Channel-worker ; I also need to study an abstract I/O thread to extend all transmission modes. At present we have a lot of duplication between the Socket,datagram and the SCTP. If the calling thread is not an I/O thread, Netty will trigger the uplink message in the I/O thread. This approach allows the user to add the Sendupstreamlater () method to the I/O thread in Channelpipeline and channelhandlercontext to trigger the uplink message. But
PROTOBUF is the abbreviation for Google's protocol buffers, which is used to convert between structured data and bytecode (serialization, deserialization), which is generally applied to network transmission and can support multiple programming languages.Protobuf How to use here no longer introduced, this article is mainly introduced in Mina, Netty, twisted How to use PROTOBUF, do not know protobuf students can go to the exam I also have a blog post.In
section will help you understand these ways and find the best way to meet your needs.6.4.1 Handling Inbound ExceptionsWhen an exception is thrown during input event handling, the exception will start propagating in the channelpipeline where the exception is triggered, in order to handle such an exception, Channelinboundhandler You need to rewrite the following method in your Channelpipeline implementationThe following code listing shows you a simple exception handling example: Close the channel
First, the conceptLet's take a look at some of the concepts presented in this blog post (Channel, Channelhandler, Channelpipeline, Channelhandlercontext, channelpromise):Channel: The carrier of the data passed in or out of the Netty;Channelhandler: A container for application logic that processes inbound and outbound data in Netty;channelpipeline: The container o
=NewEchoserver (20000); Try{Server.start (); } Catch(Exception e) {e.printstacktrace (); } }}Create Channelhandler, actually Channelhandler The main code that handles the actual business PackageCom.cw.demo.netty.server.channelhandler;ImportIo.netty.buffer.ByteBuf;Importio.netty.buffer.Unpooled;ImportIo.netty.channel.Channel;ImportIo.netty.channel.ChannelHandlerContext;ImportIo.netty.channel.ChannelInboundHandlerAdapter;ImportIo.netty.util.ReferenceCountUtil;ImportJava.nio.charset.Charset;/***
extension1:haproxy provides master and slave equipment2:nettyserver need to maintain shared data block security, plus synchronization may degrade performance, or increase the queue mechanism for the data block, the use of multi-threaded daemon mode code.3: The client is very numerous and horizontally increases the nettyserver.4: If the number of clients is very large, the database uses read and write separate master-slave library, the Business of carding division, read and write in different da
One, what is Netty?1,netty is a Java open source framework provided by JBOSS.2,netty is a jar package that can be developed using the All-in-one jar package.3,netty does not need to run on a server like Tomcat, he is building a server alone.4,netty can build HTTP server, soc
Using Netty to implement simple RPC, mainly Netty, so caching, service exposure, and so on are all using caching instead of
Netty is using 5.0+ so it may be a little different from 4.0+ ...
Let's look at the main classes first:
From two aspects, one is the Netty part, Netty
One, Netty+protocol buffers brief descriptionNetty is one of the most popular NIO frameworks in the industryAdvantages:1) Easy to use API, low development threshold;2) Powerful, preset a variety of codec functions, support a variety of mainstream protocols;3) Strong customization ability, the communication framework can be flexibly expanded through Channelhandler;4) High performance, through the comparison with other industry mainstream NIO framework,
Netty itself supports heap memory and direct memory on memory allocations, and we generally choose Direct memory, which is also the default configuration. So to understand the release of Netty memory we have to look at the release of direct memory first.Java Direct Memory ReleaseLet's take a look at how direct memory is used.ByteBuffer.allocateDirect(capacity)The applic
If you run timeclient, you must note that the application does not exit automatically, but it only keeps meaningless running. You can find that there are some running I/O threads. To close these I/O threads and let the application exit gracefully, you need to release the resources allocated by channelfactory.
A typical network application is disabled in the follo
Netty Server Threading Model OverviewBlog Category:
Netty
Java
Everything starts with the serverbootstrap.ServerBootstrapis responsible for the initial session Netty server, and starts listening for socket requests on the port.Java code
Bootstrap bootstrap = new Serverbootstrap (
New Nioserversocketchannelfactory (
Executors.newcachedthr
Netty is the core of the reactor thread, the corresponding project uses a wide range of nioeventloop, so what is the nioeventloop inside exactly what is doing? How does Netty ensure efficient polling of event loops and timely execution of tasks? And how to gracefully fix the NIO bug of the JDK? With these questions, this article will discovering to take you through the truth about
"Original" https://github.com/code4craft/netty-learning/blob/master/posts/ch3-pipeline.mdChannel is the core of understanding and using Netty. The channel involves a lot of content, here I use the introduction method of the way. In this article, we mainly introduce the pipeline implementation mechanism in the channel section. In order to avoid boring, borrow "dream space" of "dream" concept, I hope you like
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.