zoukankan      html  css  js  c++  java
  • 学习 Netty 3.x

    study link: http://netty.io/3.6/guide/#architecture

     应用场景:

    • Chat server that requires persistent connections and server push technology (e.g. Comet)

    • Media streaming server that needs to keep the connection open until the whole media is streamed (e.g. 2 hours of video)

    • File server that allows the uploading of large files without memory pressure (e.g. uploading 1GB per request)

    • Scalable mash-up client that connects to tens of thousands of 3rd party web services asynchronously

    高级特性:

    1. Codec (means encode and decode - usually you need to codec the requests from socket stream)

    2. SSL (secure socket layer) / TLS (transport layer security) support

    3.  HTTP easy implementation

    4. webSocket support

    5. Google Protocol Buffer Integration - binary protocol ?!


    powerful architecture. It is composed of three components - buffer, channel, and event model- and all advanced features are built on top of the three core components


    Guide:
    Request will be read by Channel into ChannelBuffer
    Meanwhile it will publish the ChannelEvent to the ChannelHandlers in the ChannelPipeline
    ChannelEvent.getChannel()
    Response will be generated by ChannelHandlers into ChannelBuffer, lastly write into Channel back to client





    * new NioServerSocketChannelFactory( Executors.newCachedThreadPool()

    无界线程池,可以进行自动线程回收。

    在JDK帮助文档中,有如此一段话: “强烈建议程序员使用较为方便的 Executors 工厂方法 Executors.newCachedThreadPool()(无界线程池,可以进行自动线程回收)、Executors.newFixedThreadPool(int)(固定大小线程池)和 Executors.newSingleThreadExecutor()(单个后台线程),它们均为大多数使用场景预定义了设置。”


    More details about ThreadPool tech, you can check http://dongxuan.iteye.com/blog/901689

    newFixedThreadPool          newSingleThreadExecutor           newCachedThreadPool 




  • 相关阅读:
    Git配置
    第一次作业
    第二次作业
    python目前最好用的IDE——pycharm
    九九乘法表
    python语言的优点和缺点
    Python高效编程的19个技巧
    Python中 filter | map | reduce | lambda的用法
    Python 代码优化常见技巧
    求逆序对
  • 原文地址:https://www.cnblogs.com/suncoolcat/p/3301577.html
Copyright © 2011-2022 走看看