c# - TransactionScope performance issues -


i have performance issues when using transactionscope class in server side code (wcf).

my code gets request client, creates transactionscope , performs short operations (usually 100 ms).

see bellow attached code simulates server side code. problem when there 100 , more concurrent users, takes more 1 second !!! create new transactionscope (see gettransaction() method).

and when goes 200 concurrent users, transactionaborted thrown .

do have ideas?

class program      {          private static concurrentqueue<double> m_queue = new concurrentqueue<double>();       static void main(string[] args)      {          console.writeline("press key start ...");          console.readkey();           (int = 0; < 100; i++)          {              thread t = new thread(new threadstart(method));              t.isbackground = true;              t.start();          }           thread.sleep(2000);          console.writeline("max {0}, min {1}, avg {2}, total {3}", m_queue.max(), m_queue.min(), m_queue.average(), m_queue.count);          console.readkey();      }        private static void method()       {          using (transactionscope scope = gettransaction())          {              thread.sleep(100);              scope.complete();          }      }       public static transactionscope gettransaction()      {          var start = datetime.now;           transactionoptions options = new transactionoptions();          options.isolationlevel = isolationlevel.readcommitted;          var t = new transactionscope(transactionscopeoption.required, options);           // log creation time          m_queue.enqueue((datetime.now.subtract(start)).totalmilliseconds);           return t;      }   } 

remove "enqueue" line, see if problem persists.

another thing, i'm curious "short operations" being executed within transaction scope. might escalating transaction coordinator ltm msdtc, might explain slowness more concurrent hits.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -