java - SelectorImpl is BLOCKED -


i use lot of client sends request server 1000 requests per second client, server's cpu rose 600% (8 cores), , maintain state. when use jstack printing process content, found selectorimpl blocked state. records follows:

nioeventloopgroup-4-1 prio=10 tid=0x00007fef28001800 nid=0x1dbf waiting monitor entry [0x00007fef9eec7000] java.lang.thread.state: blocked (on object monitor) @ sun.nio.ch.epollselectorimpl.doselect(unknown source) - waiting lock <0x00000000c01f1af8> (a java.lang.object)     @ sun.nio.ch.selectorimpl.lockanddoselect(unknown source)     - locked <0x00000000c01d9420> (a io.netty.channel.nio.selectedselectionkeyset)     - locked <0x00000000c01f1948> (a java.util.collections$unmodifiableset)     - locked <0x00000000c01d92c0> (a sun.nio.ch.epollselectorimpl)     @ sun.nio.ch.selectorimpl.select(unknown source)     @ io.netty.channel.nio.nioeventloop.select(nioeventloop.java:635)     @ io.netty.channel.nio.nioeventloop.run(nioeventloop.java:319)     @ io.netty.util.concurrent.singlethreadeventexecutor$2.run(singlethreadeventexecutor.java:101)     @ java.lang.thread.run(unknown source) 

high cpu has this? problem when connect lot of clients, find client connect, error follows:

"nioeventloopgroup-4-1" prio=10 tid=0x00007fef28001800 nid=0x1dbf waiting monitor entry [0x00007fef9eec7000] java.lang.thread.state: blocked (on object monitor) @ sun.nio.ch.epollselectorimpl.doselect(unknown source) - waiting lock <0x00000000c01f1af8> (a java.lang.object) @ sun.nio.ch.selectorimpl.lockanddoselect(unknown source) - locked <0x00000000c01d9420> (a io.netty.channel.nio.selectedselectionkeyset) - locked <0x00000000c01f1948> (a java.util.collections$unmodifiableset) - locked <0x00000000c01d92c0> (a sun.nio.ch.epollselectorimpl) @ sun.nio.ch.selectorimpl.select(unknown source) @ io.netty.channel.nio.nioeventloop.select(nioeventloop.java:635) @ io.netty.channel.nio.nioeventloop.run(nioeventloop.java:319) @ io.netty.util.concurrent.singlethreadeventexecutor$2.run(singlethreadeventexecutor.java:101) @ java.lang.thread.run(unknown source) 

generate client accomplished using thread pool, , has set connection timeout, why frequent connection timeout? serve cause of suit?

    public void run() {      system.out.println(tnum + " connecting...");     try {         bootstrap bootstrap = new bootstrap();         bootstrap.group(group)         .channel(niosocketchannel.class)         .option(channeloption.connect_timeout_millis, 30000)         .handler(loadclientinitializer);          // start connection attempt.         channelfuture future = bootstrap.connect(host, port);         future.channel().attr(attrnum).set(tnum);         future.sync();         if (future.issuccess()) {             system.out.println(tnum + " login success.");             gosend(tnum, future.channel());         } else {             system.out.println(tnum + " login failed.");         }     } catch (exception e) {         xlog.error(e);     } { 

// group.shutdowngracefully(); }

} 

if can elaborate more on netty doing helpful. regardless - please make sure closing channels. notice channel javadoc:

it important call close() or close(channelpromise) release resources once done channel. ensures resources released in proper way, i.e. filehandles

if closing channels, problem may logic self - running infinite loops or similar - may able explain high cpu.


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -