Hello,
As comparison, a simple single threaded program can read at 3GBps+ on the same machine.
However, when we allocate 7 cores to filebeat, the maximum throughput i got from filebeat is only about 27MBps. allocating more cores did not seem to help to improve throughput. Any insights on why filebeat is so slow? or it is just filebeat is VERY in-efficient reading files.
I am using filebeat 7.2 and my config file is copied below. The command i used to run filebeat is:
taskset -c 45,46,47,48,49,50,51 filebeat-7.2/filebeat -c filebeat-7.2/filebeat.yml -path.data ./data -path.logs ./logs > /dev/null &
registry.flush: 1
queue.mem:
events: 524288
flush.min_events: 262144
flush.timeout: 1s
filebeat.max_procs: 7
#=========================== Filebeat prospectors =============================
filebeat.inputs:
- type: log
paths:
- logs/reader-logs/*
close_removed: true
clean_removed: true
symlinks: true
multiline.pattern: '^[[:digit:]]{4,}[[:punct:]][[:digit:]]{2,}|^[I|W|E|F|D|T][[:digit:]]{4,}'
multiline.negate: true
multiline.match: after
output.console:
pretty: false
bulk_max_size: 262144
worker: 7
My simple read file program is copied below, and "cat file > /dev/null" is faster my program.
string line;
ifstream infile;
infile.open("mylog");
while(!infile.eof())
{
getline(infile,line);
}
Btw, when perf on
$ perf stat -p 21186 sleep 30 (my simple readfile program)
Performance counter stats for process id '21186':
29929.798411 task-clock (msec) # 0.998 CPUs utilized
68 context-switches # 0.002 K/sec
287 cpu-migrations # 0.010 K/sec
0 page-faults # 0.000 K/sec
89,788,668,066 cycles # 3.000 GHz
291,205,032,556 instructions # 3.24 insn per cycle
65,831,832,834 branches # 2199.541 M/sec
1,469,251 branch-misses # 0.00% of all branches
30.001622575 seconds time elapsed
$ perf stat -p 19409 sleep 30 (fielbeat)
Performance counter stats for process id '19409': (filebeat)
Performance counter stats for process id '19409':
82839.873719 task-clock (msec) # 2.760 CPUs utilized
531,789 context-switches # 0.006 M/sec
20,841 cpu-migrations # 0.252 K/sec (100.00%)
240,580 page-faults # 0.003 M/sec (100.00%)
246,444,887,688 cycles # 2.975 GHz
295,357,314,548 instructions # 1.20 insn per cycle
63,517,014,753 branches # 766.744 M/sec
641,956,934 branch-misses # 1.01% of all branches (100.00%)
30.013647236 seconds time elapsed
Why filebeat has so many context-switches, cpu-migrations and page faults? I pin-ed both programs on CPU cores.
btw, even when I set up filebeat only read one file, it still has many context switches and page faults, I pined it to 2 CPU cores when I set filebeat read one file:
$ perf stat -p 26946 sleep 30
Performance counter stats for process id '26946':
39337.198450 task-clock (msec) # 1.311 CPUs utilized
285,855 context-switches # 0.007 M/sec (100.00%)
1,681 cpu-migrations # 0.043 K/sec (100.00%)
131,950 page-faults # 0.003 M/sec (100.00%)
116,937,084,408 cycles # 2.973 GHz
194,636,200,866 instructions # 1.66 insn per cycle (100.00%)
41,472,402,829 branches # 1054.280 M/sec (100.00%)
314,597,891 branch-misses # 0.76% of all branches (100.00%)
30.006805060 seconds time elapsed