# 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:** 13\
**Page:** 3

<div class="post-metadata">

**Author:** ![Will\_71](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/will_71/32/9582_2.png) [@Will\_71](https://community.gladysassistant.com/u/Will_71)\
**Post date:** [21. September 2022 um 13:46 UTC](https://community.gladysassistant.com/t/probleme-de-performance-sur-dashboard-avec-beaucoup-de-graphiques/7522/41 "2022-09-21T13:46:12Z")

</div>

Nach einem VACUUM über Nacht sollte man über die am wenigsten belastende Lösung nachdenken, denn zum Beispiel verwaltet Gladys und NodeRed meine elektrische Heizung und meinen Pellet-Ofen. Das bedeutet, dass mein Heizsystem jede Nacht zwischen 2 und 4 Uhr für 20 Minuten blockiert wäre?  
In diesem Fall würde ich lieber einen manuellen Modus für das VACUUM haben.  
Ein weiteres Beispiel: Wenn du Gladys eine Alarmanlage hinzufügst, hätten Einbrecher jede Nacht 20 Minuten freie Bahn.

---

<div class="post-metadata">

**Author:** ![Noj](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/n/258eb7/32.png) [@Noj](https://community.gladysassistant.com/u/Noj)\
**Post date:** [21. September 2022 um 14:06 UTC](https://community.gladysassistant.com/t/probleme-de-performance-sur-dashboard-avec-beaucoup-de-graphiques/7522/42 "2022-09-21T14:06:36Z")

</div>

Kann man sich nicht vorstellen, die Gesamtheit in mehrere Teile zu splitten, die dann auf die gleiche Weise gelöscht werden?

---

<div class="post-metadata">

**Author:** ![Will\_71](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/will_71/32/9582_2.png) [@Will\_71](https://community.gladysassistant.com/u/Will_71)\
**Post date:** [21. September 2022 um 14:08 UTC](https://community.gladysassistant.com/t/probleme-de-performance-sur-dashboard-avec-beaucoup-de-graphiques/7522/43 "2022-09-21T14:08:00Z")

</div>

Das ist auch eine der Lösungen, die @pierre-gilles vorschlägt

---

<div class="post-metadata">

**Author:** ![Noj](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/n/258eb7/32.png) [@Noj](https://community.gladysassistant.com/u/Noj)\
**Post date:** [21. September 2022 um 14:09 UTC](https://community.gladysassistant.com/t/probleme-de-performance-sur-dashboard-avec-beaucoup-de-graphiques/7522/44 "2022-09-21T14:09:38Z")

</div>

Ach danke.  
Ich habe zu schnell gelesen. 😅

---

<div class="post-metadata">

**Author:** ![VonOx](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/vonox/32/10128_2.png) [@VonOx](https://community.gladysassistant.com/u/VonOx)\
**Post date:** [21. September 2022 um 15:14 UTC](https://community.gladysassistant.com/t/probleme-de-performance-sur-dashboard-avec-beaucoup-de-graphiques/7522/45 "2022-09-21T15:14:49Z")

</div>

@pierre-gilles Das sollte beim Hinzufügen eines Features nicht passieren. Ich habe gerade getestet und wie die anderen dauert es eine Weile (4 Minuten auf amd64).

Ich habe 14 GB RAM für den Container, ich muss die Nutzung etwas begrenzen.

---

<div class="post-metadata">

**Author:** ![lmilcent](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/lmilcent/32/7023_2.png) [@lmilcent](https://community.gladysassistant.com/u/lmilcent)\
**Post date:** [21. September 2022 um 15:48 UTC](https://community.gladysassistant.com/t/probleme-de-performance-sur-dashboard-avec-beaucoup-de-graphiques/7522/46 "2022-09-21T15:48:40Z")

</div>

> [@VonOx](#):
>
> Ich habe 14 GB RAM für den Container, ich muss die Nutzung etwas begrenzen

😱 Wie ist das möglich, so viel RAM für Gladys? Was machst du damit?

---

<div class="post-metadata">

**Author:** ![Will\_71](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/will_71/32/9582_2.png) [@Will\_71](https://community.gladysassistant.com/u/Will_71)\
**Post date:** [21. September 2022 um 16:47 UTC](https://community.gladysassistant.com/t/probleme-de-performance-sur-dashboard-avec-beaucoup-de-graphiques/7522/47 "2022-09-21T16:47:42Z")

</div>

Sinon machen wir die DB-Reinigung nur, wenn wir ein Feature aus der Historie löschen

---

<div class="post-metadata">

**Author:** ![VonOx](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/vonox/32/10128_2.png) [@VonOx](https://community.gladysassistant.com/u/VonOx)\
**Post date:** [21. September 2022 um 17:10 UTC](https://community.gladysassistant.com/t/probleme-de-performance-sur-dashboard-avec-beaucoup-de-graphiques/7522/48 "2022-09-21T17:10:01Z")

</div>

Nichts Besonderes 😅

---

<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"\>

---

<div class="post-metadata">

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

</div>

Genial, ich kann es kaum erwarten, es zu testen.

> [@pierre-gilles](#):
>
> Ich bin heute Morgen gut vorangekommen und habe einen PR erstellt 🙂

Ich vermute, du bist in einer anderen Zeitzone oder schläfst nachts nicht? 😅

---

<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:56 UTC](https://community.gladysassistant.com/t/probleme-de-performance-sur-dashboard-avec-beaucoup-de-graphiques/7522/51 "2022-09-29T05:56:36Z")

</div>

Ja, ich bin in Bangkok 🙂 +5 Stunden Zeitverschiebung zu Frankreich!

---

<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 08:20 UTC](https://community.gladysassistant.com/t/probleme-de-performance-sur-dashboard-avec-beaucoup-de-graphiques/7522/52 "2022-09-29T08:20:33Z")

</div>

Was das VACUUM betrifft, habe ich mich für einen „manuellen“ Ansatz entschieden, zumindest vorerst, angesichts der Auswirkungen auf die Verfügbarkeit von Gladys bei großen Datenbanken.

Ich habe das VACUUM beim Registrieren der Geräte entfernt und eine manuelle Schaltfläche in den Systemeinstellungen hinzugefügt, mit einem Text, der klar darauf hinweist, dass Gladys während einer bestimmten Zeit nach dem VACUUM nicht verfügbar sein wird.

Die Idee ist, zunächst zu sehen, wie lange das VACUUM auf verschiedenen Instanzen dauert, und dem Benutzer die Wahl zu lassen, es durchzuführen oder nicht.

Anschließend können wir möglicherweise einen monatlichen Nachtjob hinzufügen, aber wir müssen dies gut kommunizieren und ihn deaktivierbar machen für diejenigen, die maximale Verfügbarkeit von Gladys wünschen.

**Der Button:**

 ![Screenshot 2022-09-29 at 15.17.44](https://gladys-assistant-community.b-cdn.net/uploads/default/original/2X/9/940b3d579d80a7dc6aea935f71baca3eebc9d6b1.jpeg)

**Der PR:**

> <https://github.com/GladysAssistant/Gladys/pull/1611>
>
> \### 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
> 
> \<img width="1227" alt="Screenshot 2022-09-29 at 14 59 03" src="https://user-images.githubusercontent.com/7365207/192978347-a17d0bc3-9895-4771-8d25-6e9fe37a3982.png"\>

---

<div class="post-metadata">

**Author:** ![lmilcent](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/lmilcent/32/7023_2.png) [@lmilcent](https://community.gladysassistant.com/u/lmilcent)\
**Post date:** [3. Oktober 2022 um 12:59 UTC](https://community.gladysassistant.com/t/probleme-de-performance-sur-dashboard-avec-beaucoup-de-graphiques/7522/53 "2022-10-03T12:59:02Z")

</div>

Die Speichereinsparung ist in den Backups von Gladys Plus gut sichtbar 🎉  
(diese Backups sind komprimiert, meine Datenbank war vorher 7 GB groß)

 ![image](https://gladys-assistant-community.b-cdn.net/uploads/default/original/2X/e/ef60227970f9528c6cd61a0ca749107a7bb376c3.png)

[Vorherige Seite](https://community.gladysassistant.com/t/probleme-de-performance-sur-dashboard-avec-beaucoup-de-graphiques/7522.md?page=2)
