multithreading - CPU usage of Java + JDBC -
while testing webapp under load got following top excerpt under linux:
pid user pr ni virt res shr s %cpu %mem time+ command 3964 nobody 20 0 4965m 622m 6048 s 8.5 11.0 6:02.49 java 1985 mysql 20 0 294m 125m 3804 s 2.1 2.2 0:05.39 /usr/sbin/mysqld i need explanation on java's %cpu column. understand it, during web request 1 of java's thread performing pure java logic, consuming of cpu time (let 5ms). connects database via jdbc, sends sql query , waits, 10ms, response. these 10ms counted /usr/sbin/mysqld cpu usage. java thread resumes it's operation , finishes, consuming 20ms , amounting 5+10+20=30ms total execution time.
and newbie question is: don't think these db-related 10ms counted twice: 1 time java thread waiting db process query , second time database cpu usage itself? don't understand here?
when process waiting on socket not using significant amounts of cpu. basically, kernel knows in waiting state , not schedule run - except little things signal handling, can used e.g. run garbage collector regularly.
(ok, if there lot of garbage collect, "little thing" might not little.)
Comments
Post a Comment