This repo just a example case of implementation query method for search data with go and framework fiber. In case i have 100 row data in table orders, and create some load test for comparation latency request per seconds handle it. I use 3 method for implementation is a GET, POST, and last one QUERY method and load test that method with 10.000 requests of 5 seconds. Anyway, it just example in production we know, requests a dynamic, we dont know about how many request will come to endpoint, so make it a preference u to implement QUERY method
hangteabin@chentaury:~/project/test-case-query-post-get$ go run loadtest/post/postMethod.go
===================================
LOAD TEST RESULT (POST)
===================================
Total Requests : 10000
Success : 5460
Failed : 4540
Success Rate : 54.60%
Duration : 7.549225894s
Requests/sec : 1324.64
--- Failure Breakdown ---
http_status_404 : 3672
Post "http://localhost:3000/post": context deadline exceeded (Client.Timeout exceeded while awaiting headers) : 868
===================================
hangteabin@chentaury:~/project/test-case-query-post-get$ hangteabin@chentaury:~/project/test-case-query-post-get$ go run loadtest/get/getMethod.go
===================================
LOAD TEST RESULT (GET)
===================================
Total Requests : 10000
Success : 4388
Failed : 5612
Success Rate : 43.88%
Duration : 5.845022287s
Requests/sec : 1710.86
--- Failure Breakdown ---
http_status_404 : 5598
Get "http://localhost:3000/get?page=1&per_page=50": context deadline exceeded (Client.Timeout exceeded while awaiting headers) : 14
===================================
hangteabin@chentaury:~/project/test-case-query-post-get$ hangteabin@chentaury:~/project/test-case-query-post-get$ go run loadtest/query/queryMethod.go
===================================
LOAD TEST RESULT (QUERY)
===================================
Total Requests : 10000
Success : 5104
Failed : 4896
Success Rate : 51.04%
Duration : 7.083879454s
Requests/sec : 1411.66
--- Failure Breakdown ---
http_status_404 : 4880
Query "http://localhost:3000/query": context deadline exceeded (Client.Timeout exceeded while awaiting headers) : 16
===================================
hangteabin@chentaury:~/project/test-case-query-post-get$ And that's result of method, we can know in POST method have a lot deadline exceeded request (868) it's make query from that method for a get something data is not safe for service. As we know in QUERY method have a low value deadline exceeded it's like GET and count of serve data have a good percentage (51.04%). Like a description about QUERY method use a body like POST and flow like GET we can serve data to a client with safe and idempotent like a GET, in my opinion we can implement QUERY method for a serve many data from backend, like a report (read from a range date), historical user (log activity or order history), etc.
