# Topbeat very high CPU on a HAProxy server

**URL:** <https://discuss.elastic.co/t/topbeat-very-high-cpu-on-a-haproxy-server/37788>\
**Category:** Beats\
**Created:** [December 22, 2015, 7:16pm UTC](https://discuss.elastic.co/t/topbeat-very-high-cpu-on-a-haproxy-server/37788 "2015-12-22T19:16:27Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Omar\_Al\_Zabir](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/omar_al_zabir/32/5943_2.png) [@Omar\_Al\_Zabir](https://discuss.elastic.co/u/Omar_Al_Zabir)\
**Post date:** [December 22, 2015, 7:16pm UTC](https://discuss.elastic.co/t/topbeat-very-high-cpu-on-a-haproxy-server/37788/1 "2015-12-22T19:16:27Z")

</div>

top command shows topbeat consuming very high CPU on a HAproxy server that is getting around 400 req/sec.

```
  PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
13770 root 15 0 761m 378m 5904 R 66.2 4.7 41:23.84 topbeat
 2427 haproxy 15 0 45988 2676 840 S 11.3 0.0 2:42.13 haproxy
 2424 haproxy 15 0 46008 2780 920 S 10.0 0.0 2:38.81 haproxy
 2426 haproxy 15 0 46104 2732 796 S 8.3 0.0 2:49.87 haproxy
 2425 haproxy 16 0 45848 2584 796 S 7.3 0.0 2:42.12 haproxy
 2368 root 18 0 192m 1880 1052 S 7.0 0.0 0:53.25 rsyslogd
14152 root 15 0 118m 16m 4504 S 5.3 0.2 0:23.72 filebeat

```

66% CPU is taken by topbeat.

Nothing in topbeat log file.

---

<div class="post-metadata">

**Author:** ![andrewkroh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrewkroh/32/3784_2.png) [@andrewkroh](https://discuss.elastic.co/u/andrewkroh)\
**Post date:** [December 23, 2015, 12:20am UTC](https://discuss.elastic.co/t/topbeat-very-high-cpu-on-a-haproxy-server/37788/2 "2015-12-23T00:20:03Z")

</div>

Both the amount of CPU and memory seem to be unusually high.

- What version of topbeat are you running?
- How many processes are running on this system? Are there a lot of new processes being created?
- Can you post your config?

---

<div class="post-metadata">

**Author:** ![Omar\_Al\_Zabir](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/omar_al_zabir/32/5943_2.png) [@Omar\_Al\_Zabir](https://discuss.elastic.co/u/Omar_Al_Zabir)\
**Post date:** [December 23, 2015, 1:40pm UTC](https://discuss.elastic.co/t/topbeat-very-high-cpu-on-a-haproxy-server/37788/3 "2015-12-23T13:40:33Z")

</div>

I am using Topbeat 1.0. The latest one.  
My topbeat.yml has nothing special, the only things I have changed are:

```
input:
  period: 60

  procs: [".*"]

  stats:
    system: true
    proc: true
    filesystem: true

output:

  logstash:
    hosts: ["logstash.nat.bt.com:5047"]

```

The server does not start stop processes. Only HAProxy is running.

---

<div class="post-metadata">

**Author:** ![andrewkroh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrewkroh/32/3784_2.png) [@andrewkroh](https://discuss.elastic.co/u/andrewkroh)\
**Post date:** [December 23, 2015, 3:14pm UTC](https://discuss.elastic.co/t/topbeat-very-high-cpu-on-a-haproxy-server/37788/4 "2015-12-23T15:14:58Z")

</div>

I have a similar topbeat deployment (except I am using the elasticsearch output) and mine has remained constantly at about 15MB of memory and almost no CPU usage.

Would you be willing to collect some profiling information and attach it in this thread (or email it to me - andrew dot kroh at elastic dot co)? It would help us figure out where all those CPU cycles and memory are being used.

To do so, stop the service and run topbeat with the `-cpuprofile` and `-memprofile` options:

`topbeat -c /etc/topbeat/topbeat.yml -cpuprofile topbeat-1.0.1-cpu.prof -memprofile topbeat-1.0.1-mem.prof -e -v`

Let it run for a while then stop the process. It will write out two .prof files which we will look at with `go tool pprof`.

---

<div class="post-metadata">

**Author:** ![Omar\_Al\_Zabir](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/omar_al_zabir/32/5943_2.png) [@Omar\_Al\_Zabir](https://discuss.elastic.co/u/Omar_Al_Zabir)\
**Post date:** [December 23, 2015, 3:35pm UTC](https://discuss.elastic.co/t/topbeat-very-high-cpu-on-a-haproxy-server/37788/5 "2015-12-23T15:35:05Z")

</div>

Since I restarted topbeat, it is no longer taking high cpu/memory. Probably it gets stuck when there's issue with ES cluster. I will wait for another event and do the profile.

---

<div class="post-metadata">

**Author:** ![steffens](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/steffens/32/79630_2.png) [@steffens](https://discuss.elastic.co/u/steffens)\
**Post date:** [December 23, 2015, 4:31pm UTC](https://discuss.elastic.co/t/topbeat-very-high-cpu-on-a-haproxy-server/37788/6 "2015-12-23T16:31:04Z")

</div>

high memory usage is a sign for topbeat queuing up data + trying to reconnect and send to elasticsearch. This high CPU usage is still weird.

Which topbeat version have you installed? 1.0.0 or 1.0.1?

You can reduce memory usage be decreasing 'bulk\_max\_size' (in 1.0.1 value has been reduced to 200 to decrease memory usage) in logstash output.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 9:57pm UTC](https://discuss.elastic.co/t/topbeat-very-high-cpu-on-a-haproxy-server/37788/7 "2017-07-05T21:57:16Z")

</div>


