问题描述
最近生产环境的red5经常出现拒绝服务的问题,仔细查看日志后发现所有的请求都是NioProcessor-1来完成,如果请求服务过多,会导致该线程处理不过来,也将导致线上其它服务将无响应,仔细查看了下RTMPMinaTransport构造源码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
public void start() throws Exception { initIOHandler(); IoBuffer.setUseDirectBuffer(!useHeapBuffers); // this is global, oh well if (useHeapBuffers) { // dont pool for heap buffers IoBuffer.setAllocator(new SimpleBufferAllocator()); } log.info("RTMP Mina Transport Settings"); log.info("Connection Threads: {}", connectionThreads); log.info("I/O Threads: {}", ioThreads); //use default parameters, and given number of NioProcessor for multithreading I/O operations //acceptor = new NioSocketAcceptor(ioThreads); //create separate executors to handle connections and i/o Executor connectionExecutor = Executors.newFixedThreadPool(connectionThreads); Executor ioExecutor = Executors.newFixedThreadPool(ioThreads); acceptor = new NioSocketAcceptor(connectionExecutor, new NioProcessor(ioExecutor)); acceptor.setHandler(ioHandler); acceptor.setBacklog(50); log.info("TCP No Delay: {}", tcpNoDelay); log.info("Receive Buffer Size: {}", receiveBufferSize); log.info("Send Buffer Size: {}", sendBufferSize); ... } |