Note that there are some explanatory texts on larger screens.

plurals
  1. POWriting netty performance tests
    text
    copied!<p>So I have a netty-based websockets client that I am using for performance tests. My idea is that I can use it to simulate 100, 1000, etc simultaneous connections. </p> <p>I've determined that my current approach to this is not working--the test harness is simply not creating enough websocket connections, althogh it bumps along happily, thinks it's still connected, etc. But my server simply does not show the correct number of connections when I use this test harness. I think most likely this is occurring because I am using various objects in the netty library across multiple threads at once and they don't handle that very well. ClientBootstrap, for example. </p> <p>This is what I am doing per-thread. Can you tell me where I am going wrong, so that I can fix my test harness?</p> <pre><code>public void run(){ try{ // client bootstrap. There is one of these per thread. is that part of the problem? ClientBootstrap bootstrap = new ClientBootstrap(new NIOClientSocketChannelFactory(Executors.newCachedThreadPool(), Executors.newCachedThreadPool()))); Channel ch = null; try{ // set up ssl engine final SSLEngine engine = createServerContext().createSSLEngine(); engine.setUseClientMode(true); // there is a new handhsaker per thread, too. They all go to the same uri final WebSocketClientHandshaker handshaker = new WebSocketClientHandhsakerFactory().newHandshaker(uri, WebSocketVersion.V08, null, false, null); // set up the pipeline factory and pipeline bootstrap.setPipelineFactory(new ChannelPipelieFactory(){ @Override public Channelpipeline getPipeline() throws Exception(){ ChannelPipeline pipeline = Channels.pipeline(); pipeline.addLast("ssl", new SslHandler(engine)); pipeline.addLast("encoder", new HttpRequestEncoder(); pipeline.addLast("decoder", new HttpResponseDecoder(); // WebSocketClientHandler code not included, it's just a custom handler that sends requests via websockets pipeline.addLast("ws-handler", new WebSocketClientHandler(handshaker); return pipleline; } }); // connect websockets preflight over http ChannelFuture future = bootstrap.connect(new InetSocketAddress(uri.getHost(), uri.getPort()); future.sync(); // do websockets handshake ch = future.getChannel(); ChannelFuture handshakeFuture = handshaker.handshake(ch); handshakeFuture.syncUninterruptably(); Thread.sleep(1000); // i had to add this. Sync should have meant that the above method didn't return until it was complete... but that was a lie. So I sleep for 1 second to solve that problem. if(!handshakeDuture.isSuccess()) System.out.println("WHOAH errror"); // send message to server ch.write(new TextWebSocketFrame("Foo")); // wait for notifications to close while(!getShutdownNow().get()) // shutdownNow is an atomicBoolean which is set to true when all my threads have been started up and a certain amount of time has passed Thread.sleep(2000); // send close; wait for response ch.write(new CloseWebSocketFrame()); ch.getCloseFuture().awaitUninterruptibly(); } } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload