Monitoring Apache Tomcat With JMX
Monitoring Apache Tomcat With JMX
+nvo1e opeations
0eceive noti,ications
+nvo1e opeations
0eceive noti,ications
Heap status
5aba!e collection
5C pause ti&es
6eap status
5aba!e collection
5C pause ti&es
'onitoin! %o&cat
'onitoin! %o&cat
Status o, connecto
0e7uest pe,o&ance
Status o, connecto
0e7uest pe,o&ance
('- %ools
('- %ools
9console :(;<=
9console :(;<=
Status o, e7uest8
pocesso thead pool
0e7uest pe,o&ance
Session in,o&ation
Status o, e7uest8
pocesso thead pool
0e7uest pe,o&ance
Session in,o&ation
'onitoin! %o&cat
'onitoin! %o&cat
Status o, e7uest8
pocesso thead pool
0e7uest pe,o&ance
Session in,o&ation
Status o, e7uest8
pocesso thead pool
0e7uest pe,o&ance
Session in,o&ation
'onitoin! %o&cat: 0e7uests
'onitoin! %o&cat: 0e7uests
'onitoin! %o&cat: 0e7uests
'onitoin! %o&cat: 0e7uests
'onitoin! %o&cat: 0e7uests
'onitoin! %o&cat: 0e7uests
'onitoin! %o&cat
'onitoin! %o&cat
Status o, e7uest8
pocesso thead pool
0e7uest pe,o&ance
Session in,o&ation
Status o, e7uest8
pocesso thead pool
0e7uest pe,o&ance
Session in,o&ation
'onitoin! %o&cat: Sessions
'onitoin! %o&cat: Sessions
'onitoin! %o&cat
'onitoin! %o&cat
Status o, e7uest8
pocesso thead pool
0e7uest pe,o&ance
Session in,o&ation
Status o, e7uest8
pocesso thead pool
0e7uest pe,o&ance
Session in,o&ation
'onitoin! %o&cat: ;ataSouces
'onitoin! %o&cat: ;ataSouces
'onitoin! %o&cat
'onitoin! %o&cat
Status o, e7uest8
pocesso thead pool
0e7uest pe,o&ance
Session in,o&ation
Status o, e7uest8
pocesso thead pool
0e7uest pe,o&ance
Session in,o&ation
'onitoin! %o&cat: %heads
'onitoin! %o&cat: %heads
'onitoin! %o&cat: %heads
'onitoin! %o&cat: %heads
'onitoin! %o&cat: %heads
'onitoin! %o&cat: %heads
'onitoin! %o&cat: %heads
'onitoin! %o&cat: %heads
'onitoin! >ou Application
'onitoin! >ou Application
*e,o&ance 'etics
?n8the8,l4 e8con,i!uation
*e,o&ance 'etics
?n8the8,l4 e8con,i!uation
'onitoin! >ou Application
'onitoin! >ou Application
@ite an 'Aean
@ite an 'Aean
public interface RequestStatsMBean {
public long getProcessingTime();
public long getRequestCount();
public void resetCounters();
0e7uestStats 'Aean
0e7uestStats 'Aean
Ceate (A0
(ava inte,ace
(ava i&ple&entation
&beans8desciptos.x&l
Ceate (A0
(ava inte,ace
(ava i&ple&entation
&beans8desciptos.x&l
0e&ote Access
La!e Scale
Constant
0e&ote Access
La!e Scale
Constant
Auto&ated 'onitoin!
Auto&ated 'onitoin!
0e&ote Access
La!e Scale
Constant
0e&ote Access
La!e Scale
Constant
$a!ios
Simple
Flexible
@ell8deplo4ed
$a!ios
Si&ple
Flexible
@ell8deplo4ed
Session count
0e7uest eo count
Session count
0e7uest eo count
Session count
0e7uest eos
< "5c/ec=%7m8pro84 +> K/ttp955local/ost5manager57m8pro84L
get-Catalina9t4pe-RequestProcessor$6or=er-./ttp+nio+?CO")")"?+
JC?O.$name-AttpRequest?Matt-errorCountK +6 ? +c ?) ++6rite errors"t8t ++compare
errors"t8t
FMG 3B9 3B + 'ttribute get KCatalina9t4pe-RequestProcessor$6or=er-./ttp+nio+
?CO")")"?+JC?O.$name-AttpRequest?K + errorCount - )$ delta-)
Session count
0e7uest eos
< "5c/ec=%7m8pro84 +> K/ttp955local/ost5manager57m8pro84L
get-Catalina9t4pe-RequestProcessor$6or=er-./ttp+nio+?CO")")"?+
JC?O.$name-AttpRequest?Matt-errorCountK +6 ? +c ?) ++6rite errors"t8t ++compare
errors"t8t
FMG 3B9 3B + 'ttribute get KCatalina9t4pe-RequestProcessor$6or=er-./ttp+nio+
?CO")")"?+JC?O.$name-AttpRequest?K + errorCount - )$ delta-)
;etectin! ?ut?,'e&o4
;etectin! ?ut?,'e&o4
Heap exhaustion
*e&5en exhaustion
6eap exhaustion
*e&5en exhaustion
Fse 8--:?n?ut?,'e&o4)o to un a
co&&and on first ??') detected b4 the
(2'
Fse 8--:?n?ut?,'e&o4)o to un a
co&&and on first ??') detected b4 the
(2'
*esentation Slides
/ttp955people"apac/e"org5Zsc/ultV5'pac/eCon 1' C)?P5Tomcat Monitoring5
chec1C9&xpox4
/ttp9556i=i"apac/e"org5tomcat5tools5c/ec=%7m8pro84"pl
*esentation Slides
/ttp955people"apac/e"org5Zsc/ultV5'pac/eCon 1' C)?P5Tomcat Monitoring5
chec1C9&xpox4
/ttp9556i=i"apac/e"org5tomcat5tools5c/ec=%7m8pro84"pl
+nvo1e opeations
0eceive noti,ications
+nvo1e opeations
0eceive noti,ications
Heap status
5aba!e collection
5C pause ti&es
6eap status
5aba!e collection
5C pause ti&es
%he (2' exposes a lot about its intenal state. 6ee
ae so&e o, the &oe inteestin! ite&s.
%he (2' exposes a lot about its intenal state. 6ee
ae so&e o, the &oe inteestin! ite&s.
'onitoin! %o&cat
'onitoin! %o&cat
Status o, connecto
0e7uest pe,o&ance
Status o, connecto
0e7uest pe,o&ance
%o&cat has a !eat deal o, in,o&ation available as
well. 6eeEs a sa&ple o, whatEs thee.
%o&cat has a !eat deal o, in,o&ation available as
well. 6eeEs a sa&ple o, whatEs thee.
('- %ools
('- %ools
9console :(;<=
9console :(;<=
Status o, e7uest8
pocesso thead pool
0e7uest pe,o&ance
Session in,o&ation
Status o, e7uest8
pocesso thead pool
0e7uest pe,o&ance
Session in,o&ation
+&a!e: sceenshot ,o& 2isual2' o, %o&catEs 'Aean
tee.
%o&cat povides a wealth o, in,o&ation about its
intenal state. 'uch o, this in,o&ation is &eel4
con,i!uation values that ae ead on statup and do
not chan!e ove ti&e.
%hee is3 howeve3 a !eat deal o, eal8ti&e data
available about the sevlet containe and its vaious
co&ponents. +Ell dive into these pactical exa&ples to
de&onstate the ich data that is available.
+E& !oin! to cove these out8o,8ode with espect to
the top8to8botto& ode shown above in ode to
ease8into so&e o, the concepts.
+&a!e: sceenshot ,o& 2isual2' o, %o&catEs 'Aean
tee.
%o&cat povides a wealth o, in,o&ation about its
intenal state. 'uch o, this in,o&ation is &eel4
con,i!uation values that ae ead on statup and do
not chan!e ove ti&e.
%hee is3 howeve3 a !eat deal o, eal8ti&e data
available about the sevlet containe and its vaious
co&ponents. +Ell dive into these pactical exa&ples to
de&onstate the ich data that is available.
+E& !oin! to cove these out8o,8ode with espect to
the top8to8botto& ode shown above in ode to
ease8into so&e o, the concepts.
'onitoin! %o&cat
'onitoin! %o&cat
Status o, e7uest8
pocesso thead pool
0e7uest pe,o&ance
Session in,o&ation
Status o, e7uest8
pocesso thead pool
0e7uest pe,o&ance
Session in,o&ation
%o&cat tac1s the pe,o&ance o, e7uests :in
a!!e!ate= ,o each connecto sepaatel4. A
5lobal0e7uest*ocesso exists ,o each connecto
whee 4ou can obtain in,o&ation about the
pe,o&ance o, the e7uests handled b4 that
paticula connecto.
%o&cat tac1s the pe,o&ance o, e7uests :in
a!!e!ate= ,o each connecto sepaatel4. A
5lobal0e7uest*ocesso exists ,o each connecto
whee 4ou can obtain in,o&ation about the
pe,o&ance o, the e7uests handled b4 that
paticula connecto.
'onitoin! %o&cat: 0e7uests
'onitoin! %o&cat: 0e7uests
6ee is a view o, one o, %o&catEs
5lobal0e7uest*ocessos. + happen to have H
connectos con,i!ued3 and 4ou can tell the& apat
b4 thei na&es which also indicate a lot about the&:
potocol3 inte,ace addess3 and pot nu&be will
uni7uel4 identi,4 an4 connectoEs
5lobal0e7uest*ocesso.
%hese 5lobal0e7uest*ocessos 1eep tac1 o,
&etics about e7uests such as the nu&be o,
e7uests3 the cu&ulative pocessin! ti&e o, those
e7uests3 and the oveall volu&e o, data pocessed.
6ee is a view o, one o, %o&catEs
5lobal0e7uest*ocessos. + happen to have H
connectos con,i!ued3 and 4ou can tell the& apat
b4 thei na&es which also indicate a lot about the&:
potocol3 inte,ace addess3 and pot nu&be will
uni7uel4 identi,4 an4 connectoEs
5lobal0e7uest*ocesso.
%hese 5lobal0e7uest*ocessos 1eep tac1 o,
&etics about e7uests such as the nu&be o,
e7uests3 the cu&ulative pocessin! ti&e o, those
e7uests3 and the oveall volu&e o, data pocessed.
'onitoin! %o&cat: 0e7uests
'onitoin! %o&cat: 0e7uests
An4 'Aean can suppot opeations that can be
called via the ('- A*+s. %he
5lobal0e7uest*ocesso beans have a sin!le
opeation: esetCountes. %his opeation as 4ou
&i!ht !uess esets all the collected &etics ,o the
5lobal0e7uest*ocesso to #eo.
An4 'Aean can suppot opeations that can be
called via the ('- A*+s. %he
5lobal0e7uest*ocesso beans have a sin!le
opeation: esetCountes. %his opeation as 4ou
&i!ht !uess esets all the collected &etics ,o the
5lobal0e7uest*ocesso to #eo.
'onitoin! %o&cat: 0e7uests
'onitoin! %o&cat: 0e7uests
All values #eoed8outD
0esettin! these countes can be use,ul i, 4ou want to
&onito pe,o&ance data ove ti&e and want to
peiodicall4 eset the state o, the connectoEs &etics.
All values #eoed8outD
0esettin! these countes can be use,ul i, 4ou want to
&onito pe,o&ance data ove ti&e and want to
peiodicall4 eset the state o, the connectoEs &etics.
'onitoin! %o&cat
'onitoin! %o&cat
Status o, e7uest8
pocesso thead pool
0e7uest pe,o&ance
Session in,o&ation
Status o, e7uest8
pocesso thead pool
0e7uest pe,o&ance
Session in,o&ation
Sessions ae anothe thin! 4ou &i!ht want to 1eep
tac1 o,: too &an4 sessions can bo!8down a seve
and cause pe,o&ance poble&s. %he eal poble&
is stoin! lots o, data in the session3 o couse3 but
the nu&be o, sessions can be an i&potant data
point in 4ou seve &onitoin! state!4.
Sessions ae anothe thin! 4ou &i!ht want to 1eep
tac1 o,: too &an4 sessions can bo!8down a seve
and cause pe,o&ance poble&s. %he eal poble&
is stoin! lots o, data in the session3 o couse3 but
the nu&be o, sessions can be an i&potant data
point in 4ou seve &onitoin! state!4.
'onitoin! %o&cat: Sessions
'onitoin! %o&cat: Sessions
'ost use,ul attibutes shown hee: activeSessions3
&axActive3 and expiedSessions. ?ne attibute that
is not shown is the sessionCeation0ate3 which !ives
4ou an idea o, how ,ast sessions ae bein! ceated.
%o&cat actuall4 exposes eve4 session in the
containe via 'Aean opeations. >ou can ,etch a list
o, all session ids3 ,etch attibute values ,o& a
paticula session3 and even expie sessions diectl4.
'ost use,ul attibutes shown hee: activeSessions3
&axActive3 and expiedSessions. ?ne attibute that
is not shown is the sessionCeation0ate3 which !ives
4ou an idea o, how ,ast sessions ae bein! ceated.
%o&cat actuall4 exposes eve4 session in the
containe via 'Aean opeations. >ou can ,etch a list
o, all session ids3 ,etch attibute values ,o& a
paticula session3 and even expie sessions diectl4.
'onitoin! %o&cat
'onitoin! %o&cat
Status o, e7uest8
pocesso thead pool
0e7uest pe,o&ance
Session in,o&ation
Status o, e7uest8
pocesso thead pool
0e7uest pe,o&ance
Session in,o&ation
A !eat nu&be o, web applications use a elational
database via (;AC. %hose ;ataSouces con,i!ued
via %o&cat :and not diectl4 in the application3 such
as those con,i!ued b4 Spin!3 6ibenate3 etc.= ae
available ,o inspection.
%o&catEs ;ataSouces have a connection pool with
&ini&u& and &axi&u& si#es :nu&bes o,
connections=3 and a &ax+dle settin! which allows the
pool to !ow and shin1 dependin! upon the
de&and.
A !eat nu&be o, web applications use a elational
database via (;AC. %hose ;ataSouces con,i!ued
via %o&cat :and not diectl4 in the application3 such
as those con,i!ued b4 Spin!3 6ibenate3 etc.= ae
available ,o inspection.
%o&catEs ;ataSouces have a connection pool with
&ini&u& and &axi&u& si#es :nu&bes o,
connections=3 and a &ax+dle settin! which allows the
pool to !ow and shin1 dependin! upon the
de&and.
'onitoin! %o&cat: ;ataSouces
'onitoin! %o&cat: ;ataSouces
Speci,icall43 4ou &i!ht want to ta1e a loo1 at the
nu&Active and nu&+dle attibutes: 4ou can see i,
4ou (;AC connection pool is &eetin! the de&and
o, 4ou uses.
$ote that + have &axActiveI1 since this is a test
s4ste&.
Speci,icall43 4ou &i!ht want to ta1e a loo1 at the
nu&Active and nu&+dle attibutes: 4ou can see i,
4ou (;AC connection pool is &eetin! the de&and
o, 4ou uses.
$ote that + have &axActiveI1 since this is a test
s4ste&.
'onitoin! %o&cat
'onitoin! %o&cat
Status o, e7uest8
pocesso thead pool
0e7uest pe,o&ance
Session in,o&ation
Status o, e7uest8
pocesso thead pool
0e7uest pe,o&ance
Session in,o&ation
)ach o, %o&catEs connectos has a thead pool that
is used to actuall4 pocess the e7uests: once a
e7uest aives3 it is dispatched to a thead in the
pool.
%head pools in %o&cat ae called )xecutos and
&a4 be shaed between connectos3 which is wh4
the4 ae teated sepaatel4 ,o& the Connectos
the&selves.
)xecutos ae li1e the (;AC connection8pools ,o&
the pevious exa&ple: the4 have &ini&u& and
&axi&u& si#es3 as well as an idle ta!et to help
&atch esouces to use de&and.
)ach o, %o&catEs connectos has a thead pool that
is used to actuall4 pocess the e7uests: once a
e7uest aives3 it is dispatched to a thead in the
pool.
%head pools in %o&cat ae called )xecutos and
&a4 be shaed between connectos3 which is wh4
the4 ae teated sepaatel4 ,o& the Connectos
the&selves.
)xecutos ae li1e the (;AC connection8pools ,o&
the pevious exa&ple: the4 have &ini&u& and
&axi&u& si#es3 as well as an idle ta!et to help
&atch esouces to use de&and.
'onitoin! %o&cat: %heads
'onitoin! %o&cat: %heads
>ou can ,ind out the nu&be o, cuentl48active
e7uests :activeCount=3 the total nu&be o, e7uests
pocessed :b4 the executo3 which &a4 not be the
sa&e as the nu&be pocessed b4 an4 !iven
connecto=3 etc.
>ou can ,ind out the nu&be o, cuentl48active
e7uests :activeCount=3 the total nu&be o, e7uests
pocessed :b4 the executo3 which &a4 not be the
sa&e as the nu&be pocessed b4 an4 !iven
connecto=3 etc.
'onitoin! %o&cat: %heads
'onitoin! %o&cat: %heads
6ee3 +Eve ,ied8up a little ('ete scipt to put so&e
load on the seve. >ou can see that thee ae J
active theads and the pool si#e has 9u&ped ,o& 4
theads to 213 indicatin! that +Eve put 7uite a load on
the pool K elativel4 spea1in!. %he
co&pleted%as1Count is !on!8up da&aticall4.
:+ suspect the eason + donEt have 21 theads bus488
o &oe K i!ht now is because &4 laptop onl4 has L
lo!ical coes3 so eall4 onl4 L theads can be active
at once K that &eans both ('ete and %o&cat. %he
e7uests ae also pocessed so 7uic1l4 that itEs had
to catch a la!e nu&be o, theads actuall4 active.=
6ee3 +Eve ,ied8up a little ('ete scipt to put so&e
load on the seve. >ou can see that thee ae J
active theads and the pool si#e has 9u&ped ,o& 4
theads to 213 indicatin! that +Eve put 7uite a load on
the pool K elativel4 spea1in!. %he
co&pleted%as1Count is !on!8up da&aticall4.
:+ suspect the eason + donEt have 21 theads bus488
o &oe K i!ht now is because &4 laptop onl4 has L
lo!ical coes3 so eall4 onl4 L theads can be active
at once K that &eans both ('ete and %o&cat. %he
e7uests ae also pocessed so 7uic1l4 that itEs had
to catch a la!e nu&be o, theads actuall4 active.=
'onitoin! %o&cat: %heads
'onitoin! %o&cat: %heads
A,te a bit &oe load3 +Eve been able to captue the
activeCount !ettin! a bit hi!he.
A,te a bit &oe load3 +Eve been able to captue the
activeCount !ettin! a bit hi!he.
'onitoin! %o&cat: %heads
'onitoin! %o&cat: %heads
;onEt want to tac1 the values 4ousel, ove ti&eM $o
poble&: 9ust double8clic1 on an4 nu&eic value and
2isual2' will !aph it ,o 4ou ove ti&e.
;onEt want to tac1 the values 4ousel, ove ti&eM $o
poble&: 9ust double8clic1 on an4 nu&eic value and
2isual2' will !aph it ,o 4ou ove ti&e.
'onitoin! >ou Application
'onitoin! >ou Application
*e,o&ance 'etics
?n8the8,l4 e8con,i!uation
*e,o&ance 'etics
?n8the8,l4 e8con,i!uation
So3 the (2' and %o&cat expose in,o&ation about
the&selves. %hatEs !eat ,o &onitoin! the state o,
the (2' and the sevlet containe3 but what about
4ou own applicationEs healthM
>ou have caches3 othe data stoes3 co&plex
ob9ects3 and a little bit o, eve4thin! !oin! on inside
4ou own application. 6ow can we pee1 unde those
covesM
So3 the (2' and %o&cat expose in,o&ation about
the&selves. %hatEs !eat ,o &onitoin! the state o,
the (2' and the sevlet containe3 but what about
4ou own applicationEs healthM
>ou have caches3 othe data stoes3 co&plex
ob9ects3 and a little bit o, eve4thin! !oin! on inside
4ou own application. 6ow can we pee1 unde those
covesM
'onitoin! >ou Application
'onitoin! >ou Application
@ite an 'Aean
@ite an 'Aean
public interface RequestStatsMBean {
public long getProcessingTime();
public long getRequestCount();
public void resetCounters();
Ceate (A0
(ava inte,ace
(ava i&ple&entation
&beans8desciptos.x&l
Ceate (A0
(ava inte,ace
(ava i&ple&entation
&beans8desciptos.x&l
0e&ote Access
La!e Scale
Constant
0e&ote Access
La!e Scale
Constant
All the exa&ples thus ,a have used 2isual2' which
is a 5F+ inte,ace. @hile thatEs ,un ,o inspectin! a
sin!le seve and &a4be doin! so&e scoutin! ,o
inteestin! data available3 itEs not !oin! to wo1 in the
eal wold o, poduction &onitoin!.
All the exa&ples thus ,a have used 2isual2' which
is a 5F+ inte,ace. @hile thatEs ,un ,o inspectin! a
sin!le seve and &a4be doin! so&e scoutin! ,o
inteestin! data available3 itEs not !oin! to wo1 in the
eal wold o, poduction &onitoin!.
Auto&ated 'onitoin!
Auto&ated 'onitoin!
0e&ote Access
La!e Scale
Constant
0e&ote Access
La!e Scale
Constant
$a!ios
Simple
Flexible
@ell8deplo4ed
$a!ios
Si&ple
Flexible
@ell8deplo4ed
Session count
0e7uest eo count
Session count
0e7uest eo count
Session count
0e7uest eos
< "5c/ec=%7m8pro84 +> K/ttp955local/ost5manager57m8pro84L
get-Catalina9t4pe-RequestProcessor$6or=er-./ttp+nio+?CO")")"?+
JC?O.$name-AttpRequest?Matt-errorCountK +6 ? +c ?) ++6rite errors"t8t ++compare
errors"t8t
FMG 3B9 3B + 'ttribute get KCatalina9t4pe-RequestProcessor$6or=er-./ttp+nio+
?CO")")"?+JC?O.$name-AttpRequest?K + errorCount - )$ delta-)
Session count
0e7uest eos
< "5c/ec=%7m8pro84 +> K/ttp955local/ost5manager57m8pro84L
get-Catalina9t4pe-RequestProcessor$6or=er-./ttp+nio+?CO")")"?+
JC?O.$name-AttpRequest?Matt-errorCountK +6 ? +c ?) ++6rite errors"t8t ++compare
errors"t8t
FMG 3B9 3B + 'ttribute get KCatalina9t4pe-RequestProcessor$6or=er-./ttp+nio+
?CO")")"?+JC?O.$name-AttpRequest?K + errorCount - )$ delta-)
%hee ae lots o, data whose ates o, chan!e ae
&oe i&potant than thei cuent values. Session
count and eo count ae a&on! the&.
%hee ae lots o, data whose ates o, chan!e ae
&oe i&potant than thei cuent values. Session
count and eo count ae a&on! the&.
;etectin! ?ut?,'e&o4
;etectin! ?ut?,'e&o4
Heap exhaustion
*e&5en exhaustion
6eap exhaustion
*e&5en exhaustion
Fse 8--:?n?ut?,'e&o4)o to un a
co&&and on first ??') detected b4 the
(2'
Fse 8--:?n?ut?,'e&o4)o to un a
co&&and on first ??') detected b4 the
(2'
*esentation Slides
/ttp955people"apac/e"org5Zsc/ultV5'pac/eCon 1' C)?P5Tomcat Monitoring5
chec1C9&xpox4
/ttp9556i=i"apac/e"org5tomcat5tools5c/ec=%7m8pro84"pl
*esentation Slides
/ttp955people"apac/e"org5Zsc/ultV5'pac/eCon 1' C)?P5Tomcat Monitoring5
chec1C9&xpox4
/ttp9556i=i"apac/e"org5tomcat5tools5c/ec=%7m8pro84"pl