You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Supun Abeysinghe <su...@cse.mrt.ac.lk> on 2019/03/12 16:05:59 UTC
Tomcat Online Parameter Setting/Tuning
Hi all,
I am working on a project where the parameters of the tomcat server (e.g.
MaxThreads, MinSpareThreads, MaxSpareThreads etc.) for a given web
application is auto-tuned using a machine learning technique by looking at
the runtime characteristics (e.g. workload characteristics, current
performance etc.). As of my knowledge, the typical way of setting these
parameters is by changing the server.xml inside the {catalina-home}/conf
folder. In order to reconfigured/tuned values to get updated, we need to
restart the tomcat server. However, the project that I'm working on
requires the ability to change the parameters dynamically while the system
is running.
I have looked into several approaches. One way is to use JMX and use the
setters to set the parameter values. I have tried setting the MaxThreads
parameter of the shared executor thread pool and it seems to be working
fine. Now I'm looking into using that approach and set it up in my source
code and access MBeans to change the parameters.
I just wanted to know whether I'm going in the right direction. Also, is
there any other easier way of achieving what I want? I have gone through
prior work in this research area and seen many people have tuned tomcat
parameters in such a fashion. However, there seems to be no docs/articles
on this topic. Am I missing something here? Any feedback is highly
appreciated!
Tomcat version: 7.0.93
Thank you.
Best regards,
Supun
--
*Supun Abeysinghe*
Undergrad, Department of Computer Science and Engineering,
University of Moratuwa, Faculty of Engineering.
+94717018897
<https://lk.linkedin.com/pub/supun-abeysinghe/109/3a4/554>
Re: Tomcat Online Parameter Setting/Tuning
Posted by Mark Thomas <ma...@apache.org>.
On 12/03/2019 16:05, Supun Abeysinghe wrote:
> Hi all,
>
> I am working on a project where the parameters of the tomcat server (e.g.
> MaxThreads, MinSpareThreads, MaxSpareThreads etc.) for a given web
> application is auto-tuned using a machine learning technique by looking at
> the runtime characteristics (e.g. workload characteristics, current
> performance etc.). As of my knowledge, the typical way of setting these
> parameters is by changing the server.xml inside the {catalina-home}/conf
> folder. In order to reconfigured/tuned values to get updated, we need to
> restart the tomcat server. However, the project that I'm working on
> requires the ability to change the parameters dynamically while the system
> is running.
>
> I have looked into several approaches. One way is to use JMX and use the
> setters to set the parameter values. I have tried setting the MaxThreads
> parameter of the shared executor thread pool and it seems to be working
> fine. Now I'm looking into using that approach and set it up in my source
> code and access MBeans to change the parameters.
>
> I just wanted to know whether I'm going in the right direction. Also, is
> there any other easier way of achieving what I want? I have gone through
> prior work in this research area and seen many people have tuned tomcat
> parameters in such a fashion. However, there seems to be no docs/articles
> on this topic. Am I missing something here? Any feedback is highly
> appreciated!
JMX is the right approach. Just keep in mind that changes to some
parameters don't take effect until the component is restarted.
You might want to consider using
http://tomcat.apache.org/tomcat-9.0-doc/config/listeners.html#StoreConfig_Lifecycle_Listener_-_org.apache.catalina.storeconfig.StoreConfigLifecycleListener
to persist any changes you make.
The other thing to keep in mind is that most of the time is spent in
application code so you normally get a bigger return for your investment
if you focus on application tuning.
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: [OT] Tomcat Online Parameter Setting/Tuning
Posted by Supun Abeysinghe <su...@cse.mrt.ac.lk>.
Mark,
Thanks for the suggestion. I agree with you on tuning application-level
threads will have a higher impact. However, tuning these application-level
thread pools will make the tool application dependent whereas, at the
moment, I am thinking of a more general tool. Nonetheless, I'm still at a
POC level and if things work out, can look into that aspect as well.
Chris,
First of all, I'm still at a POC level. That being said, having the thread
pool size at a higher number does not always guarantee better performance.
In fact, I have conducted some experiments using different thread pool
sizes with different workloads and found out that for a given workload
type, there is a different optimal thread pool size that yields the best
performance (not only memory usage but also metrics like latency). This
might be caused by the additional context switches and other overheads
associated with a larger number of threads. Thus, simply running with X
number of threads throughout does not result in the optimal performance. In
this project, my plan is to tweak the thread pool size (and some other
parameters) during runtime to find out that optimal point dynamically.
This area of research has been studied extensively in the literature
(however, not sure about any real-world implementation though) and has
shown some promising results. Below figure is extracted from [1]. In [1],
they are proposing a reinforcement learning based algorithm (a subclass of
machine learning algorithms) to tune the parameters of a web application
dynamically. The figure below shows that response time shows a significant
decrement compared to the static default configuration. I'm trying to
extend this work using different machine learning algorithms.
[image: image.png]
As you have suggested, it is still questionable how things will work out in
a real-world system with bursty workloads. I will definitely conduct some
experiments with bursty workloads once I'm done with the implementation.
[1] https://www.sciencedirect.com/science/article/pii/S0743731511001924
Thank you.
Best regards,
Supun
On Wed, 13 Mar 2019 at 06:55, Christopher Schultz <
chris@christopherschultz.net> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
>
> Supun,
>
> On 3/12/19 12:05, Supun Abeysinghe wrote:
> > I am working on a project where the parameters of the tomcat server
> > (e.g. MaxThreads, MinSpareThreads, MaxSpareThreads etc.) for a
> > given web application is auto-tuned using a machine learning
> > technique by looking at the runtime characteristics (e.g. workload
> > characteristics, current performance etc.).
>
> I'm kind of curious about this. Is this Nest[1] for Tomcat?
>
> My experience is that traffic is bursty. That means that it's hard to
> predict when you'll need more resources -- like threads, one of the
> only things you can really tune at runtime. When you need them, you
> want them NOW, not when some algorithm finally gets around to
> detecting the burst of traffic you know has already begun.
>
> Since the server must be planned for X number of threads at peak
> volume, why not simply always run with X threads? There is really no
> penalty for leaving threads unused, other than "wasted" memory... that
> you would need if you needed the threads, anyway. It's not like you
> can use that memory for anything else, because you're going to need it
> at peak-load time.
>
> If you are interested in doing ML for capacity-tuning, I'd look more
> toward auto-scaling of *instances* rather than the resources being
> used by one single Tomcat instance. If I can scale-down my VMs
> deployed into, say, AWS, then I can save *real money* by scaling-back
> during low-load times and learning about trends to pre-scale things
> before e.g. the Friday-night rush or whatever happens to be "peak
> volume" for my particular use-case.
>
> - -chris
>
> [1] https://nest.com/thermostats/
> -----BEGIN PGP SIGNATURE-----
> Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/
>
> iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAlyIXA8ACgkQHPApP6U8
> pFhIexAAhhyCaSiQLaTlS3ySTzF5hHuH9Ft2TVXV8rC1/nOA11zelkQRad1Dpd1Z
> Ywks+Ag0OaZryld+S/oDCg2hbZEJ4yp2lCKhib9Vk85TGO6DnLM17Ul6Z7XOGstQ
> gQagjNBCd+lpRuaJ/d1esx1zhzUxD8eTSMRNGP1eZcOTRFUekQpSPlaEmJiczTdo
> /X79kL/NPV2evmJXlXrzBToqLPqpNVUrQMNmu6QZcwEP4eXNIaGIiUTD6WqnnHeJ
> jSppwqk/++RXJa2P17+6cue5fmyoUHcVKOypwYye6c7deEXPR5Kx8Nvdl/IB4VJU
> GsEhce9L+4R0EGRsgBEi0VW5OK4SxDYtmi+hdPxHDFXz1hocwAu3R0zdZspwJYo6
> ESFepwnvEA/yfrNJD/dkoVrndejuZQjBRHkTRDh4ELj/ce/jFW3q0WjESVTz0Mmt
> jrwnZsbqQ+qAFgcvYqQnBAyHguiJTfuRpDAg0kkkPfXLay65ESU5j8tAmoHR1S+V
> utuZOaStzFnDl0VRyFMhPzU0K32w29bpp0wSpb6COgwkIha1TDOIrVJTBlT5sjhr
> 0tXo2ex4TZXdGVkeGqwCGmu2SNZQcPSp3qVbYGzZ/w1duvqlPFoBkxpk04dWFEc1
> 6eixdMxP3fb0KAiowXbk3VFtLJblkzzum3+UavxB8+vOCn2v2kg=
> =Q1Uk
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
--
*Supun Abeysinghe*
Undergrad, Department of Computer Science and Engineering,
University of Moratuwa, Faculty of Engineering.
+94717018897
<https://lk.linkedin.com/pub/supun-abeysinghe/109/3a4/554>
Re: [OT] Tomcat Online Parameter Setting/Tuning
Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Supun,
On 3/12/19 12:05, Supun Abeysinghe wrote:
> I am working on a project where the parameters of the tomcat server
> (e.g. MaxThreads, MinSpareThreads, MaxSpareThreads etc.) for a
> given web application is auto-tuned using a machine learning
> technique by looking at the runtime characteristics (e.g. workload
> characteristics, current performance etc.).
I'm kind of curious about this. Is this Nest[1] for Tomcat?
My experience is that traffic is bursty. That means that it's hard to
predict when you'll need more resources -- like threads, one of the
only things you can really tune at runtime. When you need them, you
want them NOW, not when some algorithm finally gets around to
detecting the burst of traffic you know has already begun.
Since the server must be planned for X number of threads at peak
volume, why not simply always run with X threads? There is really no
penalty for leaving threads unused, other than "wasted" memory... that
you would need if you needed the threads, anyway. It's not like you
can use that memory for anything else, because you're going to need it
at peak-load time.
If you are interested in doing ML for capacity-tuning, I'd look more
toward auto-scaling of *instances* rather than the resources being
used by one single Tomcat instance. If I can scale-down my VMs
deployed into, say, AWS, then I can save *real money* by scaling-back
during low-load times and learning about trends to pre-scale things
before e.g. the Friday-night rush or whatever happens to be "peak
volume" for my particular use-case.
- -chris
[1] https://nest.com/thermostats/
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/
iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAlyIXA8ACgkQHPApP6U8
pFhIexAAhhyCaSiQLaTlS3ySTzF5hHuH9Ft2TVXV8rC1/nOA11zelkQRad1Dpd1Z
Ywks+Ag0OaZryld+S/oDCg2hbZEJ4yp2lCKhib9Vk85TGO6DnLM17Ul6Z7XOGstQ
gQagjNBCd+lpRuaJ/d1esx1zhzUxD8eTSMRNGP1eZcOTRFUekQpSPlaEmJiczTdo
/X79kL/NPV2evmJXlXrzBToqLPqpNVUrQMNmu6QZcwEP4eXNIaGIiUTD6WqnnHeJ
jSppwqk/++RXJa2P17+6cue5fmyoUHcVKOypwYye6c7deEXPR5Kx8Nvdl/IB4VJU
GsEhce9L+4R0EGRsgBEi0VW5OK4SxDYtmi+hdPxHDFXz1hocwAu3R0zdZspwJYo6
ESFepwnvEA/yfrNJD/dkoVrndejuZQjBRHkTRDh4ELj/ce/jFW3q0WjESVTz0Mmt
jrwnZsbqQ+qAFgcvYqQnBAyHguiJTfuRpDAg0kkkPfXLay65ESU5j8tAmoHR1S+V
utuZOaStzFnDl0VRyFMhPzU0K32w29bpp0wSpb6COgwkIha1TDOIrVJTBlT5sjhr
0tXo2ex4TZXdGVkeGqwCGmu2SNZQcPSp3qVbYGzZ/w1duvqlPFoBkxpk04dWFEc1
6eixdMxP3fb0KAiowXbk3VFtLJblkzzum3+UavxB8+vOCn2v2kg=
=Q1Uk
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org