Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve performance of Icinga 2 API commands processed in bulk #721

Merged
merged 7 commits into from Aug 10, 2023
Merged

Improve performance of Icinga 2 API commands processed in bulk #721

merged 7 commits into from Aug 10, 2023

Conversation

Al2Klimov
Copy link
Member

@Al2Klimov Al2Klimov commented Mar 1, 2023

Let me explain how I came here in the first place.

While discussing removal of some deprecated features with @Thomas-Gelf he opted against removing the command pipe. He considered it faster than the Icinga 2 API for massive stuff submission. I thought: wait, we have one system which eventually does massive stuff submission via API – Icinga Web. I even actually did that while testing Icinga ack sync. And it was indeed slow. I asked myself: what could it already do by itself to do this faster? What does it do right now? While reverse-engineering this repo I came to the conclusion that it renders, sends and awaits commands one by one. I remembered that @yhabteab did somewhere something with PHP event loops and let him show me them. They could help me sending multiple commands concurrently. It turned out more complicated than I thought, but then I remembered something else. @julianbrost digged out than our API supports not only DSL filters and filter_vars which iterate over all objects. It also supports targeting a specific object by name. This repo already does this. But it supports targeting multiple specific objects by array of names as well. That's what I did here.

Now the command forms render at best exactly one Icinga 2 API action request targeting all selected objects at once, not one request per object. Commenting e.g. 500 hosts now takes 4s, not 40. For this now commands and forms always handle multiple objects by design. PHP generators everywhere don't permit the RAM to blow up. Delete*Command are now parts of the ObjectsCommand family.

TODO

  • Approval of the concept in general
  • Agreement on the implementation details
  • What's up with GHA? (@Al2Klimov)
  • Tests of all code usages of all commands DB-Web supports

@cla-bot cla-bot bot added the cla/signed CLA is signed by all contributors of a PR label Mar 1, 2023
library/Icingadb/Command/Object/ObjectsCommand.php Outdated Show resolved Hide resolved
application/forms/Command/CommandForm.php Outdated Show resolved Hide resolved
application/forms/Command/CommandForm.php Outdated Show resolved Hide resolved
application/forms/Command/CommandForm.php Outdated Show resolved Hide resolved
@Al2Klimov Al2Klimov requested a review from nilmerg July 28, 2023 11:16
@nilmerg nilmerg added this to the 1.1.0 milestone Aug 2, 2023
@nilmerg nilmerg added the enhancement New feature or improvement label Aug 2, 2023
@nilmerg nilmerg changed the title Render one (not X) Icinga 2 API command targeting X objects Improve performance of Icinga 2 API commands processed in bulk Aug 2, 2023
@Al2Klimov
Copy link
Member Author

Tests

To do list

$ git diff --stat master..bulk-cmd application/forms/Command
 application/forms/Command/CommandForm.php                         | 51 +++++++++++++++++++++++++++++++--------------------
 application/forms/Command/Instance/ToggleInstanceFeaturesForm.php |  7 ++-----
 application/forms/Command/Object/AcknowledgeProblemForm.php       | 42 ++++++++++++++++++------------------------
 application/forms/Command/Object/AddCommentForm.php               | 34 ++++++++++++++--------------------
 application/forms/Command/Object/CheckNowForm.php                 | 45 +++++++++++++++++++++++----------------------
 application/forms/Command/Object/DeleteCommentForm.php            | 30 ++++++++++++++++--------------
 application/forms/Command/Object/DeleteDowntimeForm.php           | 36 +++++++++++++++++++-----------------
 application/forms/Command/Object/ProcessCheckResultForm.php       | 37 ++++++++++++++++++-------------------
 application/forms/Command/Object/RemoveAcknowledgementForm.php    | 24 +++++++++---------------
 application/forms/Command/Object/ScheduleCheckForm.php            | 45 +++++++++++++++++++++++----------------------
 application/forms/Command/Object/ScheduleHostDowntimeForm.php     | 53 +++++++++++++++++++++++++----------------------------
 application/forms/Command/Object/ScheduleServiceDowntimeForm.php  | 44 +++++++++++++++++++-------------------------
 application/forms/Command/Object/SendCustomNotificationForm.php   | 28 +++++++++++-----------------
 application/forms/Command/Object/ToggleObjectFeaturesForm.php     | 32 +++++++++++++++-----------------
 14 files changed, 243 insertions(+), 265 deletions(-)
$

Instance/ToggleInstanceFeaturesForm.php

Bildschirmaufnahme 2023-08-02 um 12 46 39

Object/AcknowledgeProblemForm.php

Bildschirmaufnahme 2023-08-02 um 12 57 32

Object/AddCommentForm.php

Bildschirmaufnahme 2023-08-02 um 12 59 25

Object/CheckNowForm.php

Bildschirmaufnahme 2023-08-02 um 13 01 16

Object/DeleteCommentForm.php

Bildschirmaufnahme 2023-08-02 um 13 03 06

Object/ScheduleServiceDowntimeForm.php

Bildschirmaufnahme 2023-08-02 um 13 04 02

Object/DeleteDowntimeForm.php

Bildschirmaufnahme 2023-08-02 um 13 05 00

Object/RemoveAcknowledgementForm.php

Bildschirmaufnahme 2023-08-02 um 13 06 22

Object/ProcessCheckResultForm.php

Bildschirmaufnahme 2023-08-02 um 13 07 04

Object/ToggleObjectFeaturesForm.php

Bildschirmaufnahme 2023-08-02 um 13 07 23

Object/ScheduleCheckForm.php

Bildschirmaufnahme 2023-08-02 um 13 09 18

Object/SendCustomNotificationForm.php

Bildschirmaufnahme 2023-08-02 um 13 10 54

Conclusion

It still works.

@Al2Klimov Al2Klimov removed their assignment Aug 2, 2023
@nilmerg nilmerg merged commit 17adfc2 into Icinga:master Aug 10, 2023
12 checks passed
@Al2Klimov Al2Klimov deleted the bulk-cmd branch August 10, 2023 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla/signed CLA is signed by all contributors of a PR enhancement New feature or improvement
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants