Search code examples
c#asp.netasynchronousasync-awaitmultiserver

Using Async and await to update Database after sending response to Client


I am working on ASP.NET Web Application with C#. Kindly go through the Flowchart of the process.

Now, what I want is that a client sends a request to Server1 and Server1 requests Server2. I want the latter request to be asynchronous. I want Server1 to respond immediately to client before even getting response from Server2.

UPDATE: I have been working on async and await, unable to understand (with a simplest example) the work around.

All I understood is that async tells that the function is asynchronous and contains await statement which is asynchonously executed.

I don't find any reason for why people are downvoting my question. If you do, kindly let me know.


Solution

  • this is a classic example where you should use queues. when you receive request from client you put a task (request to server 2, update db, whatever) into queue and immediately respond to client. additionaly, you have queue consumer (windows service or something) that reads tasks from queue and execute them.