HTTPServer.java thread pool size

13 views
Skip to first unread message

Milano Nicolum

unread,
Mar 23, 2020, 8:38:12 AM3/23/20
to Prometheus Users
Hi,
at the moment I use prometheus-java-client 0.8.1 with out of the box HTTPServer to expose metrics on my K8S pods and Prometheus discovery to scrape them.
I just wonder if there is any particular reason to use fixedThreadPool of size 5 as default. - https://github.com/prometheus/client_java/blob/master/simpleclient_httpserver/src/main/java/io/prometheus/client/exporter/HTTPServer.java#L167

As the metrics endpoint is usually accessed by prometheus scrape only I feel as 5 threads are quite a luxury to have on every pod. I wonder if there is any response time based reasoning behind the pool size or some situation I still have to experience.

While I guess the default HTTPServer could be replace by different implementation I just want to know what setup is the most lightweight and reliable at the same time.
Thanks,
Milan.

Brian Brazil

unread,
Mar 23, 2020, 8:40:57 AM3/23/20
to Milano Nicolum, Prometheus Users
On Mon, 23 Mar 2020 at 12:38, Milano Nicolum <drac...@gmail.com> wrote:
Hi,
at the moment I use prometheus-java-client 0.8.1 with out of the box HTTPServer to expose metrics on my K8S pods and Prometheus discovery to scrape them.
I just wonder if there is any particular reason to use fixedThreadPool of size 5 as default. - https://github.com/prometheus/client_java/blob/master/simpleclient_httpserver/src/main/java/io/prometheus/client/exporter/HTTPServer.java#L167

It's a hardcoded value, and it seems unlikely that you'd have 5 scrapes at once so it's a conservative choice.

Brian
 


As the metrics endpoint is usually accessed by prometheus scrape only I feel as 5 threads are quite a luxury to have on every pod. I wonder if there is any response time based reasoning behind the pool size or some situation I still have to experience.

While I guess the default HTTPServer could be replace by different implementation I just want to know what setup is the most lightweight and reliable at the same time.
Thanks,
Milan.

--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/9e57f6c6-51ad-49c0-8c9a-b3f58945143a%40googlegroups.com.


--

Milano Nicolum

unread,
Mar 23, 2020, 8:49:12 AM3/23/20
to Brian Brazil, Prometheus Users
So it would be possible to make a PR to make that value/Executorservice configurable?

Milan

po 23. 3. 2020 v 13:40 odesílatel Brian Brazil <brian....@robustperception.io> napsal:

Brian Brazil

unread,
Mar 23, 2020, 9:00:57 AM3/23/20
to Milano Nicolum, Prometheus Users
On Mon, 23 Mar 2020 at 12:49, Milano Nicolum <drac...@gmail.com> wrote:
So it would be possible to make a PR to make that value/Executorservice configurable?

Why do you need it to be bigger?

If you've more nice needed, you're probably best providing your own http server. That one is only meant to get you up and running quickly.

Brian

Milano Nicolum

unread,
Mar 23, 2020, 9:03:41 AM3/23/20
to Brian Brazil, Prometheus Users
Maybe I wasn't clear. I want the pool smaller. If there is only one Prometheus instance scraping it every 15 seconds or so, I don't think 5 threads are needed all the time.

Milan

po 23. 3. 2020 v 14:00 odesílatel Brian Brazil <brian....@robustperception.io> napsal:

Brian Brazil

unread,
Mar 23, 2020, 9:23:14 AM3/23/20
to Milano Nicolum, Prometheus Users
On Mon, 23 Mar 2020 at 13:03, Milano Nicolum <drac...@gmail.com> wrote:
Maybe I wasn't clear. I want the pool smaller. If there is only one Prometheus instance scraping it every 15 seconds or so, I don't think 5 threads are needed all the time.

Threads are pretty cheap, and the minimum safe number is around 3 so with that small a range I don't see a need for it to be configurable.

If your resource constraints are that tight, you probably need a custom server.

Brian
 

Milano Nicolum

unread,
Mar 23, 2020, 10:30:01 AM3/23/20
to Brian Brazil, Prometheus Users
OK, I admit it does not make sense to limit the pool from 5 to 3 as that would not make big difference. I guess those threads should not have large impact on resources usage anyway. It just looks slightly suspicious in Java VisualVM, where you can see five parked threads most of the time while other components go with a thread or two. Now I know why.

Thanks for your insight.
Milan

po 23. 3. 2020 v 14:23 odesílatel Brian Brazil <brian....@robustperception.io> napsal:
Reply all
Reply to author
Forward
0 new messages