# Leistungsproblem im Dashboard mit vielen Grafiken

**URL:** <https://community.gladysassistant.com/t/probleme-de-performance-sur-dashboard-avec-beaucoup-de-graphiques/7522>\
**Category:** Configuration\
**Created:** [11. September 2022 um 18:27 UTC](https://community.gladysassistant.com/t/probleme-de-performance-sur-dashboard-avec-beaucoup-de-graphiques/7522 "2022-09-11T18:27:48Z")\
**Posts on this page:** 1\
**Showing post:** 49

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [29. September 2022 um 05:29 UTC](https://community.gladysassistant.com/t/probleme-de-performance-sur-dashboard-avec-beaucoup-de-graphiques/7522/49 "2022-09-29T05:29:25Z")

</div>

Zur Information arbeite ich heute an diesem Thema. Ich bin heute Morgen gut vorangekommen und habe einen Pull Request erstellt 🙂

**Mein Ansatz:**

Wenn ein Gerät registriert wird, bei dem mehrere Funktionen das Kontrollkästchen „Ja, Zustände beibehalten“ deaktiviert haben, starte ich Hintergrundjobs, die die vergangenen Zustände auf eine etwas intelligentere Weise bereinigen als bisher.

Der Job zählt in der Datenbank, wie viele Zustände bzw. aggregierte Zustände es für jede Funktion gibt, und bereinigt dann in kleinen Batches von 1000 Zuständen, um die Datenbank nicht zu überlasten. Zwischen jedem Batch wartet Gladys 100 ms, um Gladys etwas Luft zu verschaffen.

Um 5 Millionen Zustände zu bereinigen, sind also 5 Millionen / 1000 = 5.000 Batches erforderlich.

5.000 \* 0,1 = 500 Sekunden = 8,3 Minuten Wartezeit zwischen den Batches. Wenn man 100 ms pro Bereinigung hinzufügt, dauert es 16 Minuten, um 5 Millionen Zustände im Hintergrund auf **nicht blockierende** Weise und **sanft** zu bereinigen.

Auf Gladys-Seite können alle Hintergrundjobs in der Registerkarte „Hintergrundaufgaben“ in Echtzeit verfolgt werden:

 ![Screenshot 2022-09-29 at 12.21.17](https://gladys-assistant-community.b-cdn.net/uploads/default/original/2X/f/fce2a355da8d34b65ffe92782dc0495935a38ff5.png)

Dadurch können diese Aufgaben nachverfolgt und ihre Ausführung überwacht werden.

Normalerweise sollte die Registrierung eines Geräts nun sofort erfolgen, und Gladys sollte nicht mehr blockieren!

Ich werde meine Tests an größeren Datenbanken fortsetzen und sehen, wie ich mit dem VACUUM umgehe 😉

Der Pull Request:

> <https://github.com/GladysAssistant/Gladys/pull/1610>
>
> \### Pull Request check-list
> 
> To ensure your Pull Request can be accepted as fa…st as possible, make sure to review and check all of these items:
> 
> \- \[x\] If your changes affects code, did your write the tests?
> \- \[x\] Are tests passing? (\`npm test\` on both front/server)
> \- \[x\] Is the linter passing? (\`npm run eslint\` on both front/server)
> \- \[x\] Did you run prettier? (\`npm run prettier\` on both front/server)
> \- \[x\] If you are adding a new features/services, did you run integration comparator? (\`npm run compare-translations\` on front)
> \- \[x\] Did you test this pull request in real life? With real devices? If this development is a big feature or a new service, we recommend that you provide a Docker image to \[the community\](https://community.gladysassistant.com/) for testing before merging.
> \- \[x\] If your changes modify the API (REST or Node.js), did you modify the API documentation? (Documentation is based on comments in code)
> \- \[x\] If you are adding a new features/services which needs explanation, did you modify the user documentation? See \[the GitHub repo\](https://github.com/GladysAssistant/v4-website) and the \[website\](https://gladysassistant.com).
> \- \[x\] Did you add fake requests data for the demo mode (\`front/src/config/demo.js\`) so that the demo website is working without a backend? (if needed) See \[https://demo.gladysassistant.com\](https://demo.gladysassistant.com).
> 
> NOTE: these things are not required to open a PR and can be done afterwards / while the PR is open.
> 
> \### Description of change
> 
> Cleaning device feature states is now a background job
> 
> \<img width="914" alt="Screenshot 2022-09-29 at 12 21 17" src="https://user-images.githubusercontent.com/7365207/192945435-a9f9658f-c9f8-45f9-802c-51fff664a720.png"\>

---

_[View the full topic](https://community.gladysassistant.com/t/probleme-de-performance-sur-dashboard-avec-beaucoup-de-graphiques/7522)._
