none
Advice Needed: Multiple transactions using same Linq2Sql datacontext simulteneously RRS feed

  • Question

  • Hi,

    Here is the scenario

    I have an service  that uses ONE DataContext instance for each user/call and performs database operations.

    Service gets very high volume of calls and uses TransactionScope to do the Transactions. 

    My question is,

    1) Is it a good practice ?

    2) Is it safe ?

    3) What possible ways things can go wrong this way ?

    4) Could there be a race-condition ?

    5) Could transactions overlap on each other and cause trouble ?

    6) Should I use separate connection per User ? I get 30 unique users in a second on average.

    Your input will be greatly appreciated.

    Thanks


    Fahad

    Friday, July 6, 2012 2:17 PM

Answers

  • New context instance for each db operation is safe for data freshness. If you have huge service consumption, the only part you need to worry for this approach is memory usage and your application's performance.

    I would suggest you to do more research on connection pool, by setting pool properly will help you maintain the application performance.


    Friday, July 6, 2012 2:52 PM