Concurrent Use in Asp.net Applications [closed]

0

I'm starting to study programming in asp.net mvc (and trying to follow the DDD) and with that, I had a question about competing use: Asp.net already performs this control for me or I'm the one who should to control this with Threads in all that is method of my system (Controllers, data access, application layer, etc.)?

    
asked by anonymous 12.10.2016 / 18:33

1 answer

2

Your question is not very specific, I'll try to answer it based on what you mentioned most (DDD and DAL).

There is concurrency control at the request level, that is, concurrent requests have their own memory as a sandbox, they do not share most states. An example of an object that is split is session.

As you spoke more with a focus on DDD and data access (I imagine it is the bank), you have to take control. Suppose you are using EntityFramework , you can have concurrent requests on the same data, and that can be a problem.

Example: a reservation system, where user A can be with the seating window open, thinking where to sit. Meanwhile, user B also arrives on that screen and chooses seat 1. Coincidentally, user A also chooses seat 1 and triggers the request along with user B, so that the 2 requests arrive on the server together. At that time, if your code does not handle competition and simply run User.MakeReservation(1) for both users, you will lose data.

There are several ways to deal with this, such as pessimistic and optimistic competition.

At the thread level and everything else, each request will most often have its space, and within that space you have to deal with competitions of that type.

    
13.10.2016 / 04:20