mina2.0的优化

1、解决使用线程池导致速度慢的问题:

acceptor.getFilterChain().addLast("threadPool", new ExecutorFilter(Executors.newCachedThreadPool()));

IoBuffer.setUseDirectBuffer(false);
IoBuffer.setAllocator(new SimpleBufferAllocator());


2、解决过多TIME_WAIT的问题:

@Override
	public void sessionCreated(IoSession session) throws Exception {
		// TODO Auto-generated method stub
		SocketSessionConfig cfg = (SocketSessionConfig) session.getConfig();
		cfg.setReceiveBufferSize(2 * 1024 * 1024);
		cfg.setReadBufferSize(2 * 1024 * 1024);
		cfg.setKeepAlive(true);
		cfg.setSoLinger(0); 
	}

你可能感兴趣的:(exception,优化,session,Mina)