Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

enh(api): improve performance of clapi call through REST API #7842

Merged
merged 1 commit into from
Sep 18, 2019
Merged

enh(api): improve performance of clapi call through REST API #7842

merged 1 commit into from
Sep 18, 2019

Conversation

tanguyvda
Copy link
Contributor

@tanguyvda tanguyvda commented Sep 6, 2019

Pull Request Template

Description

On huge plateforms, the array_walk in the for loop is the same as doing an infinity loop. You can't do a show service through the rest api even if you have a 5 minutes timeout in your php configuration. Thanks @kduret on this one, nice catch.

Type of change

  • Patch fixing an issue (non-breaking change)
  • New functionality (non-breaking change)
  • Breaking change (patch or feature) that might cause side effects breaking part of the Software
  • Updating documentation (missing information, typo...)

Target serie

  • 2.8.x
  • 18.10.x
  • 19.04.x
  • 19.10.x (master)

How this pull request can be tested ?

  • first of all, you need 290 000 services in your configuration (not in your monitoring, just your configuration)
  • configure your php.ini file to have a 5 minutes execution time timeout
  • vim /etc/opt/rh/rh-php71/php.ini and change the max_execution_time to be at 300
  • restart php-fpm, service rh-php71-php-fpm restart
  • authenticate yourself on the REST API
    curl -k -d 'username=xxxxxx&password=xxxxxxx' 'http://127.0.0.1/centreon/api/index.php?action=authenticate'
  • show all your service thanks to clapi through the webservice
    curl -H 'Content-type: application/json' -H 'centreon-auth-token: xxxxxxxxxxxxxx' -d '{"action": "show", "object": "SERVICE"}' 'http://127.0.0.1/centreon/api/index.php?action=action&object=centreon_clapi' -X POST
  • without the patch, it's going to reach de max_execution_time timeout, apply the patch, and it is going to take about 30 seconds (keep in mind that I'm testing that on physical servers, it might be longer on a virtual machine with less cpu/memory)

Any relevant details of the configuration to perform the test should be added.

Checklist

Community contributors & Centreon team

  • I followed the coding style guidelines provided by Centreon
  • I have commented my code, especially new classes, functions or any legacy code modified. (docblock)
  • I have commented my code, especially hard-to-understand areas of the PR.
  • I have made corresponding changes to the documentation.
  • I have rebased my development branch on the base branch (master, maintenance).

Centreon team only

  • I have made sure that the unit tests related to the story are successful.
  • I have made sure that unit tests cover 80% of the code written for the story.
  • I have made sure that acceptance tests related to the story are successful (local and CI)

Copy link
Contributor

@kduret kduret left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

already validated
we could merge it soon

@kduret kduret changed the title improves clapi through REST API performance enh(api): improve performance of clapi call through REST API Sep 11, 2019
@kduret kduret merged commit 8b8fc3a into centreon:master Sep 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants