Search code examples
javamultithreadingcpuwowzamina

wowza java high cpu usage


I have problem about cpu usage in wowza.

this is doubtful thread. this thread is took high cpu.

SocketAcceptorIoProcessor-1.0 prio=10 tid=0x0000002a9fb53000 nid=0x2428 runnable         [0x000000004f017000]
java.lang.Thread.State: RUNNABLE
at sun.nio.ch.EPollArrayWrapper.epollWait(Native Method)
at sun.nio.ch.EPollArrayWrapper.poll(EPollArrayWrapper.java:210)
at sun.nio.ch.EPollSelectorImpl.doSelect(EPollSelectorImpl.java:65)
at sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:69)
- locked <0x00000007d82ba4e8> (a sun.nio.ch.Util$2)
- locked <0x00000007d82ba4d8> (a java.util.Collections$UnmodifiableSet)
- locked <0x00000007d82ad450> (a sun.nio.ch.EPollSelectorImpl)
at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:80)
at org.apache.mina.transport.socket.nio.SocketIoProcessor$Worker.run(Unknown Source)
at org.apache.mina.util.NamePreservingRunnable.run(Unknown Source)
at java.lang.Thread.run(Thread.java:662)

this thread took high cpu. is this jdk bug or else?

this is my environment.

CentOS release 5.4 (Final)

WowzaMediaServer-3.1.2

java version 1.6.0_23 Java(TM) SE Runtime Environment (build 1.6.0_23-b05) Java HotSpot(TM) 64-Bit Server VM (build 19.0-b09, mixed mode)


Solution

  • I would first check it really is consuming CPU. If you are profiling the application it can appear to be spending allot of time in this method, when the method is actually blocking. Most profilers have problems telling the difference between a method which is spending allot of time in native code (consumes lots of CPU) and one which is blocking (consumes very little CPU)

    Older versions of Java had bugs which could result in the selector spinning. i.e. it keeps returning no selectors without blocking in a busy loop even though it still functions correctly otherwise. I believe newer version of Java have this fixed. I would try Java 6 update 35 or Java 7 update 7 to see if it fixes your problem.

    I prefer to use blocking NIO if there is less than a few hundred connections as it much simpler IMHO.