Regular weekend cappuccino J trying to get thoughts straight for that blog entry, okay what I am talking about. I am talking about BTS 2004 Orchs performance and optimization.
I happened to be in one of these projects where we are delivering an integrated “fully configurable” workflow, you know the drill external data store contains all the configuration data this configuration data affects your orchs in a couple of areas
- Message process – should your workflow process a just received message or kick it back returning some business validation rule violation error – yeah those errors that you keep in Strings.cs or external resources files
- Decisions shapes – should your orch do X or Y
Anyway during the implementation I found out about a couple of interesting things that would
- Make your life easier during the development
- Let you answer questions from other techy’s/whoever telling you hey that is slow I can write C# code that would do better job and more importantly faster.
Development:
As you have noticed developing orchs using VS.NET 2003 is nasty especially – That one is much, much better in BTS 2006 code named PathFinder as I have learned - if you are implementing a lot of ports and messages in/out. The reason behind that is GDI L. Somewhere in the designer it consumes a lot of memory I found out that:
- Develop using Windows XP or 2003 it – the designer - is more optimized on them (don’t ask me why I am trying to find out why still)
- If you have to do it on win 2000 then get that SP1 it really helps
- Don’t connect to local SQL, Deployment and enlisting generates a lot of traffic on local SQL so why not using one of these big/ fat development servers instead of connecting locally
- Always, always close port surface like:

Reason behind that is it really puts GDI @ ease to eliminate these lines connecting your shapes and ports
- If you are using Virtual PC to do the good stuff, then put it – VMD files - on a different HDD if you are running on a tower pc or put it on USB 2 external HDD if you are running on a laptop – yes these works like a charm
Runtime:
Okay scaling up or out your servers is pretty straight forward, adding more servers and how to add them is published everywhere on MSDN and Microsoft web site. But what I am trying to introduce is ability to get these orchs to act faster and do more.
Let me tell you this the problem that might make your orchs slower isn’t executing code within the orchs it is the state maintenance, by that I mean the fact that BTS saves the orchs during execution so if things went wrong it can compensate, execute from last successful step or whatever you configure it.
Most of the code generated out of orchs is maps call or send/receive calls the heavy calls – other than state maintenance is during sending or receiving (hence pipeline/adapters) can really damage your performance expectation but I am saving that talk for later blog entry.
Before I go on I want to introduce to concepts related to orchs processing within BTS
- Serialization: is done when BTS put a mark on your orch instance, think of it as the last successful action made during you’re your processing, this happens a lot in Send/Receive loops etc..
o How it happens: BTS orch code genereated is just a .NET class that implements ISerializable interface or other seriliazation mechanism, during the execution BTS decides it needs to mark it, it serializes everything to the MSGBOX DB. And it doesn’t take anything out of BTS Host’s memory. Pretty smart stuff eh? J loved that one btw
- Dehydration: is done when BTS decides ok this particular instance is not needed in the memory any more (happens in listen, delay, receive shapes – other than activation). Later on when BTS decides to awaken – hydrates – this instance based on message received, delay is over – those one are message also called timer messages- , more on that later on other blogs.
o Ho it happens: it happens using serialization as well but this time BTS takes everything out of the host’s memory.
As you have noticed both operations entails heavy calls to SQL stored procs, unfortunately you can not control dehydration process as it is totally controlled by BTS – which is good to tell you the truth – however the serialization process is controllable using few tricks.
Btw I found this
post to control the dehydration but it is don’t do it at home style
Back to our talk, BTS never serializes scoped operations reason is message processing so scope shapes can be your best friend if you used them well:
Consider the following picture: it is send receive shapes in a scope (BTS will not go to DB in scopes, I have tried atomics and none transactional none synchronized scopes and it works like a charm). This way you minimize calls to SQL hence faster processing.

NOTE: doing that will not let BTS mark the execution so if it is failed somewhere in the middle of the scope it will start the execution before the scope. Hence do that carefully on top of my mind I can tell you
- do that when there is no harm repeating the calls (like Update statements)
- do that in loops if there is no harm repeating your loops starting the counter @ 0.
- Do that if your adapters are transactional.
- Don’t do that when your sending messages to external entities (you never trust how they process repeated messages)
- Don’t do that during calls to web services (unless they implement some transactional mechanism).
Other tips related to performance is parallel execution
- No I am not saying use it, instead don’t use it in message processing. Use them if you are doing some execution that has nothing to do with sending or receiving message. Reason is using that will most probably require some synchronization shapes which hurts your performance. (in addition imagine the number of calls to SQL if you have a couple of branches that send/receive messages)
If you want to test how many times BTS serializes your orch instances create a serializable class have it as amember variable in your orch and let it save counter for each time your serialization ctor called, then try with different shapes (loops receive delays and so on) promise, astonishment!
I will keep this post short will stop here, later I will talk about messages/schemas I want to tell you about optimizing your schemas for performance (that will entails talking about pipelines)
Feel free to communicate with me on
khnidk@gmail.comEnjoy BPI,
Kal