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

Set timer to reduce load #424

Merged
merged 7 commits into from
Feb 1, 2024
Merged

Set timer to reduce load #424

merged 7 commits into from
Feb 1, 2024

Conversation

Alopalao
Copy link

@Alopalao Alopalao commented Jan 29, 2024

Close #373

Summary

Set a timer to reduce load to database.
The timer will stop first event, while updating last received interface event. When timer ends, the last event will be applied.
Example in used:

2024-01-30 07:20:56,482 - WARNING [kytos.napps.kytos/mef_eline] (thread_pool_sb_155) TIMING -> 00:00:00:00:00:00:00:02:3 -> kytos/of_core.switch.interface.link_down            <----- Start time here for 02:3
2024-01-30 07:20:56,487 - WARNING [kytos.napps.kytos/mef_eline] (thread_pool_sb_130) RETURN -> 00:00:00:00:00:00:00:02:3 -> kytos/of_core.switch.interface.link_up
2024-01-30 07:20:56,487 - WARNING [kytos.napps.kytos/mef_eline] (thread_pool_sb_14) TIMING -> 00:00:00:00:00:00:00:01:4 -> kytos/of_core.switch.interface.link_down             <----- Start time here for 01:4
2024-01-30 07:20:56,489 - WARNING [kytos.napps.kytos/mef_eline] (thread_pool_sb_112) RETURN -> 00:00:00:00:00:00:00:01:4 -> kytos/of_core.switch.interface.link_up
2024-01-30 07:20:56,506 - WARNING [kytos.napps.kytos/mef_eline] (thread_pool_sb_63) RETURN -> 00:00:00:00:00:00:00:02:3 -> kytos/of_core.switch.interface.link_down
2024-01-30 07:20:56,506 - WARNING [kytos.napps.kytos/mef_eline] (thread_pool_sb_39) RETURN -> 00:00:00:00:00:00:00:02:3 -> kytos/of_core.switch.interface.link_up
2024-01-30 07:20:56,508 - WARNING [kytos.napps.kytos/mef_eline] (thread_pool_sb_22) RETURN -> 00:00:00:00:00:00:00:01:4 -> kytos/of_core.switch.interface.link_down
2024-01-30 07:20:56,509 - WARNING [kytos.napps.kytos/mef_eline] (thread_pool_sb_73) RETURN -> 00:00:00:00:00:00:00:01:4 -> kytos/of_core.switch.interface.link_up
2024-01-30 07:20:56,533 - WARNING [kytos.napps.kytos/mef_eline] (thread_pool_sb_6) RETURN -> 00:00:00:00:00:00:00:01:4 -> kytos/of_core.switch.interface.link_down
2024-01-30 07:20:56,533 - WARNING [kytos.napps.kytos/mef_eline] (thread_pool_sb_9) RETURN -> 00:00:00:00:00:00:00:02:3 -> kytos/of_core.switch.interface.link_down
2024-01-30 07:20:56,535 - WARNING [kytos.napps.kytos/mef_eline] (thread_pool_sb_54) RETURN -> 00:00:00:00:00:00:00:02:3 -> kytos/of_core.switch.interface.link_up
2024-01-30 07:20:56,566 - WARNING [kytos.napps.kytos/mef_eline] (thread_pool_sb_54) RETURN -> 00:00:00:00:00:00:00:01:4 -> kytos/of_core.switch.interface.link_up
2024-01-30 07:20:56,583 - WARNING [kytos.napps.kytos/mef_eline] (thread_pool_sb_155) PROCESS -> 00:00:00:00:00:00:00:02:3 -> kytos/of_core.switch.interface.link_up             <----- Finnished 02:3
2024-01-30 07:20:56,589 - WARNING [kytos.napps.kytos/mef_eline] (thread_pool_sb_14) PROCESS -> 00:00:00:00:00:00:00:01:4 -> kytos/of_core.switch.interface.link_up              <----- Finnished 01:4

End-To-End Tests

============================= test session starts ==============================
platform linux -- Python 3.9.2, pytest-7.2.0, pluggy-1.4.0
rootdir: /tests
plugins: timeout-2.1.0, rerunfailures-10.2, anyio-3.6.2
collected 256 items

tests/test_e2e_01_kytos_startup.py ..                                    [  0%]
tests/test_e2e_05_topology.py ....................                       [  8%]
tests/test_e2e_10_mef_eline.py ..........ss.....x.....x................  [ 24%]
tests/test_e2e_11_mef_eline.py ......                                    [ 26%]
tests/test_e2e_12_mef_eline.py .....Xx.                                  [ 29%]
tests/test_e2e_13_mef_eline.py ....Xs.s.....Xs.s.XXxX.xxxx..X........... [ 45%]
.                                                                        [ 46%]
tests/test_e2e_14_mef_eline.py x                                         [ 46%]
tests/test_e2e_15_mef_eline.py .....                                     [ 48%]
tests/test_e2e_20_flow_manager.py .....................                  [ 56%]
tests/test_e2e_21_flow_manager.py ...                                    [ 57%]
tests/test_e2e_22_flow_manager.py ...............                        [ 63%]
tests/test_e2e_23_flow_manager.py ..............                         [ 69%]
tests/test_e2e_30_of_lldp.py ....                                        [ 70%]
tests/test_e2e_31_of_lldp.py ...                                         [ 71%]
tests/test_e2e_32_of_lldp.py ...                                         [ 73%]
tests/test_e2e_40_sdntrace.py ..............                             [ 78%]
tests/test_e2e_41_kytos_auth.py ........                                 [ 81%]
tests/test_e2e_42_sdntrace.py ..                                         [ 82%]
tests/test_e2e_50_maintenance.py ........................                [ 91%]
tests/test_e2e_60_of_multi_table.py .....                                [ 93%]
tests/test_e2e_70_kytos_stats.py ........                                [ 96%]
tests/test_e2e_80_pathfinder.py ss......                                 [100%]

@Alopalao Alopalao marked this pull request as ready for review January 29, 2024 17:27
@Alopalao Alopalao requested a review from a team as a code owner January 29, 2024 17:27
Copy link
Member

@viniarck viniarck left a comment

Choose a reason for hiding this comment

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

It's a good start, but there's a potential concurrency issue. Check out my comment.

Also, don't forget to update the changelog and ship unit tests once the implemenation is working as expected.

main.py Outdated Show resolved Hide resolved
main.py Outdated Show resolved Hide resolved
@viniarck viniarck self-requested a review January 30, 2024 14:24
@Alopalao
Copy link
Author

Alopalao commented Jan 30, 2024

APM results:
Laps were sent every 1 second.
Previous mef_eline implementation. Peak 144tpm:
0by1

Current implementation, TIME_INTERFACE = 1. Peak 56tpm:
1by1

Current implementation, TIME_INTERFACE = 10. Peak 24tpm:
10by1

Copy link
Member

@viniarck viniarck left a comment

Choose a reason for hiding this comment

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

Nicely done @Alopalao, it's looking great, very neat how it ended up not even needing a deque at this time, I asked trivial implementation detail changes though, check them out. Did you also have a chance to also run a stress link flap test with this last code while monitoring with the APM? (the chart with 1 flap / sec are looking great)

settings.py Outdated Show resolved Hide resolved
main.py Outdated Show resolved Hide resolved
main.py Outdated Show resolved Hide resolved
main.py Outdated Show resolved Hide resolved
main.py Show resolved Hide resolved
@viniarck viniarck self-requested a review January 30, 2024 17:51
Copy link
Member

@viniarck viniarck left a comment

Choose a reason for hiding this comment

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

@Alopalao, excellent PR. It's great to see simple and elegant solutions like this one here. Consider it approved.

I'm just waiting these things before approving and merging it:

  • Fix linter errors
  • Make sure e2e mef eline tests are passing
  • Update changelog

main.py Outdated Show resolved Hide resolved
@viniarck viniarck self-requested a review January 31, 2024 15:34
Copy link
Member

@viniarck viniarck left a comment

Choose a reason for hiding this comment

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

Leaving it pre-approved. It'll get merged once changelog is updated.

@Alopalao, in the last e2e you posted here there was a RRF on topology, it's probably unrelated, but investigate it and open an issue on e2e repo if needed. Thanks.

@Alopalao
Copy link
Author

Alopalao commented Jan 31, 2024

E2E test results. The previous result was from an outdated e2e repo.

============================= test session starts ==============================
platform linux -- Python 3.9.2, pytest-7.2.0, pluggy-1.4.0
rootdir: /tests
plugins: timeout-2.1.0, rerunfailures-10.2, anyio-3.6.2
collected 256 items

tests/test_e2e_01_kytos_startup.py ..                                    [  0%]
tests/test_e2e_05_topology.py ....................                       [  8%]
tests/test_e2e_10_mef_eline.py ..........ss.....x.....x................  [ 24%]
tests/test_e2e_11_mef_eline.py ......                                    [ 26%]
tests/test_e2e_12_mef_eline.py .....Xx.                                  [ 29%]
tests/test_e2e_13_mef_eline.py ....Xs.s.....Xs.s.XXxX.xxxx..X........... [ 45%]
.                                                                        [ 46%]
tests/test_e2e_14_mef_eline.py x                                         [ 46%]
tests/test_e2e_15_mef_eline.py .....                                     [ 48%]
tests/test_e2e_20_flow_manager.py .....................                  [ 56%]
tests/test_e2e_21_flow_manager.py ...                                    [ 57%]
tests/test_e2e_22_flow_manager.py ...............                        [ 63%]
tests/test_e2e_23_flow_manager.py ..............                         [ 69%]
tests/test_e2e_30_of_lldp.py ....                                        [ 70%]
tests/test_e2e_31_of_lldp.py ...                                         [ 71%]
tests/test_e2e_32_of_lldp.py ...                                         [ 73%]
tests/test_e2e_40_sdntrace.py ..............                             [ 78%]
tests/test_e2e_41_kytos_auth.py ........                                 [ 81%]
tests/test_e2e_42_sdntrace.py ..                                         [ 82%]
tests/test_e2e_50_maintenance.py ........................                [ 91%]
tests/test_e2e_60_of_multi_table.py .....                                [ 93%]
tests/test_e2e_70_kytos_stats.py ........                                [ 96%]
tests/test_e2e_80_pathfinder.py ss......                                 [100%]

@viniarck
Copy link
Member

E2E test results. The previous result was from an outdated e2e repo.

============================= test session starts ==============================
platform linux -- Python 3.9.2, pytest-7.2.0, pluggy-1.4.0
rootdir: /tests
plugins: timeout-2.1.0, rerunfailures-10.2, anyio-3.6.2
collected 256 items

tests/test_e2e_01_kytos_startup.py ..                                    [  0%]
tests/test_e2e_05_topology.py ....................                       [  8%]
tests/test_e2e_10_mef_eline.py ..........ss.....x.....x................  [ 24%]
tests/test_e2e_11_mef_eline.py ......                                    [ 26%]
tests/test_e2e_12_mef_eline.py .....Xx.                                  [ 29%]
tests/test_e2e_13_mef_eline.py ....Xs.s.....Xs.s.XXxX.xxxx..X........... [ 45%]
.                                                                        [ 46%]
tests/test_e2e_14_mef_eline.py x                                         [ 46%]
tests/test_e2e_15_mef_eline.py .....                                     [ 48%]
tests/test_e2e_20_flow_manager.py .....................                  [ 56%]
tests/test_e2e_21_flow_manager.py ...                                    [ 57%]
tests/test_e2e_22_flow_manager.py ...............                        [ 63%]
tests/test_e2e_23_flow_manager.py ..............                         [ 69%]
tests/test_e2e_30_of_lldp.py ....                                        [ 70%]
tests/test_e2e_31_of_lldp.py ...                                         [ 71%]
tests/test_e2e_32_of_lldp.py ...                                         [ 73%]
tests/test_e2e_40_sdntrace.py ..............                             [ 78%]
tests/test_e2e_41_kytos_auth.py ........                                 [ 81%]
tests/test_e2e_42_sdntrace.py ..                                         [ 82%]
tests/test_e2e_50_maintenance.py ........................                [ 91%]
tests/test_e2e_60_of_multi_table.py .....                                [ 93%]
tests/test_e2e_70_kytos_stats.py ........                                [ 96%]
tests/test_e2e_80_pathfinder.py ss......                                 [100%]

Cool.

Regarding the changelog though, there's a git conflict if you can solve it.

@viniarck viniarck self-requested a review January 31, 2024 16:31
Copy link
Member

@viniarck viniarck left a comment

Choose a reason for hiding this comment

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

Nicely done. This PR will land by tomorrow.

@viniarck viniarck merged commit 6305644 into master Feb 1, 2024
2 checks passed
@viniarck viniarck deleted the database_load branch February 1, 2024 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reduce updates to DB when UNI is disabled
2 participants