REST-API performance

CMK version: 2.2.0p14.cee
**OS version:**Ubuntu 22.04.3 LTS

I have a question about the performance of the REST API compared to Livestatus queries. When I query the same data via the REST API, it takes about 17 seconds, which is more than 25 times what it takes with Livestatus to retrieve the exact same data. So the question is, am I doing it wrong
or is the REST API just that much slower?

The code can be found here bin/topology_data/create_topology_classes.py · master · CheckMK / Vendor independent / Network Visualization data creation tool · GitLab

Here are some sample data

Count → request number
What → query the host’s inventory data or the host’s service descriptions
Livestatus (socket) → time via local luvstatus (Unix socket)
Livsatus (lib) → time with livestatus python lib (import livestatus)
Filesystem-> data retrieval through direct file access
REST-API → call with overhead from my tool
Elapsed-> time only for the request

Except for Elapsed, all times are measured at exactly the same place in my code, so they all contain the overhead for the various function calls. Elapsed is from “resp.elapsed” only.

Count What Host Livestatus (socket) Livsatus (lib) Filesystem Rest-API elapsed
1 inventory Host01 0,043278463 0,004883836 0,003256210 0,039624452 0,038133000
2 items Host01 0,003547118 0,001211029 0,001419394 0,153732592 0,150669000
3 inventory Host02 0,005743197 0,000769551 0,001139298 0,035087218 0,034376000
4 items Host02 0,009009912 0,000724704 0,000467531 0,151083014 0,148707000
5 inventory Host03 0,003657788 0,002988547 0,000045393 0,051978970 0,051171000
6 items Host03 0,003997984 0,001167893 0,088080000 0,144504296 0,142661000
7 inventory Host04 0,009738581 0,004637759 0,002166393 0,037588940 0,036772000
8 items Host04 0,004398248 0,001369192 0,001379171 0,164676073 0,162706000
9 inventory Host05 0,011743506 0,003498969 0,000043781 0,042433158 0,041727000
10 items Host05 0,00355826 0,001077943 0,000023224 0,168054662 0,166105000
11 inventory Host06 0,004022033 0,037389322 0,002155440 0,037557271 0,036922000
12 items Host06 0,003881669 0,004128302 0,001395354 0,142596461 0,140409000
13 inventory Host07 0,004741238 0,003474990 0,002274687 0,040057657 0,039298000
14 items Host07 0,017134006 0,002035353 0,001580299 0,152959386 0,150992000
15 inventory Host08 0,004351887 0,005437477 0,000065076 0,042987343 0,042259000
16 items Host08 0,004085543 0,002055860 0,000062428 0,143538896 0,141862000
17 inventory Host09 0,003915289 0,007045143 0,003915322 0,033324825 0,032689000
18 items Host09 0,004580237 0,001918588 0,002202185 0,142146452 0,140508000
19 inventory Host10 0,013552551 0,012032620 0,004079633 0,036807860 0,036163000
20 items Host10 0,004416976 0,001551752 0,002604353 0,149796082 0,147856000
21 inventory Host11 0,00422975 0,005641658 0,039015113 0,037366801 0,036617000
22 items Host11 0,002903036 0,001551697 0,009174948 0,139584352 0,137831000
23 inventory Host12 0,002518531 0,004858769 0,002253097 0,032127385 0,031662000
24 items Host12 0,002330471 0,001454863 0,001237927 0,138842676 0,137270000
25 inventory Host13 0,0143281 0,005636671 0,002431709 0,067473154 0,065468000
26 items Host13 0,004025181 0,001423487 0,001298713 0,165414442 0,163055000
27 inventory Host14 0,014359937 0,006143693 0,003444773 0,035204001 0,034547000
28 items Host14 0,050884412 0,001450466 0,001959468 0,143544845 0,141787000
29 inventory Host15 0,000263237 0,006024773 0,003430385 0,185052157 0,184401000
30 items Host15 0,000693391 0,001766171 0,002210003 0,168224172 0,166294000
31 inventory Host16 0,000675187 0,005189267 0,003253911 0,044098492 0,043301000
32 items Host16 0,002721562 0,001682673 0,002059928 0,152472795 0,150717000
33 inventory Host17 0,001531207 0,005986428 0,003102204 0,037380606 0,036562000
34 items Host17 0,001667383 0,007628108 0,001928257 0,155397830 0,153741000
35 inventory Host18 0,002292542 0,013536531 0,002964341 0,043308780 0,042451000
36 items Host18 0,000889225 0,001524270 0,002286771 0,143034623 0,141316000
37 inventory Host19 0,008191279 0,033058961 0,003259197 0,040958234 0,040185000
38 items Host19 0,001033347 0,010864653 0,001955970 0,374700809 0,372458000
39 inventory Host20 0,003726163 0,013454326 0,002959150 0,040181495 0,039219000
40 items Host20 0,000178054 0,002289354 0,002199686 0,154434616 0,152543000
41 inventory Host21 0,00358302 0,006873848 0,003319895 0,040043677 0,039296000
42 items Host21 0,000946736 0,001949983 0,001874486 0,160821748 0,158878000
43 inventory Host22 0,00266486 0,019754847 0,003077352 0,048795443 0,047966000
44 items Host22 0,000153967 0,002330852 0,001997683 0,151109240 0,149344000
45 inventory Host23 0,000626491 0,010464412 0,002967465 0,038677467 0,037839000
46 items Host23 0,003950681 0,001707017 0,002106588 0,154194859 0,152107000
47 inventory Host24 0,002488576 0,005399605 0,007921154 0,041579105 0,040719000
48 items Host24 0,001616159 0,001620974 0,002065501 0,152809942 0,150933000
49 inventory Host25 0,002016444 0,006315517 0,002927052 0,036398743 0,035560000
50 items Host25 0,000161695 0,001662745 0,002032190 0,139421652 0,137629000
51 inventory Host26 0,000137207 0,005478682 0,002990115 0,038090488 0,037211000
52 items Host26 0,006103493 0,001487154 0,001844220 0,137832537 0,136161000
53 inventory Host27 0,000737226 0,003812309 0,003019223 0,039376398 0,038388000
54 items Host27 0,006092311 0,001341039 0,001985540 0,155298553 0,153482000
55 inventory Host28 0,000221037 0,005836381 0,003002525 0,039188894 0,038496000
56 items Host28 0,000555285 0,001560130 0,001902443 0,149509093 0,147378000
57 inventory Host29 0,000581421 0,003546692 0,002858924 0,059714604 0,058855000
58 items Host29 0,000157999 0,001241877 0,002043406 0,157462117 0,154655000
59 inventory Host30 0,002721737 0,005215301 0,003179523 0,043383110 0,042443000
60 items Host30 0,002379767 0,012050330 0,001793395 0,149450102 0,147544000
61 inventory Host31 0,00152561 0,007790640 0,003162618 0,041383136 0,040571000
62 items Host31 0,000150588 0,001366088 0,001977813 0,151497469 0,149295000
63 inventory Host32 0,002427615 0,034834123 0,002351913 0,041401821 0,040537000
64 items Host32 0,000165051 0,017681425 0,001313928 0,179436447 0,176963000
65 inventory Host33 0,001156283 0,014896550 0,001956935 0,039563673 0,038746000
66 items Host33 0,00030177 0,002924594 0,001095776 0,155750152 0,153831000
67 inventory Host34 0,001388331 0,001163157 0,001936933 0,046475833 0,045622000
68 items Host34 0,002205803 0,001008297 0,001069023 0,156145892 0,154110000
69 inventory Host35 0,00979737 0,003364307 0,002704372 0,050254440 0,049359000
70 items Host35 0,001263908 0,001582017 0,001661920 0,160727122 0,158760000
71 inventory Host36 0,003084068 0,002623746 0,003282226 0,037110734 0,036309000
72 items Host36 0,002118135 0,001373128 0,001736321 0,142843325 0,140905000
73 inventory Host37 0,043278463 0,005400199 0,011496026 0,036846771 0,036141000
74 items Host37 0,003547118 0,001418453 0,012758341 0,164394280 0,156909000
75 inventory Host38 0,005743197 0,002826740 0,011692093 0,041692693 0,040863000
76 items Host38 0,009009912 0,003396567 0,007285939 0,145037660 0,143063000
77 inventory Host39 0,003657788 0,002728714 0,000081967 0,046373983 0,045395000
78 items Host39 0,003997984 0,001186476 0,000026307 0,139111161 0,136905000
79 inventory Host40 0,009738581 0,000926875 0,000731390 0,052492473 0,051013000
80 items Host40 0,004398248 0,000853560 0,000333317 0,144576749 0,142627000
81 inventory Host41 0,011743506 0,003175852 0,000560780 0,033586475 0,033014000
82 items Host41 0,00355826 0,001248463 0,000227615 0,137528158 0,135718000
83 inventory Host42 0,004022033 0,002574762 0,000403885 0,031368639 0,030815000
84 items Host42 0,003881669 0,001093427 0,000187913 0,159695434 0,157710000
85 inventory Host43 0,004741238 0,005246641 0,000410012 0,038397995 0,037822000
86 items Host43 0,017134006 0,002287478 0,000303023 0,154544946 0,152352000
87 inventory Host44 0,004351887 0,001394339 0,000398449 0,038444323 0,037742000
88 items Host44 0,004085543 0,001297781 0,000203798 0,154323462 0,152287000
89 inventory Host45 0,003915289 0,003358861 0,000035381 0,038740299 0,038129000
90 items Host45 0,004580237 0,001735978 0,000021989 0,185933814 0,184165000
91 inventory Host46 0,013552551 0,001224443 0,001875377 0,036202285 0,035562000
92 items Host46 0,004416976 0,001316079 0,001358813 0,141594230 0,139423000
93 inventory Host47 0,00422975 0,001388198 0,001192812 0,034690518 0,034066000
94 items Host47 0,002903036 0,001139399 0,001208587 0,146869218 0,144387000
95 inventory Host48 0,002518531 0,004451141 0,001025641 0,042508643 0,041868000
96 items Host48 0,002330471 0,002196462 0,001169321 0,152422651 0,150500000
97 inventory Host49 0,0143281 0,001642769 0,000173903 0,040596831 0,039592000
98 items Host49 0,004025181 0,001025493 0,000033407 0,149218336 0,147087000
99 inventory Host50 0,014359937 0,001636028 0,020270000 0,031948993 0,031193000
100 items Host50 0,050884412 0,001216412 0,000016331 0,167411149 0,165420000
101 inventory Host51 0,000263237 0,001482972 0,001224939 0,040294653 0,039634000
102 items Host51 0,000693391 0,000971214 0,001360985 0,168782744 0,166708000
103 inventory Host52 0,000675187 0,000934221 0,000071965 0,033592085 0,033051000
104 items Host52 0,002721562 0,000859220 0,000023348 0,157965733 0,155884000
105 inventory Host53 0,001531207 0,000823558 0,003264961 0,038248038 0,037689000
106 items Host53 0,001667383 0,000786571 0,001810148 0,145258264 0,143413000
107 inventory Host54 0,002292542 0,000792935 0,053460000 0,036918596 0,036352000
108 items Host54 0,000889225 0,000800595 0,000021971 0,158098700 0,156142000
109 inventory Host55 0,008191279 0,000891023 0,001915986 0,031753927 0,031250000
110 items Host55 0,001033347 0,000836846 0,001272367 0,144203140 0,142171000
111 inventory Host56 0,003726163 0,001807369 0,001001700 0,033685768 0,033139000
112 items Host56 0,000178054 0,000952776 0,000936745 0,140597626 0,138490000
113 inventory Host57 0,00358302 0,000819556 0,001018956 0,042997341 0,042310000
114 items Host57 0,000946736 0,000755580 0,001069482 0,145305220 0,143209000
115 inventory Host58 0,00266486 0,002749097 0,000072195 0,040008774 0,039292000
116 items Host58 0,000153967 0,001346940 0,000029331 0,143128192 0,141034000
117 inventory Host59 0,000626491 0,002403389 0,020480000 0,035038065 0,034464000
118 items Host59 0,003950681 0,001157705 0,000015792 0,228888928 0,226760000
119 inventory Host60 0,002488576 0,005144167 0,000808032 0,039300831 0,038774000
120 items Host60 0,001616159 0,001584022 0,000526153 0,300427271 0,298389000
121 inventory Host61 0,002016444 0,001881909 0,000030573 0,041827544 0,041255000
122 items Host61 0,000161695 0,001062810 0,000019457 0,293493180 0,291051000
123 inventory Host62 0,000137207 0,000923418 0,000785329 0,139867619 0,139078000
124 items Host62 0,006103493 0,001011116 0,000421179 0,534985316 0,532938000
125 inventory Host63 0,000737226 0,002968671 0,000897956 0,182949239 0,182299000
126 items Host63 0,006092311 0,001702593 0,000501948 0,447568691 0,445375000
127 inventory Host64 0,000221037 0,003399470 0,002752787 0,085727721 0,085019000
128 items Host64 0,000555285 0,001200624 0,001744047 0,451867132 0,449920000
129 inventory Host65 0,000581421 0,002047550 0,001766506 0,105919956 0,105382000
130 items Host65 0,000157999 0,001190199 0,001001417 0,414832563 0,412667000
131 inventory Host66 0,002721737 0,002307098 0,000043044 0,044693082 0,044003000
132 items Host66 0,002379767 0,001187713 0,000020443 0,204356950 0,202156000
133 inventory Host67 0,00152561 0,000824626 0,000021094 0,053153642 0,052431000
134 items Host67 0,000150588 0,000837300 0,000081638 0,290546743 0,288027000
135 inventory Host68 0,002427615 0,001389643 0,001751013 0,062361914 0,060724000
136 items Host68 0,000165051 0,001071168 0,001199199 0,262598868 0,258345000
137 inventory Host69 0,001156283 0,000877837 0,001309103 0,166101110 0,164766000
138 items Host69 0,00030177 0,000796205 0,000869611 0,274987431 0,266720000
139 inventory Host70 0,001388331 0,001431734 0,000403739 0,128670033 0,127801000
140 items Host70 0,002205803 0,001005069 0,000292860 0,235356424 0,232457000
141 inventory Host71 0,00979737 0,003039884 0,001730963 0,050548161 0,049870000
142 items Host71 0,001263908 0,001224376 0,001069711 0,228229221 0,225311000
143 inventory Host72 0,003084068 0,001943070 0,008387831 0,064186803 0,062588000
144 items Host72 0,002118135 0,004238116 0,000863873 0,217553160 0,213875000
sum 0,690436115 0,543434845 0,482908102 16,900961097 16,683408

We are looking into this. :eyes:

1 Like

@robin.gierse any news on this? Were you able to reproduce the issue?

I do apologize for the late answer. This one slipped through the cracks.

To our current knowledge, this issue is endpoint-specific and not a general issue with the REST API. Possible reasons include additional validations performed by the API, which do not occur for the other access methods.

I have the same issue and the answers I am getting are mostly not helpful at all but what I have been told and found out about is if you want to process data a little bit faster try to rely more on:

  • Livestatus querys with a TCP socket connection
  • REST-API Bulk… operations (instead of doing things one by one give the API a list of hosts, etc.)
  • Views you can customize and then get a REST-API style output (see: Host and service views)

At least that helped me a bit I don’t know if this was helpful to you.
Regardless cool project!

This works fine

I don’t think this will help in my case as I am switching from host to host (check a host to see if it has connections to another host [search inventory], if so, start again with the host found). Maybe I can optimise a bit here (query all found hosts together). In the end, however, most queries will always be for one or two hosts.

Thank :slight_smile:

Happens :wink:

As it should be in your interest to close the performance gap between Livestatus querys and REST-API, i hope you work on this. If so let me know if i can help (test) with it (PM is OK :slight_smile: )

2 Likes