The above is the very high-level sequence diagram for two APIs trying to communicate with each other. The frontend does only communicate with AppOne. AppOne calls AppTwo to store some data in AppTwo's DB but before saving the data, AppTwo calls AppOne to retrieve some further information. Once AppTwo receive further information from AppOne, if everything goes as intended, AppTwo will return OK response to AppOne, finally that response will be shown to user.
This works just OK on my local machine, however after deploying to Azure. The call R1 just hangs. So I added logs to monitor whats happening. I found call (a) was initiated and after line executions, call (c) is also initiated from AppTwo to AppOne. AppOne also did some thing to prepare response for the call (c) and I can see the validated response for call (c) is being printed however the response (e) does not reach AppTwo, rather I am getting HTTP 504 after some waiting time. Both these apps use MySQL as backend (different databases on a single server). Additionally, in the waiting time the AppOne does not facilitate any other requests.
Can anyone explain why does this happen?
PS: I found a workaround to solve the problem. I can simply get rid of R2 (call (c) )by providing all the necessary information in the original call for the AppTwo to do all the necessary calculation and just return the OK response for R1. But I would like to know why it didn't make it to work when I had the R2 implementation. Is this a limitation on Django?