事件驱动的异步IO通信框架 Apache Mina , JBoss Netty , Grizzly (Java), Twisted , gevent (python), eventmachine (Ruby), POE (Perl), Node.js (JavaScript), libevent (C)
各框架实现的Echo Server
Twisted , libevent (不是echo server,但讲了很多基础知识), gevent , eventmachine , Node.js , Netty , Grizzly , POE ,按先后顺序进行学习。
选型的依据:
功能: 截取模式: Mina: Filter-Handler; Netty/Grizzly: Handler only
支持的Filter/Handler:
Mina: blacklist filters, compression filters, connection throttling filters, SSL filters, logging filters, protocol codecs such as delimiter based, and HTTP. Grizzly provides support for SSL, custom protocol codecs, logging, and HTTP;
Netty: Base64 encoding/decoding, delimiter based codecs, fixed length codecs, HTTP handlers, logging handlers, Java object serialization/deserialization codecs, Google Protocol Buffer codecs, SSL handlers, simple string codecs, and handlers used to control bandwidth, traffic shaping, etc. There are also several utility handlers that may be used to build custom handlers such as a replay handler, timeout handler , frame decoder, etc;(Netty在支持基于已有的Handler构建用户Handler方面更灵活)
高级缓存
Netty: ChannelBuffer中封装了多个ByteBuffer实例的引用(而非拷贝),支持zero copy,支持标记与重设“读指针”(Reader)索引,支持搜索、切片、读写不同类型数据;
Mina: 与Netty基本类似,但不支持zero copy(在Mina 3中实现);
Socket and Protocol Independence
三者均支持,使通信框架底层技术变化(例如从NIO向AIO过渡)时,无需更新业务逻辑代码;
可定制的协议与POJO
三者均支持,POJO在网络传输中的作用是什么?
线程模型
三者均使用线程池模型,应付高并发能力良好;
性能:
速度:MINA能够满足要求(并发800+),Netty=Grizzly>MINA;
内存占用量:Netty=Mina<Grizzly 扩展性:采用此框架的项目代码是否易于修改,易于在已有功能基础上拓展新功能; 易用性:框架的简洁程度,API Docs是否完善,Tutorials是否丰富,论坛是否活跃; 与GODU的整合能力/迁移成本;