自定义修改百万连接调优
来源:13-1 课程回顾和总结

payzul
2020-07-23
public void start(String ip, String port, int clientCount, int time) throws Exception {
EventLoopGroup eventLoopGroup = new NioEventLoopGroup();
final Bootstrap bootstrap = new Bootstrap();
bootstrap.group(eventLoopGroup);
bootstrap.channel(NioSocketChannel.class);
bootstrap.option(ChannelOption.SO_REUSEADDR, true);
bootstrap.handler(new ChannelInitializer() {
@Override
protected void initChannel(SocketChannel ch) {
ch.pipeline().addLast(new FixedLengthFrameDecoder(Long.BYTES));
ch.pipeline().addLast(ClientBusinessHandler.INSTANCE);
}
});
for (int i = 0; i < clientCount; i++) {
bootstrap.connect(ip, Integer.parseInt(port)).get();
}
}
老师:您好!
我想模拟指定时间内多客户端访问,并记录每次最短,最长,平均等访问时间,并把这些信息落库,想问time 我该如何传入呢?
按照我的理解,在代码里我只需要固定时间(time)传入进去,并在ClientBusinessHandler 中把time 替换成duration 变量即可。
此外入库也可以在clien端进行吧?
1回答
-
闪电侠
2020-08-01
没看明白你这里的 time 的意思呢00
相似问题