What is the Lighweight Transaction Manager and why do you need to know about it

A "hidden" feature available in System.Transactions is the Lightweight Transaction Manager (LTM). It provides support for light weight transactions that live in the current appdomain. The LTM acts as a façade layer for all the transactions started in System.Transactions and based on a set of rules, it will "fallback" to an MSDTC distributed transaction when it is necessary. I call it "fallback" because there is some performance penalty that you need to pay when this happens: the transaction will span beyond the appdomain and there will be cross-process messages that will be sent, since MSDTC resides in a different process. (Note that from the TM functionality point of view, you can also call this a "promotion", since the MSDTC is a more general purpose and more complete TM). The fallback/promotion happens behind the scenes without any action required from the application developer.

As long as the LTM deals with volatile resources (that enlist using Transaction.EnlistVolatile) and with at most one durable resource that supports single phase notifications (this resource enlists with Transaction.EnlistDurable and implements ISinglePhaseNotification) then the transaction remains in the ownership of LTM. The LTM restricts itself only to those resources that live in the same appdomain and for which "logging" (writing the transaction outcome to the disk) is not required.

The fallback will take place and the LTM will transfer the ownership of the transaction to MSDTC if any of the following is true:
- at least one durable resource that doesn't support single phase notifications is enlisted in the transaction
- at least two durable resources that support single phase notifications are enlisted in the transaction
- a request to "marshal" the transaction to a different appdomain or different process is done.

In between the LTM transaction and MSDTC transaction there is one intermediary type of transaction that we sometimes call it "database transaction" that is made available through the Promotable Single Phase Enlistment. PSPE is another important mechanism in System.Transactions for performance optimization. It allows a remote durable resource, located in a different appdomain/process/machine, to participate in the LTM transaction without causing it to "fallback" to an MSDTC transaction.

Since the LTM is a "hidden" feature, the only reason for which you need to know about its existence is when you care a lot about performance. You will want to delay or avoid the fallback to MSDTC as much as possible to gain performance and for that you need to know how and when the fallback is triggered.