21-2 Netty之初次见面
读分两步:1.把我们的数据从IO流里读出来,放在我们的缓存区,
2.再从缓冲区读到堆里面。
数据会经历两次才会到达堆内存,数据量很大就会造成资源的浪费
netty使用了nio的零拷贝,接收数据传输数据开辟新的堆内存,数据从io直接读到开辟新的堆内存中
官网:https://netty.io/
Netty is an asynchronous event-driven network application framework
for rapid development of maintainable high performance protocol servers & clients.
翻译:Netty是一种异步事件驱动的网络应用框架,用于快速开发可维护的高性能协议服务器和客户端。
Netty is an NIO client server framework which enables quick and easy development of network applications such as protocol servers and clients. It greatly simplifies and streamlines network programming such as TCP and UDP socket server.
'Quick and easy' doesn't mean that a resulting application will suffer from a maintainability or a performance issue. Netty has been designed carefully with the experiences earned from the implementation of a lot of protocols such as FTP, SMTP, HTTP, and various binary and text-based legacy protocols. As a result, Netty has succeeded to find a way to achieve ease of development, performance, stability, and flexibility without a compromise.
翻译:Netty是一个NIO客户机-服务器框架,可以快速轻松地开发网络应用程序,如协议服务器和客户机。它大大简化和流线型网络编程,如TCP和UDP套接字服务器。
“快速而简单”并不意味着最终的应用程序将面临可维护性或性能问题。Netty经过精心设计,使用了从许多协议(如FTP、SMTP、HTTP)以及各种二进制和基于文本的遗留协议的实现中获得的经验。因此,Netty成功地找到了一种不需要妥协就能轻松实现开发、性能、稳定性和灵活性的方法。
Features
Design
Unified API for various transport types - blocking and non-blocking socket
Based on a flexible and extensible event model which allows clear separation of concerns
Highly customizable thread model - single thread, one or more thread pools such as SEDA
True connectionless datagram socket support (since 3.1)
Ease of use
Well-documented Javadoc, user guide and examples
No additional dependencies, JDK 5 (Netty 3.x) or 6 (Netty 4.x) is enough
Note: Some components such as HTTP/2 might have more requirements. Please refer to the Requirements page for more information.
Performance
Better throughput, lower latency
Less resource consumption
Minimized unnecessary memory copy
Security
Complete SSL/TLS and StartTLS support
Community
Release early, release often
The author has been writing similar frameworks since 2003 and he still finds your feed back precious!
翻译:
特征
设计
用于各种传输类型的统一API-阻塞和非阻塞套接字
基于灵活且可扩展的事件模型,该模型允许清晰地分离关注点
高度可定制的线程模型-单线程、一个或多个线程池,如SEDA
真正的无连接数据报套接字支持(自3.1版起)
易用性
文档丰富的Javadoc、用户指南和示例
没有其他依赖项,JDK 5(Netty 3.x)或6(Netty 4.x)就足够了
注意:有些组件(如HTTP/2)可能有更多要求。请参阅“需求”页面了解更多信息。
性能
吞吐量更好,延迟更低
减少资源消耗
最小化不必要的内存拷贝
安全
完全支持SSL/TLS和StartTLS
以下图是netty所支持的协议
使用User guide for 4.x