Archive for the ‘Architecture’ category

Developing a sense of Scalability

February 6th, 2010

Scott Hanselman’s recent post about exporting data from a database to a csv file where he talks about how some code could be improved. He does a very nice job of showing how and were the code could remove the smells that were present in the original design. However there are a few things that I see that if changed could improve both the performance and scalability of the system.

While this is something that depending on the complexity and scalability needs of your site one may consider over kill, it is something that takes minimal effort in design to create a system that is innately more scalable. What happens when the data you are querying starts to push out is 5-10Mb of Data to a CSV file?

Option 1

So rather than generate the list of Foo into a CSV at each request why not pre generate the list at pre configured intervals depending on the volatility of the data and save the resultant CSV to a san that can be served up via IIS. In this scenario there is no need for the ASP.NET worker process to get involved and the IIS process can do what it was meant to do serve content.

Pregenerated file system

Advantages

  • No need to hit the DB to get the data
  • You don’t have to involve the asp.net worker process and let IIS do what its designed to do

Disadvantages

  • Your data may be stale up to a preconfigured amount of time (but since its going to a report of sorts it is more than likely stale)

Option 2

So your business requirement absolutely dictates that it is required to be generated and sent as the user requests it. There is no choice, you have but to send it through the response stream. BUT there is another way. Say when this request for the data to be exported VIA an AJAX call to your server the response from the server is a URL to where the file will be output. Now the server it self can then send a message to the export to csv service and request the file be output to the san. The client can then poll the server waiting for a 200 response code, when it does get one it can then redirect the browser to the given URL.

polling file system

Advantages

  • Gives you more or less up to the minute accurate data
  • Reduces the amount of work the asp.net worker process has to perform

Disadvantages

  • Introduces polling into the design of the client

When designing systems that do not take Scalability into account from the ground up, you generally are missing something. Considering Scalability does not mean that you choose either of these two options all the time. At times it might make sense to think about using the approach suggested in Scott’s article, the key being to always think about know your data and make informed decisions.

Video of Command Query Responsibility Segregation by Udi Dahan

January 24th, 2010

Udi presented his talk on CQRS at the Victoria.Net User Group on the 19th of January in Melbourne, we recorded his presentation.  Hopefully this is of some benefit despite the audio and video not being the greatest. It was a great night that opened many eyes and ears to the best.

 

Command Query Responsibility Segregation – Udi Dahan from Mark Harris on Vimeo.

Lessons Learned from building a Linq To Sql Saga Persister

December 9th, 2009

Simon has released the first version of the Linq To Sql Saga Persister code and the EF 1 Saga Persister in the past couple of days. In fact we started working on the saga persister mid September, so what took doing something like a Saga Persister, a fairly trivial exercise almost 3 months. To be fair Simon initially put some of the work on the persister quite quickly. However once we started to use the code in our test with the Manufacturing sample under load it would begin to creak. Seeing as that was a problem we had to switch to using the NHibernate Saga persister for our client to go into production.

The first thing that went through our minds was that we had written the persister wrong, however a persistent Simon continued to work through the issues. Along the way we discovered a few things.

  1. NHibernate is faster and therefore able to handle the load better.
  2. Proper Saga Design is important.

NHibernate is faster

Most of you already know this but the key thing here is that because its faster it fails less therefore the issues that we saw in the development of the persister was difficult to isolate.

In the Manufacturing Sample that comes with NServiceBus start up all the required services and when the partner is ready run it in simulate mode, it does not fail. doing the same thing when using the L2S persister had the same effect.

Once the number of worker threads on the Order Service Host was increased to 4 could use we started to see a whole bunch of errors. From messages not being completed to violation of primary keys and deadlocks. Using the NHibernate persister required us to increase the workers to 6 or 7 you would start to notice similar errors.This leads me to the next item.

Proper Saga Design is Important

If your not sure about what a Saga is please read the NServiceBus wiki. When considering how you build a system  though that goes into how you would like to handle long running transactions is important. Knowing how many transactions per second. What are the SLA’s? My rule of thumb the more i think about it is that a Saga message that starts the saga should be unique any subsequent messages that are part of that saga should be dealt with a more explicit message handler. So you have a CreateOrderMessage that starts a saga and subsequent messages are handled by UpdateOrderMessages for changes to the order, with CancelOrderMessages and AuthorizeOrderMessages being explicit to the saga.

In my opinion doing so produces both a simpler and more explicit design of your long lived transaction. This however is now going down the path of a different post one that warrants a post of it own.

The Benefits of Reading code became clear the deeper we went through the NServiceBus code base, the more you understand how each piece interacts with the other to provide a great framework. Despite all the hurdles L2S provided it was worth the effort. What must be said for NServiceBus is that it is highly extensible already evidenced by its existing OOB support for 4 IOC frameworks, now 3 ORM’s and in the future with version 2.1 it will support a whole raft of Queued Transports.

Service Broker – Some thoughts post hoc

December 1st, 2009

sql service broker

This post has been sitting in my drafts for a while. After my day today i felt that it was best that i put my thoughts about service broker down.
In a project that i worked on about 2 years ago Service Broker was used as part of the system to perform data validation.  If success was measured by the amount of time that a system has been in production without major issues then i can say that it was successful.

But if a system was to be judged by how much of a pain it is to maintain then l must say that its was not a glowing success. Below is a list of things that i found as good or bad about it.

 

Bad things

  1. Limited information on the internet
  2. Testing is extremely hard (compromises everywhere)
  3. Troubleshooting is a pain
  4. It could stop working and you may never know, (if using a fire and forget mechanism)
  5. Poison messages disable queues (would have been nicer if it moved the message to a error queue)

Good things

  1. Its Asynchronous
  2. Its Asynchronous
  3. Its Asynchronous

Yes this list is one sided but true. The question that is important though is

Would i use Service Broker again?

The answer to that question is strangely YES. Only in very specific circumstances where system is ok with not having some data loss because of queue being disabled

What would I use instead?

of course. It provides an answer to all the negatives of service broker and is still asynchronous.

Every developer must read

October 14th, 2008

Last month I ordered Jimmy Nilsson’s book Applying Domain Drive Design and Patterns along with a couple of others including Patterns of Enterprise Application Architecture, they arrived about a 2 weeks ago.

Finally this week I have started to read ADDP and have been struggling to put it down to do anything else. IMHO this is one of the best Technical books ever written. As a newbie to DDD there is no better starting point than with this book.

Jimmy’s style of writing is very easy to read and understand. The content of course is brilliant, I have just finished reading chapter 2 and feel a few years wiser.

My advice to any developer looking for enlightenment is to read Jimmy’s book. Perfecting the use of Domain Driven Design is not something that comes easy. Even in the smallest application the value of using it is immense. I have a long way to go to become a good developer, and reading this book is going to be a big help in that process.

Technorati Tags:

Microsoft Distributed Application Server aka Dublin

October 2nd, 2008

Mary-Jo shares some of her insight into some of the news around Oslo that may be announced around PDC 08. What interests me is that in my last post I speculated that the Process Server could be some sort of service bus implementation, which seems to be spot on. Yes “Dublin” is the code name for Microsoft’s Distributed Application Server, but hey is that not just a fancy name for or .

I guess when PDC rolls around in a few weeks and more news around what Oslo is and when the bits roll out to developers and architects to see, touch, feel and smell what the CSD and Dev Division guys have come up with is when the real questions need to be asked. All well and good to speculate, I just hope that some parts of the Oslo effort will touch on some of my desires.

 

UPDATE: Mike Taulty has posted links to a whitepaper and a screencast that explain more details about .net 4.0

Technorati Tags: ,,,,

Oslo – More news and predictions

September 23rd, 2008

A few weeks back in that post I suggested the following

I imagine it to be a tool that enables these Information Workers to use some of Oslo’s features much like using Visio, but instead of static elements there are dynamic objects drawn from the repository that perform a specific business purpose, when put together by the domain expert enables them to perform a task that would have required a developer to perform otherwise.

As it turns out I may not be that far from the truth, or some part of it. Ron Jacobs interviewed David Chappell at Tech.Ed just past and in that conversation David divulges a few interesting bit of information.

Two things that caught my attention was the “Lifecycle Manager” and the “Process Server”.  But here are my two predictions about what these two things could be. (Yes I am going out on a limb)

The Lifecycle Manager – A long running workflow or Saga manager.

The Process Server – A Service Bus implementation.

The video  of Ron Jacobs and David Chappell along with David’s loose timeline/ roadmap to Oslo is after the Jump » Read more: Oslo – More news and predictions