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 




  • 相关阅读:
    element:记一次重置表单引发提交数据为默认数据现象
    三种常用又简单的排序算法
    (07)GitHub从2021.08.13开始使用Token代替账号和密码
    does not implement methodSignatureForSelector:
    自用python库
    2048
    CCSP2021游记
    2021 CCPC 桂林站游记
    2021 ICPC 沈阳站游记
    2021SDU新生赛游记
  • 原文地址:https://www.cnblogs.com/suncoolcat/p/3301577.html
Copyright © 2011-2022 走看看