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

⚡️(api) cache PointDeCharge id from id_pdc_itinerance database request #298

Merged
merged 1 commit into from
Dec 17, 2024

Conversation

jmaupetit
Copy link
Member

Purpose

Getting a point of charge identifier from its id_pdc_itinerance is now the most frequent database request as it's accessed almost by every dynamic endpoints (create + read / status + session).

As the same point of charge may generate multiple events (and dynamic data) within a limited timeline, caching this database request result may save time and database hits in that period for the same point of charge.

Proposal

  • extract this database request in a cached get_pdc_id utility

@jmaupetit jmaupetit self-assigned this Dec 17, 2024
@jmaupetit jmaupetit added critical improvement needs review API Item related to the API service labels Dec 17, 2024
Copy link

Current benchmark

Type Name Request Count Failure Count Median Response Time Average Response Time Min Response Time Max Response Time Average Content Size Requests/s Failures/s 50% 66% 75% 80% 90% 95% 98% 99% 99.9% 99.99% 100% git timestamp version
GET /auth/whoami 26 0 270.0 322.9901081923047 2.6180790000012166 1023.505474999979 160.0 1.1600365380131483 0.0 270 380 540 660 780 840 1000 1000 1000 1000 1000 48d0776 2024-12-17 15:32:50.631036+00:00 0.16.0
POST /dynamique/session/ 19 0 1000.0 838.2045988421065 11.809193999965828 1407.777923000026 45.0 0.8477190085480701 0.0 1000 1200 1200 1300 1300 1400 1400 1400 1400 1400 1400 48d0776 2024-12-17 15:32:50.631036+00:00 0.16.0
POST /dynamique/session/bulk 23 0 1000.0 856.070145217391 21.40368499999568 1443.7050819999513 411.0 1.0261861682424007 0.0 1000 1100 1200 1200 1300 1400 1400 1400 1400 1400 1400 48d0776 2024-12-17 15:32:50.631036+00:00 0.16.0
GET /dynamique/status/ 23 0 380.0 530.449062652172 29.0155590000154 1559.1532109999662 285.0 1.0261861682424007 0.0 380 760 930 1100 1100 1200 1600 1600 1600 1600 1600 48d0776 2024-12-17 15:32:50.631036+00:00 0.16.0
POST /dynamique/status/ 27 0 660.0 647.8178034444451 13.555655999994087 1414.5737910000094 45.0 1.2046533279367313 0.0 660 840 1100 1100 1200 1200 1400 1400 1400 1400 1400 48d0776 2024-12-17 15:32:50.631036+00:00 0.16.0
GET /dynamique/status/FRALLEGO002006P3 21 0 380.0 622.4630320476194 21.166127000014967 2006.933658999969 283.0 0.9369525883952354 0.0 380 860 1200 1200 1400 1400 2000 2000 2000 2000 2000 48d0776 2024-12-17 15:32:50.631036+00:00 0.16.0
GET /dynamique/status/FRALLEGO002006P3/history 23 0 360.0 568.6354656086988 13.28265699999065 1879.122384000027 29524.652173913044 1.0261861682424007 0.0 360 970 1100 1200 1200 1300 1900 1900 1900 1900 1900 48d0776 2024-12-17 15:32:50.631036+00:00 0.16.0
POST /dynamique/status/bulk 19 0 700.0 600.9832598421249 15.618670000037582 1444.0473740000357 411.0 0.8477190085480701 0.0 700 860 940 1100 1200 1400 1400 1400 1400 1400 1400 48d0776 2024-12-17 15:32:50.631036+00:00 0.16.0
POST /statique/ 22 10 350.0 592.0156193181936 19.05097499997055 1503.9439509999966 58.63636363636363 0.981569378318818 0.4461678992358264 560 930 1100 1200 1300 1300 1500 1500 1500 1500 1500 48d0776 2024-12-17 15:32:50.631036+00:00 0.16.0
GET /statique/?limit=10 24 0 780.0 769.5534469999999 23.01077700002452 1566.6630939999775 13826.333333333334 1.0708029581659833 0.0 840 950 1300 1300 1300 1400 1600 1600 1600 1600 1600 48d0776 2024-12-17 15:32:50.631036+00:00 0.16.0
GET /statique/?limit=100 26 0 690.0 704.6563580384617 141.43118200001936 1513.0242040000326 129006.3846153846 1.1600365380131483 0.0 690 850 1200 1200 1500 1500 1500 1500 1500 1500 1500 48d0776 2024-12-17 15:32:50.631036+00:00 0.16.0
PUT /statique/FR073EP7QU5233 25 0 460.0 609.190423600005 24.026333999984217 1513.763928000003 1371.0 1.115419748089566 0.0 460 860 1200 1200 1300 1300 1500 1500 1500 1500 1500 48d0776 2024-12-17 15:32:50.631036+00:00 0.16.0
GET /statique/FRALLEGO002006P3 29 0 560.0 531.457721103444 12.413536999986263 1511.8992559999924 1202.0 1.2938869077838966 0.0 560 700 860 1100 1100 1300 1500 1500 1500 1500 1500 48d0776 2024-12-17 15:32:50.631036+00:00 0.16.0
POST /statique/bulk 25 0 980.0 949.5708559200056 303.06469300001027 1875.6074210000409 1128.68 1.115419748089566 0.0 980 1100 1200 1300 1500 1600 1900 1900 1900 1900 1900 48d0776 2024-12-17 15:32:50.631036+00:00 0.16.0
Aggregated 332 10 650.0 649.0050347771111 2.6180790000012166 2006.933658999969 13553.298192771084 14.812774254629437 0.4461678992358264 650 930 1100 1200 1300 1400 1500 1600 2000 2000 2000 48d0776 2024-12-17 15:32:50.631036+00:00 0.16.0

Comparison with the latest previous benchmark

A lower (negative) value means the current version performs better than the previous one.

Type Name Request Count Failure Count Median Response Time Average Response Time Min Response Time Max Response Time Average Content Size Requests/s
GET /auth/whoami
POST /dynamique/session/
POST /dynamique/session/bulk
GET /dynamique/status/
POST /dynamique/status/
GET /dynamique/status/FRALLEGO002006P3
GET /dynamique/status/FRALLEGO002006P3/history
POST /dynamique/status/bulk
POST /statique/
GET /statique/?limit=10
GET /statique/?limit=100
PUT /statique/FR073EP7QU5233
GET /statique/FRALLEGO002006P3
POST /statique/bulk
Aggregated

@jmaupetit jmaupetit changed the title ⚡️(api) cache PointDeCharge id from id_pdc_itinerance db request ⚡️(api) cache PointDeCharge id from id_pdc_itinerance database request Dec 17, 2024
@jmaupetit jmaupetit requested a review from ssorin December 17, 2024 15:39
Getting a point of charge identifier from its `id_pdc_itinerance` is now
the most frequent database request as it's accessed almost by every
dynamic endpoints (create + read / status + session).

As the same point of charge may generate multiple events (and dynamic
data) within a limited timeline, caching this database request result
may save time and database hits in that period for the same point of
charge.
Copy link

Current benchmark

Type Name Request Count Failure Count Median Response Time Average Response Time Min Response Time Max Response Time Average Content Size Requests/s Failures/s 50% 66% 75% 80% 90% 95% 98% 99% 99.9% 99.99% 100% git timestamp version
GET /auth/whoami 38 0 370.0 524.3134593947406 3.232307000018864 1699.030284999992 160.0 1.3204726570365777 0.0 390 730 950 1000 1500 1600 1700 1700 1700 1700 1700 c3a01b7 2024-12-17 16:01:08.449871+00:00 0.16.0
POST /dynamique/session/ 29 0 790.0 766.7378132758716 8.233261000043512 1940.405863000024 45.0 1.0077291330015987 0.0 790 1100 1300 1400 1900 1900 1900 1900 1900 1900 1900 c3a01b7 2024-12-17 16:01:08.449871+00:00 0.16.0
POST /dynamique/session/bulk 35 0 750.0 828.9114405714259 13.179733000015403 2029.0137819999927 411.0 1.2162248156915847 0.0 750 1200 1400 1500 1700 2000 2000 2000 2000 2000 2000 c3a01b7 2024-12-17 16:01:08.449871+00:00 0.16.0
GET /dynamique/status/ 26 0 430.0 597.604230346152 14.65261400005602 1785.5361400000334 274.11538461538464 0.9034812916566056 0.0 470 570 1100 1100 1700 1800 1800 1800 1800 1800 1800 c3a01b7 2024-12-17 16:01:08.449871+00:00 0.16.0
POST /dynamique/status/ 34 0 500.0 783.9367941470662 14.66951899999458 2037.531295000008 45.0 1.1814755352432535 0.0 740 1100 1200 1400 1400 2000 2000 2000 2000 2000 2000 c3a01b7 2024-12-17 16:01:08.449871+00:00 0.16.0
GET /dynamique/status/FRALLEGO002006P3 29 0 650.0 817.3436733448237 11.424627999986114 2029.7645549999856 275.62068965517244 1.0077291330015987 0.0 650 1100 1300 1600 1900 1900 2000 2000 2000 2000 2000 c3a01b7 2024-12-17 16:01:08.449871+00:00 0.16.0
GET /dynamique/status/FRALLEGO002006P3/history 38 0 800.0 856.0720501315706 15.817891999972744 2070.874124999989 60956.36842105263 1.3204726570365777 0.0 830 1300 1500 1700 1900 2000 2100 2100 2100 2100 2100 c3a01b7 2024-12-17 16:01:08.449871+00:00 0.16.0
POST /dynamique/status/bulk 30 0 670.0 761.9455013999963 17.279264000023886 2006.1953759999935 411.0 1.0424784134499296 0.0 740 1100 1300 1400 2000 2000 2000 2000 2000 2000 2000 c3a01b7 2024-12-17 16:01:08.449871+00:00 0.16.0
POST /statique/ 29 12 510.0 777.409646172416 12.186204000045109 2336.234883999964 58.793103448275865 1.0077291330015987 0.4169913653799719 510 1100 1300 1500 1900 2000 2300 2300 2300 2300 2300 c3a01b7 2024-12-17 16:01:08.449871+00:00 0.16.0
GET /statique/?limit=10 29 0 970.0 951.8796613793174 23.800121000022045 2204.289759000005 13826.689655172411 1.0077291330015987 0.0 970 1400 1700 1700 2000 2100 2200 2200 2200 2200 2200 c3a01b7 2024-12-17 16:01:08.449871+00:00 0.16.0
GET /statique/?limit=100 29 0 1200.0 1070.6969728275926 144.42183300002398 2007.7733030000215 129006.6551724138 1.0077291330015987 0.0 1200 1400 1500 1700 1900 2000 2000 2000 2000 2000 2000 c3a01b7 2024-12-17 16:01:08.449871+00:00 0.16.0
PUT /statique/FR073EP7QU5233 27 0 760.0 822.2861651111089 46.3090140000304 2045.316237999998 1371.0 0.9382305721049368 0.0 760 1000 1400 1600 1900 1900 2000 2000 2000 2000 2000 c3a01b7 2024-12-17 16:01:08.449871+00:00 0.16.0
GET /statique/FRALLEGO002006P3 32 0 750.0 777.7366052812499 13.852294000002985 1836.860612999999 1202.0 1.1119769743465917 0.0 750 1100 1400 1400 1700 1800 1800 1800 1800 1800 1800 c3a01b7 2024-12-17 16:01:08.449871+00:00 0.16.0
POST /statique/bulk 32 0 1200.0 1208.2423779375056 373.7663140000223 2200.3370959999984 1124.65625 1.1119769743465917 0.0 1200 1500 1600 1700 2000 2100 2200 2200 2200 2200 2200 c3a01b7 2024-12-17 16:01:08.449871+00:00 0.16.0
Aggregated 437 12 740.0 822.4427802700244 3.232307000018864 2336.234883999964 15154.311212814646 15.185435555920645 0.4169913653799719 740 1100 1400 1500 1800 2000 2000 2100 2300 2300 2300 c3a01b7 2024-12-17 16:01:08.449871+00:00 0.16.0

Comparison with the latest previous benchmark

A lower (negative) value means the current version performs better than the previous one.

Type Name Request Count Failure Count Median Response Time Average Response Time Min Response Time Max Response Time Average Content Size Requests/s
GET /auth/whoami
POST /dynamique/session/
POST /dynamique/session/bulk
GET /dynamique/status/
POST /dynamique/status/
GET /dynamique/status/FRALLEGO002006P3
GET /dynamique/status/FRALLEGO002006P3/history
POST /dynamique/status/bulk
POST /statique/
GET /statique/?limit=10
GET /statique/?limit=100
PUT /statique/FR073EP7QU5233
GET /statique/FRALLEGO002006P3
POST /statique/bulk
Aggregated

@jmaupetit jmaupetit merged commit 23e0f9f into main Dec 17, 2024
15 checks passed
@jmaupetit jmaupetit deleted the api-cache-pdc-ids branch December 17, 2024 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Item related to the API service critical improvement needs review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants