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 




  • 相关阅读:
    SpringCloud微服务初步认识
    SpringCloud-Hystrix:服务熔断与降级
    List接口下重要集合源码分析
    高频面试题:手写一个LRU
    Java基础面试题面经整理(持续更新)
    Redis高可用之主从复制
    Redis过期键删除和内存淘汰
    Redis持久化(RDB与AOF)
    了解Redis事务
    Redis入门与安装
  • 原文地址:https://www.cnblogs.com/suncoolcat/p/3301577.html
Copyright © 2011-2022 走看看