We have one application which is hosted on 4 different server if support the one web server is down that time what will going to be happen for the user who is going to do transaction on that particular web server.
Can any one explain me the scenario ?
If your application is hosted on 4 different web servers and you are using network load balancing, the load balancing service can detect that one web server is down and it will not forward any request to that server.
In your case, I think you want to know that what will happen if one server is processing some request and it fails while the request is still under processing. The way to handle such cases will depend upon what you are actually trying to do. For example, suppose you are reducing the number of available items and storing the order details, then I will do these two processes in one stored procedure and use the in-built TRANSACTION functionality of database system.
If the in-built transaction functionality does not work in your case, you can have some custom mechanism. One approach could be:
-
Before starting your transaction (a set of more than one operations), assign some transction id for the process and save it in a database.
-
During all the operations of the transaction, perform the actions in a way that you can undo it if required at some later stage. For example, while updating database records, save the old record in a separate table and associate it with the transaction id by having some column for the transaction id.
-
If all the actions of the transaction are complete i.e. server does not fail during the transaction, then update the transaction entry made in point 1 and then display a message to the user.
-
Now suppose that server fails while transaction is processing i.e. step 3 is not complete. To handle this case, write some code to check the failed transactions and undo the operations. You can execute this cleanup code once a day or when the same user login again etc.
I hope this will help. For a better response, share more details about your requirements and codeproject team will surely help you.