Netty: A non-volatile client/server photo frame

Source: Internet
Author: User
Tags fsm starttls

Netty: A non-volatile client/server photo frame

Chszs. Please note the reprint. Blog home:Http://blog.csdn.net/chszs

Netty is an asynchronous event-driven network application framework that brings some new vitality to the development of Java Web applications. The Netty is made up of protocol server and client. Can be used for high-speed development of maintainable high-performance software. The Netty application framework and its tools simplify network programming and are maintained by the Netty community.


Netty is also categorized as a nioclient/server framework. It can be used to develop network applications at high speed and ease. Makes network programming for TCP and UDP sockets server simpler and more reasonable.

The built-in HTTP protocol supports WebSocket, which allows the framework to run inside the servlet container. The new Netty supports both non-clogging I/O and blocking I/O communication at the same time.

Features of the Netty:

1. The transport Service contains: Sockets and datagrams, HTTP channels, virtual machine internal pipelines

2. The protocol supports the following extensions: HTTP, Web sockets, Google Protocol Buffer, ssl-starttls, large file transfer, RTSP, zlib or gzip compression, binary protocols, other legacy text formats

3. Core: Scalable event model, unified Communications API, 0 copy-capable byte buffer

Netty Design:

Designed for multiple transport types, Netty integrates a unified set of APIs, plug-in, and non-clogging sockets. The event model of the Netty is extensible. Be able to isolate the point of concern clearly. The threading model of Netty provides the flexibility to choose between a single thread or class Seda. And the thread is high can be defined by itself, the support of the datagram to achieve a true non-connected communication, Netty pipeline abstraction and security thread, dynamic variability of the combination, so that the framework has been strongly supported.

Note: SEDA, which is staged event driven Architecture, is a staged, events-driven architecture.

The idea of Seda is to cut a task that was previously completed by one thread into a relatively independent, multiple phase. Each stage is run by a dedicated set of threads. The phases are used to interact with the queue.

In Seda way, only in the concurrency increase to a certain extent. When concurrency becomes a system bottleneck, talent embodies value.

In the case of a single operation, because of the queue's delivery. The delay must have been rising.

Be able to participate in this paper "Seda:an Architecture for well-conditioned, scalable Internet Services"

Seda is an excellent high performance Internet server architecture model at UC Berkeley, designed to support large-scale concurrency processing, simplify system development, support process monitoring, and support system resource management.

Two network server architecture models that are now widely used:

1) Multithreaded server (threaded server)

How it works: for each request. Dispatcher creates and assigns a thread for it, which is responsible for the processing of the request. This method is also named (thread-per-request).


Strengths: The operational granularity is the entire processing process and the processing logic is clear. Easy to develop.


Cons: When the processing request continues to be added. Can cause too many threads to run concurrently. Excessive number of threads can lead to excessive overhead on system thread scheduling and resource contention. resulting in a sharp decline in system performance. resulting in reduced system processing power.


Improvement measures: Introduction of thread pool (bounded thread pools)
The system can only create a certain number of threads at most.

When all the threads are running saturated. The newly arrived processing request can only wait. or be abandoned.
Cons: Run granularity is still the complete process. It is difficult to detect the root cause of system performance bottlenecks and make corresponding adjustments.

2) event-driven concurrency processing (event-driven Concurrency)

The processing process is cut into multiple steps and each step is implemented as a finite state machine (FSM).
How it works: All processing requests Enter the system as an event. The scheduler is responsible for passing it to the corresponding FSM.

The processing results of the FSM are also output to scheduler in event form. The new event will be forwarded to the next FSM again by scheduler until processing is complete.


Strengths:
1, with the addition of processing capacity, the system load is linear growth.

When the system saturation processing capacity is reached. The processing power of the system does not degrade.
2, because the processing steps independently realized, easy to conduct system monitoring and adjustment.
Disadvantages:
The design and implementation of scheduler is too complex, and the logic changes for different applications and systems require different implementations.


Seda Architecture

(Approximate to Event-driven Concurrency, but none of the scheduler) separate each processing step into a stage.


Stage structure:
1) An event Queue that accepts input;
2) an event Handler written by an application developer;
3) A controller is used to control the running process.

Contains the number of concurrent threads, number of batches, and so on;
4) A thread pool is used for concurrent processing;
The input to the stage is obtained through the event queue. The output of the stage is pushed to the event queue in the other stage as an event. This connection relationship between stages is specified by the application developer.
The problem: The Event queue reduces the coupling between modules, but decreases the response speed.



Performance and effectiveness:

The Netty not only provides good stability, but also provides better throughput and lower latency performance, limiting memory replication to the minimum requirements, and the 0 copy-capable byte-buffer feature enables the kernel to manage DMA replication. This reduces the burden on the CPU and the system bus, and improves the effectiveness of the framework.


Scalability and Integration:

Netty has the ability to expand. Support extends to thousands of connection types. And there is no performance bottleneck at the same time that the validity is maintained. The reliability of these connections is very high and will not fail. Netty is easy to scale and build. Netty also provides flexible integration capabilities that can be integrated with environments such as Linux, Java, C #, C + +, Python, and more.


Security: Netty provides complete SSL/TLS and STARTTLS support.

Netty Official offers a number of guides, documentation, and Javadoc and samples for developers to refer to.

Netty's latest stable version is the 4.0.23 version.

: http://dl.bintray.com/netty/downloads/netty-4.0.23.Final.tar.bz2

Copyright notice: This article blog Chszs original articles, blogs, without consent may not be reproduced.

Netty: A non-volatile client/server photo frame

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.