To Use MTS or Not

Results 1 to 2 of 2

Thread: To Use MTS or Not

  1. #1
    Join Date
    Dec 1969

    Default To Use MTS or Not

    I am building a web application that will use ASP for UI and SQL Server for database. I plan to write a single VB COM that will do the data access(simple read and write) for the application. My question is whether I should use MTS with my VB COM(I am new to COM and MTS). Can somebody please share to me the advantage of using MTS in my application?<BR><BR>Thanks.

  2. #2
    Christiaan Guest

    Default RE: To Use MTS or Not

    This is going to a length reply, but a lot of people have this question, so perhaps i can be of help here.<BR><BR>MTS, in short, allows you to manage your objects in a better way than without MTS. Also, if you use MTS you can use transactions. A transaction can span over several functions/procedures and is basically a queue for actions to be performed. When you call the MTS function &#039SetComplete&#039 the queue will be &#039executed&#039. If an error occurred somewhere in the line, you can cancel the entire transaction by calling &#039SetAbort&#039. This is a rather crude description of transactions, but it&#039ll give you a picture of what it can do for you. Transactions are not always needed, but they&#039ll help maintaining the integrity of the data to be written to the DB.<BR><BR>Do you need MTS? I think that MTS is the best option available. It provides with ways to improve scalability (in other words: your component can support more users) and you&#039ll use less memory because of the efficient MTS object manager. Normally, when you create a ADO-connection, the component will need some time to create it. To get around this delay, most programmers open the connection once, and use it for several functions, procedures. This is not a good choice because it hurts scalability A LOT (the server can&#039t release the object, even if it isn&#039t using it). <BR><BR>With MTS, you MUST create your objects only when you need them, and destroy them IMMEDIATLY when you&#039re done. Now, most people think that this isn&#039t very efficient because you have to, for example, create 5 connections while you could use 1. If you use MTS, creating 5 connections will not be any less efficient because even if you destroy the object, the MTS will still keep it active (in a different way though - won&#039t use a lot of resources). If you create the 2nd connection, the MTS will simple open the link to the still active object and continue using it. Of course, the MTS still needs some memory to keep the object alive, but it&#039s a lot less. <BR><BR>If you call SetComplete, the MTS will also clean up the memory used for the objects.<BR><BR>But what is the downside? MTS is rather hard to use. it requires a somewhat different way of programming and sometimes you have to do things that aren&#039t as efficient as possible. Also, MTS will create an overhead for your components and that means that performance will decrease (not much, but stil...).<BR><BR>All in all, you have to make the choice. MTS is the choice if you&#039re building components that are going to be used by a lot of people at the same time. <BR><BR>My tip for you: try to find some articles on They&#039ve got some good material there.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts