When we create a gunicorn using 2 workers and concurrently hit 20 requests then up to certain time requests are executed on different workers but then the requests start executing on the same worker sequentially, why gunicorn show such behavior?The endpoint of API is async and the workers are synchronous.This is the console result.
@app.post("/apii2")async def processing(requestJson: Dict): print("we here man") print(os.getpid(), " ------------------ ",requestJson["id"]," -------------------- ", datetime.now()) time.sleep(eval(requestJson["id"])) print("peace out")Output:-
we here man
we here man
35707 ------------------ 15 -------------------- 2024-01-22 13:37:35.587476
35706 ------------------ 10 -------------------- 2024-01-22 13:37:35.587476
peace out
we here man
35706 ------------------ 16 -------------------- 2024-01-22 13:37:45.600518
peace out
we here man
35707 ------------------ 19 -------------------- 2024-01-22 13:37:50.603958
peace out
we here man
35706 ------------------ 15 -------------------- 2024-01-22 13:38:01.617591
peace out
peace out
we here man
35706 ------------------ 18 -------------------- 2024-01-22 13:38:16.629669
peace out
we here man
35706 ------------------ 5 -------------------- 2024-01-22 13:38:34.645926
peace out
we here man
35706 ------------------ 17 -------------------- 2024-01-22 13:38:39.649604
peace out
we here man
35706 ------------------ 21 -------------------- 2024-01-22 13:38:56.667146
peace out
we here man
35706 ------------------ 10 -------------------- 2024-01-22 13:39:17.688973
peace out
we here man
35706 ------------------ 19 -------------------- 2024-01-22 13:39:27.700038
peace out
we here man
35706 ------------------ 20 -------------------- 2024-01-22 13:39:46.717574
peace out
we here man
35706 ------------------ 16 -------------------- 2024-01-22 13:40:06.727625
peace out
we here man
35706 ------------------ 21 -------------------- 2024-01-22 13:40:22.741164
peace out
we here man
35706 ------------------ 20 -------------------- 2024-01-22 13:40:43.762873
peace out
we here man
35706 ------------------ 22 -------------------- 2024-01-22 13:41:03.783833
peace out
we here man
35706 ------------------ 5 -------------------- 2024-01-22 13:41:25.805320
peace out
we here man
35706 ------------------ 22 -------------------- 2024-01-22 13:41:30.809944
peace out
we here man
35706 ------------------ 18 -------------------- 2024-01-22 13:41:52.829541
peace out
we here man
35706 ------------------ 17 -------------------- 2024-01-22 13:42:10.845286
peace out
I was expecting that all the requests would be executed parallelly.