<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Ado.net 2.0 Mars Session Pooling. (aka stuff you don't need to know.)</title><link>http://blogs.msdn.com/angelsb/archive/2005/01/13/352718.aspx</link><description>Mars session pooling, Well, it has been a long time since my last blog and I am finding it very hard to get this one started. You start thinking that you need to have something really good to start up the train again or you might as well not bother. I</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: Ado.net 2.0 Mars Session Pooling. (aka stuff you don't need to know.)</title><link>http://blogs.msdn.com/angelsb/archive/2005/01/13/352718.aspx#352754</link><pubDate>Fri, 14 Jan 2005 06:57:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:352754</guid><dc:creator>Sahil Malik</dc:creator><description>Excellent post Angel - and good to see you back.&lt;br&gt;&lt;br&gt;I have a few questions - &lt;br&gt;&lt;br&gt;a) Would it make sense to keep the session pooling parameters configurable like the connection pooling parameters? Or are they configurable?&lt;br&gt;&lt;br&gt;b) What would then be the best practices for making sure sessions are pooled effectively? Short executing commands? No more than 10? What could one do in the data layer to prevent anymore than 10 concurrent executing commands on the same connection - does it make sense to expose a SqlCommand.CurrentCommandCount property or sump'n like that?&lt;br&gt;&lt;br&gt;c) Is it 10 logical connections per physical connection or 10 logical connections in all?&lt;br&gt;&lt;br&gt;d) I am assuming that if we took a physical connection, and really tired it with too many concurrent SqlCommands, then the physical connection goes back to the connection pool. UserB comes along merrily and tries to fill a dataset - he won't notice any difference because all those commands are done and over with? Or will he see a performance hit too?&lt;br&gt;&lt;br&gt;e) I understand why physical connections are expensive, but why are logical connections such a valuable resource?&lt;br&gt;&lt;br&gt;f) The session pool broker - does that run on another thread? Would sleeping my thread for 0 between too many fast executing commands help?&lt;br&gt;&lt;br&gt;g) Why do you have to blog at 2 AM EST everyday LOL !!&lt;br&gt;&lt;br&gt;- Sahil</description></item><item><title>re: Ado.net 2.0 Mars Session Pooling. (aka stuff you don't need to know.)</title><link>http://blogs.msdn.com/angelsb/archive/2005/01/13/352718.aspx#352758</link><pubDate>Fri, 14 Jan 2005 07:04:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:352758</guid><dc:creator>Sahil Malik</dc:creator><description>Okay this is yet another funky question - This question might make zero sense whatsoever - but I have to ask it LOL.&lt;br&gt;&lt;br&gt;Can I do two DataAdapters.Fill using the same open SqlConnection, two different threads, two different commands, but at the same time - if MARS is enabled? &lt;br&gt;&lt;br&gt;Or Should I? (This is a test hard to simulate, but I know with the introduction of MARS someone will run into it).&lt;br&gt;&lt;br&gt;How would ADO.NET 2.0 handle such a situation?</description></item><item><title>.::Szőkelizer 120::.</title><link>http://blogs.msdn.com/angelsb/archive/2005/01/13/352718.aspx#352851</link><pubDate>Fri, 14 Jan 2005 12:40:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:352851</guid><dc:creator>RIO - Randektív Informatikai Oldal</dc:creator><description>&amp;lt;p&amp;gt;&amp;amp;lt;ul&amp;amp;gt;&amp;amp;lt;li&amp;amp;gt;&amp;amp;lt;a href=&amp;amp;quot;http://weblogs.asp.net/angelsb/archive/2005/01/13/352718.aspx&amp;amp;quot; target=&amp;amp;quot;_blank&amp;amp;quot;&amp;amp;gt;MARS &amp;#233;s session pooling&amp;amp;lt;/a&amp;amp;gt;, avagy mi a k&amp;#252;l&amp;#246;nbs&amp;#233;g a session pool &amp;#233;s a connection pool k&amp;#246;z&amp;#246;tt, avagy mi is</description></item><item><title>re: Ado.net 2.0 Mars Session Pooling. (aka stuff you don't need to know.)</title><link>http://blogs.msdn.com/angelsb/archive/2005/01/13/352718.aspx#352876</link><pubDate>Fri, 14 Jan 2005 10:54:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:352876</guid><dc:creator>Angel</dc:creator><description>Sahil,&lt;br&gt;Great questions, I had some code that I was going to post with this to make things a little clearer, unfortunatelly this post was becoming too long for code.&lt;br&gt;&lt;br&gt;a)make session pooling configurable.&lt;br&gt;I _dislike_ knobs. Of course they make my job a lot harder so I am very biased, but in general the more knobs we add to a feature the more things we are going to get wrong.  This feature is designed specifically to ensure that asp.net applications that use MARS _responsably_ are not slowed down by constant logical connection creation. It does this job well. The 10 logical connection limit should be 5x more connections as a normal application will use, using more than 10 is going to be problematic. Remember that this only applies to SqlCommands that are executing at the same time.&lt;br&gt;&lt;br&gt;b)what are best practices for this feature?&lt;br&gt;IMO most applications don't need MARS, best practice would then be to not use it when you don't need it. For my opinion on when MARS makes sense take a look at the MARS FAQ blog post I mention in this post. It does not make sense to expose this information as a property, you can always get this information from the server with &amp;quot;select * from sys.dm_exec_connections where session_id=@@spid&amp;quot;.&lt;br&gt;&lt;br&gt;c)Is it 10 logical connections per physical connection?&lt;br&gt;Yes, as shown in the sys.dm_exec_connections table the logical connections belong to an individual physical connection. We will cache up to ten logical connections per physical.&lt;br&gt;&lt;br&gt;d)what happens when the physical connection goes back to the connection pool?&lt;br&gt;This is the beauty of this feature, when you close the connection and it goes back to the connection pool it will retain the logical connections. the next time you use this connection it will behave faster than the first time arround.&lt;br&gt;&lt;br&gt;e)why are logical connections such a valuable resource? &lt;br&gt;They are not nearly as expensive as physical connections, but as soon as you use two SqlCommands at the same time we get the cost of creating a new logical connection. As soon as we did our first perf pass on MARS without session pooling we realized that throwing these logical connections away was not an option.&lt;br&gt;&lt;br&gt;f)The session pool broker ?&lt;br&gt;fortunatelly no such thing, one of the benefits of keeping things simple.&lt;br&gt;&lt;br&gt;Can I do two DataAdapters.Fill using the same open SqlConnection, two different threads.&lt;br&gt;Man this is the question I always dread. The easy answer of course is &amp;quot;yes&amp;quot;, this is in fact one of the scenarios that we originally envisioned for this feature. The thing that makes this a hard question is that _under certain circumstances_ it actually makes sense to do so. A physical connection costs about 40k (I am going with sql server 2000 numbers here, may be way off for 2005) logical connections are much cheaper so by using MARS you can save memory resources. If instead you use the tried and true current model, open a connection in each thread, you will almost certainly execute faster but consume more memory.&lt;br&gt; &lt;br&gt;I am a huge fan of the &amp;quot;open a connection in each thread&amp;quot; model and I have real concerns that trying to use MARS in this way is going to create a lot of ugly hard to debug code that runs into threading and transaction issues. I would not use a connection in multiple threads at all. Take a look at my MARS FAQ to see more of my concerns.</description></item><item><title>re: Ado.net 2.0 Mars Session Pooling. (aka stuff you don't need to know.)</title><link>http://blogs.msdn.com/angelsb/archive/2005/01/13/352718.aspx#352929</link><pubDate>Fri, 14 Jan 2005 14:18:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:352929</guid><dc:creator>Sahil Malik</dc:creator><description>Angel,&lt;br&gt;&lt;br&gt;I completely agree with your feelings about MARS. In my eyes, there is nothing that MARS gives you that you cannot acheive with two open connections. &lt;br&gt;&lt;br&gt;Anyway, tell me a reason why should I use MARS. Under what circumstance (other than 40k memory saved - big deal), or specific situation is MARS so kick-ass that I should use it .. over two Sql connections.&lt;br&gt;&lt;br&gt;The situation that you dread, about two concurrent DataAdapters.Fill - is the hard to debug situation that we will see in newsgroups - just wait and see :). &lt;br&gt;&lt;br&gt;BTW, the article you mentioned is awesome. I am coming up with a &amp;quot;Best ways to use MARS&amp;quot; blog post sometime later in the day and will trackback to this post over here. I think such a thing would be ultra valuable :).&lt;br&gt;&lt;br&gt;- SM</description></item><item><title>re: Ado.net 2.0 Mars Session Pooling. (aka stuff you don't need to know.)</title><link>http://blogs.msdn.com/angelsb/archive/2005/01/13/352718.aspx#353110</link><pubDate>Fri, 14 Jan 2005 18:31:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:353110</guid><dc:creator>Angel</dc:creator><description>Sahil,&lt;br&gt;In my mind there are two main scenarios that have been enabled:&lt;br&gt;&lt;br&gt;1)You would need to use MARS in the following scenario:&lt;br&gt;&lt;br&gt;Executing under the same isolation level:&lt;br&gt;Open connection and lock data in the database (with a transaction for example), try to access the locked data (datareader) and update it at the same time. Without true MARS the locks that are held by the first connection would stop the second connection from updating.&lt;br&gt;&lt;br&gt;2)A lot of customers have requested that we enable the following scenario:&lt;br&gt;&lt;br&gt;Update database while procesing SqlDataReader.&lt;br&gt;Create reader and start procesing the results, use a second command to update/insert/delete as you go.&lt;br&gt;&lt;br&gt;It is not necesary to use MARS on the second scenario, but it was one of the biggest feature requests from v1.0. Quite frankly it results in clean easy to manage code and it may be worth it for that reason.&lt;br&gt;&lt;br&gt;Two scenarios that are newly enabled but that I would not recomend would include using SqlCommands in different threads as we discussed and using MARS with Async commands. There is nothing wrong with mixing Async and MARS but in my experience you won't get the performance gains that you would expect.&lt;br&gt;&lt;br&gt;</description></item><item><title>re: Ado.net 2.0 Mars Session Pooling. (aka stuff you don't need to know.)</title><link>http://blogs.msdn.com/angelsb/archive/2005/01/13/352718.aspx#353275</link><pubDate>Fri, 14 Jan 2005 21:45:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:353275</guid><dc:creator>Sahil Malik</dc:creator><description>#1 - Yes in certain isolation levels .&lt;br&gt;#2 - Yes that will result in cleaner code.&lt;br&gt;&lt;br&gt;That helps .. :) .. your answers as usual are very enlightening.&lt;br&gt;&lt;br&gt;ADO.NET 2.0 should ship with two nipple clips that should give the programmer a 110V jolt anytime he tried doing MARS on two threads on the same connection.</description></item><item><title>re: Ado.net 2.0 Mars Session Pooling. (aka stuff you don't need to know.)</title><link>http://blogs.msdn.com/angelsb/archive/2005/01/13/352718.aspx#353336</link><pubDate>Fri, 14 Jan 2005 23:13:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:353336</guid><dc:creator>Bill</dc:creator><description>Excellent post my friend - glad to see you blogging again ;-)&lt;br&gt;</description></item><item><title>re: Ado.net 2.0 Mars Session Pooling. (aka stuff you don't need to know.)</title><link>http://blogs.msdn.com/angelsb/archive/2005/01/13/352718.aspx#353340</link><pubDate>Fri, 14 Jan 2005 23:22:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:353340</guid><dc:creator>Angel</dc:creator><description>Bill,&lt;br&gt;Great to hear from you, I tried sending you an email when I got back from vacation but it bounced right back-at-me, drop me a note some time so I can keep in touch.&lt;br&gt;&lt;br&gt;As I mentioned in the title this is stuff you don't need to know, unfortunatelly in my experience it is always this type of under the covers work that ends up having the most issues. By explaining exactly how we have implemented this I am hoping that whatever issues arrise come as no surprise to the experts.&lt;br&gt;</description></item><item><title>re: Ado.net 2.0 Mars Session Pooling. (aka stuff you don't need to know.)</title><link>http://blogs.msdn.com/angelsb/archive/2005/01/13/352718.aspx#353694</link><pubDate>Sat, 15 Jan 2005 20:43:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:353694</guid><dc:creator>Sahil Malik</dc:creator><description>Hey Angel - unrelated question- &lt;br&gt;&lt;br&gt;Can you point me to some good documentation around the SqlCommand.NotificationAutoEnlist property? It seems hella interesting and somehow connected to Sql Server 2005 Service Broker (I could be completely wrong here) - but some guidance on that would be ultra awesome :).&lt;br&gt;&lt;br&gt;Regards,&lt;br&gt;&lt;br&gt;- Sahil</description></item><item><title>re: Ado.net 2.0 Mars Session Pooling. (aka stuff you don't need to know.)</title><link>http://blogs.msdn.com/angelsb/archive/2005/01/13/352718.aspx#353869</link><pubDate>Sun, 16 Jan 2005 08:13:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:353869</guid><dc:creator>Angel</dc:creator><description>Sahil,&lt;br&gt;&lt;br&gt;This is the guy you want to bug for more info on Notifications :&lt;br&gt;&lt;a target="_new" href="http://blogs.msdn.com/sushilc/"&gt;http://blogs.msdn.com/sushilc/&lt;/a&gt; &lt;br&gt;</description></item><item><title>re: Ado.net 2.0 Mars Session Pooling. (aka stuff you don't need to know.)</title><link>http://blogs.msdn.com/angelsb/archive/2005/01/13/352718.aspx#353872</link><pubDate>Sun, 16 Jan 2005 09:17:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:353872</guid><dc:creator>Sahil Malik</dc:creator><description>Sorry yet another question - Is SqlDataReader.Close in any way connected with the number of session pools you can have active at a given time??</description></item><item><title>re: Ado.net 2.0 Mars Session Pooling. (aka stuff you don't need to know.)</title><link>http://blogs.msdn.com/angelsb/archive/2005/01/13/352718.aspx#354045</link><pubDate>Sun, 16 Jan 2005 19:39:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:354045</guid><dc:creator>Angel</dc:creator><description>Sahil,&lt;br&gt;Sorry not sure I understand the question. there is one pool per physical connection so the number of session pools does not change. &lt;br&gt;&lt;br&gt;If you are asking whether the number of sessions in a pool change on SqlDataReader.Close then ... it is possible. If you have more than ten cached logical connections and you are using them all, opening a SqlDataReader will create the eleventh session. When you close the datareader the logical connection will be freed and since we already have 10 cached sessions it will be discarded.</description></item><item><title>re: Ado.net 2.0 Mars Session Pooling. (aka stuff you don't need to know.)</title><link>http://blogs.msdn.com/angelsb/archive/2005/01/13/352718.aspx#354541</link><pubDate>Mon, 17 Jan 2005 18:59:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:354541</guid><dc:creator>Sahil Malik</dc:creator><description>Yeah Angel you understood my question without me typing it right. &lt;br&gt;&lt;br&gt;I was trying to establish a simili between&lt;br&gt;&lt;br&gt;Connection.Close &amp;lt;---&amp;gt; Physical Connections&lt;br&gt;SqlDataReader.Close &amp;lt;----&amp;gt; # of sessions in a pool.&lt;br&gt;&lt;br&gt;Thanks :)</description></item><item><title>re: Ado.net 2.0 Mars Session Pooling. (aka stuff you don't need to know.)</title><link>http://blogs.msdn.com/angelsb/archive/2005/01/13/352718.aspx#354548</link><pubDate>Mon, 17 Jan 2005 19:02:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:354548</guid><dc:creator>Angel</dc:creator><description>Ah, I see.&lt;br&gt;&lt;br&gt;Yes, the SqlDataReader.Close does free up a logical connection. If we were not caching them you would be able to see it disapear with the server query. Since we are caching up to 10 logical connections you will not see this until you go over our cache.</description></item><item><title>SQL Server High Number of User Connections found on PERFMON, how to resolve it?</title><link>http://blogs.msdn.com/angelsb/archive/2005/01/13/352718.aspx#8571228</link><pubDate>Tue, 03 Jun 2008 11:39:42 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8571228</guid><dc:creator>SQL Server Storage Engine &amp; Tools (SSQA.net)</dc:creator><description>&lt;p&gt;I was working with one of the user project to monitor the Performance Audit of their SQL Server estate.&lt;/p&gt;
</description></item><item><title> Angel Saenz Badillos Ado net 2 0 Mars Session Pooling aka stuff you | pool toys</title><link>http://blogs.msdn.com/angelsb/archive/2005/01/13/352718.aspx#9774904</link><pubDate>Thu, 18 Jun 2009 12:06:43 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9774904</guid><dc:creator> Angel Saenz Badillos Ado net 2 0 Mars Session Pooling aka stuff you | pool toys</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://pooltoysite.info/story.php?id=2498"&gt;http://pooltoysite.info/story.php?id=2498&lt;/a&gt;&lt;/p&gt;
</description></item></channel></rss>