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

Forbid /statique/ POST usage for an existing PDC #254

Merged
merged 1 commit into from
Dec 12, 2024

Conversation

jmaupetit
Copy link
Member

@jmaupetit jmaupetit commented Dec 4, 2024

Purpose

If a user submits the same payload twice using the /statique/ (POST) endpoint, the API returns a 201 CREATED. And if the payload is slightly modified (with the same id_pdc_itinerance), we cannot guaranty what would be created or updated. This use-case should be forbidden.

Proposal

  • check that the PDC does not exist and return a 409 if it does

@jmaupetit jmaupetit self-assigned this Dec 4, 2024
@jmaupetit jmaupetit added improvement WIP API Item related to the API service labels Dec 4, 2024
@MTES-MCT MTES-MCT deleted a comment from github-actions bot Dec 4, 2024
@jmaupetit jmaupetit force-pushed the api-static-post-twice branch from 7772e5b to b276d8a Compare December 10, 2024 20:15
@jmaupetit jmaupetit marked this pull request as ready for review December 10, 2024 20:16
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 24 0 730.0 652.5307373749978 5.484555999998975 1582.8728399999932 160.0 0.82526346345668 0.0 740 840 880 890 1100 1300 1600 1600 1600 1600 1600 38b16df 2024-12-10 20:18:14.532365+00:00 0.15.0
POST /dynamique/session/ 28 0 980.0 948.346516249998 19.80603100003009 2245.972763999987 45.0 0.9628073740327934 0.0 1000 1400 1500 1500 1900 1900 2200 2200 2200 2200 2200 38b16df 2024-12-10 20:18:14.532365+00:00 0.15.0
POST /dynamique/session/bulk 24 0 860.0 964.4031999166624 90.93110300000262 2065.4483889999824 411.0 0.82526346345668 0.0 1000 1200 1500 1600 1800 1800 2100 2100 2100 2100 2100 38b16df 2024-12-10 20:18:14.532365+00:00 0.15.0
GET /dynamique/status/ 32 0 940.0 976.9608291250032 79.35549000001174 1874.465853000004 285.0 1.1003512846089067 0.0 1000 1200 1400 1500 1600 1900 1900 1900 1900 1900 1900 38b16df 2024-12-10 20:18:14.532365+00:00 0.15.0
POST /dynamique/status/ 28 0 850.0 982.8781566785646 48.014143000045806 2272.339244999955 45.0 0.9628073740327934 0.0 850 1400 1500 1600 1900 2000 2300 2300 2300 2300 2300 38b16df 2024-12-10 20:18:14.532365+00:00 0.15.0
GET /dynamique/status/FRALLEGO002006P3 31 0 980.0 999.9175961290324 49.47732699997687 2465.344879999975 283.0 1.0659653069648782 0.0 980 1300 1400 1400 1800 2000 2500 2500 2500 2500 2500 38b16df 2024-12-10 20:18:14.532365+00:00 0.15.0
GET /dynamique/status/FRALLEGO002006P3/history 27 0 950.0 1031.7380965185223 8.489512999972249 2272.5405819999764 58162.92592592593 0.928421396388765 0.0 950 1300 1900 1900 2000 2100 2300 2300 2300 2300 2300 38b16df 2024-12-10 20:18:14.532365+00:00 0.15.0
POST /dynamique/status/bulk 42 0 940.0 1070.711868523808 47.20696200001839 2467.258934999961 411.0 1.44421106104919 0.0 1100 1500 1700 1900 2100 2200 2500 2500 2500 2500 2500 38b16df 2024-12-10 20:18:14.532365+00:00 0.15.0
POST /statique/ 29 12 620.0 671.6662338620737 40.4750120000017 2272.9230599999823 57.6551724137931 0.9971933516768215 0.41263173172834 620 840 890 1200 1500 2100 2300 2300 2300 2300 2300 38b16df 2024-12-10 20:18:14.532365+00:00 0.15.0
GET /statique/?limit=10 20 0 760.0 855.921314699998 40.9169359999737 1913.776291000033 13826.5 0.6877195528805666 0.0 810 1000 1500 1600 1900 1900 1900 1900 1900 1900 1900 38b16df 2024-12-10 20:18:14.532365+00:00 0.15.0
GET /statique/?limit=100 21 0 810.0 893.0328461904761 157.96338000001242 2174.974317000021 129006.47619047618 0.722105530524595 0.0 810 1100 1100 1300 1600 1900 2200 2200 2200 2200 2200 38b16df 2024-12-10 20:18:14.532365+00:00 0.15.0
PUT /statique/FR073EP7QU5233 30 0 930.0 949.6292344666642 39.58043299996916 1953.964054999972 1371.0 1.03157932932085 0.0 960 1100 1200 1400 1900 1900 2000 2000 2000 2000 2000 38b16df 2024-12-10 20:18:14.532365+00:00 0.15.0
GET /statique/FRALLEGO002006P3 23 0 830.0 924.2529702173892 139.57558300000983 1899.8149259999764 1202.0 0.7908774858126517 0.0 830 1200 1400 1500 1500 1600 1900 1900 1900 1900 1900 38b16df 2024-12-10 20:18:14.532365+00:00 0.15.0
POST /statique/bulk 32 0 1200.0 1309.7138199375047 378.4147079999798 2331.772544000046 1124.78125 1.1003512846089067 0.0 1400 1800 1900 1900 2000 2100 2300 2300 2300 2300 2300 38b16df 2024-12-10 20:18:14.532365+00:00 0.15.0
Aggregated 391 12 880.0 959.0171326496168 5.484555999998975 2467.258934999961 12055.971867007673 13.444917258815078 0.41263173172834 880 1200 1400 1500 1900 2000 2200 2300 2500 2500 2500 38b16df 2024-12-10 20:18:14.532365+00:00 0.15.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

If a user submits the same payload twice using the /statique/ (POST)
endpoint, the API returns a 201 CREATED. And if the payload is slightly
modified (with the same id_pdc_itinerance), we cannot guaranty what
would be created or updated. We now return a 409 CONFLICT response if
the PDC already exist.
@jmaupetit jmaupetit force-pushed the api-static-post-twice branch from b276d8a to 0f6374d Compare December 12, 2024 11:20
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 37 0 500.0 606.9190343783745 19.02296599996589 1907.6619370000003 160.0 1.3136935075299874 0.0 500 740 950 1100 1200 1800 1900 1900 1900 1900 1900 db992c3 2024-12-12 11:27:25.538291+00:00 0.15.0
POST /dynamique/session/ 29 0 710.0 768.5009698965497 25.11959899999283 1594.014884000046 45.0 1.0296516680640442 0.0 710 1000 1100 1300 1500 1600 1600 1600 1600 1600 1600 db992c3 2024-12-12 11:27:25.538291+00:00 0.15.0
POST /dynamique/session/bulk 40 0 970.0 949.5810722249956 101.04085499995108 2602.956630999984 411.0 1.420209197329716 0.0 970 1300 1300 1500 2100 2200 2600 2600 2600 2600 2600 db992c3 2024-12-12 11:27:25.538291+00:00 0.15.0
GET /dynamique/status/ 27 0 520.0 625.0759721851928 24.0842669999779 1959.7873989999923 253.55555555555557 0.9586412081975584 0.0 520 720 880 990 1700 1900 2000 2000 2000 2000 2000 db992c3 2024-12-12 11:27:25.538291+00:00 0.15.0
POST /dynamique/status/ 32 0 700.0 928.806667218753 20.16667499998448 2216.370540000014 45.0 1.1361673578637728 0.0 710 1200 1300 1400 2100 2200 2200 2200 2200 2200 2200 db992c3 2024-12-12 11:27:25.538291+00:00 0.15.0
GET /dynamique/status/FRALLEGO002006P3 22 0 780.0 938.7854409090928 37.47765099996059 2208.209543000009 273.27272727272725 0.7811150585313438 0.0 800 1200 1500 1600 1700 2200 2200 2200 2200 2200 2200 db992c3 2024-12-12 11:27:25.538291+00:00 0.15.0
GET /dynamique/status/FRALLEGO002006P3/history 26 0 270.0 625.9134170384646 29.303621999986262 1888.703396999972 44370.53846153846 0.9231359782643154 0.0 460 960 1200 1300 1500 1900 1900 1900 1900 1900 1900 db992c3 2024-12-12 11:27:25.538291+00:00 0.15.0
POST /dynamique/status/bulk 32 0 780.0 946.5537548749978 40.95827899999449 2215.12033099998 411.0 1.1361673578637728 0.0 930 1300 1600 1600 2000 2200 2200 2200 2200 2200 2200 db992c3 2024-12-12 11:27:25.538291+00:00 0.15.0
POST /statique/ 37 17 700.0 798.2203403783808 42.75464200003398 2211.2049410000054 57.108108108108105 1.3136935075299874 0.6035889088651293 700 970 1100 1300 1600 2000 2200 2200 2200 2200 2200 db992c3 2024-12-12 11:27:25.538291+00:00 0.15.0
GET /statique/?limit=10 25 0 430.0 791.4734958399889 46.05115800001158 2736.9791619999546 13826.48 0.8876307483310725 0.0 430 980 1500 1600 1800 1900 2700 2700 2700 2700 2700 db992c3 2024-12-12 11:27:25.538291+00:00 0.15.0
GET /statique/?limit=100 27 0 960.0 1013.5385539999958 275.0329070000248 2215.930175999972 129006.48148148147 0.9586412081975584 0.0 960 1000 1600 1600 2200 2200 2200 2200 2200 2200 2200 db992c3 2024-12-12 11:27:25.538291+00:00 0.15.0
PUT /statique/FR073EP7QU5233 27 0 620.0 816.8381866296302 37.76954500000329 2116.797630000008 1371.0 0.9586412081975584 0.0 620 1200 1300 1300 1900 1900 2100 2100 2100 2100 2100 db992c3 2024-12-12 11:27:25.538291+00:00 0.15.0
GET /statique/FRALLEGO002006P3 20 0 780.0 900.740098 25.806541000008565 2115.886278000005 1202.0 0.710104598664858 0.0 790 1200 1600 1600 1700 2100 2100 2100 2100 2100 2100 db992c3 2024-12-12 11:27:25.538291+00:00 0.15.0
POST /statique/bulk 29 0 1200.0 1201.9058728965572 369.6422840000082 2604.0570299999786 1116.3103448275865 1.0296516680640442 0.0 1200 1300 1300 1600 2600 2600 2600 2600 2600 2600 2600 db992c3 2024-12-12 11:27:25.538291+00:00 0.15.0
Aggregated 410 17 710.0 849.1527386536576 19.02296599996589 2736.9791619999546 12510.070731707316 14.55714427262959 0.6035889088651293 710 1000 1300 1300 1800 2100 2200 2600 2700 2700 2700 db992c3 2024-12-12 11:27:25.538291+00:00 0.15.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 5c2434a into main Dec 12, 2024
15 checks passed
@jmaupetit jmaupetit deleted the api-static-post-twice branch December 12, 2024 11:27
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 improvement needs review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants