nServiceBus 2.0

Posted August 28, 2009 by andrewwhitten
Categories: Enterprise Service Bus, nServiceBus

I’ve had a slight interest in Udi Dahan’s nServiceBus for about a year now, but it was his recent interview with Scott Hanselman that encouraged me to really dive in this time.

nServiceBus is based on the reliable Microsoft MSMQ service, and thereby achieves reliability and scalability through message queues.

I hear more about potential Enterprise Service Bus implementations at various customer sites, and always they are seen as the silver bullet to integration issues. “The ESB will handle everything” is a common adage. The thought of an electronic backbone in your organization managing all services seamlessly whilst you scale business with no performance hit is admittedly very seductive, even if in fact there is a great deal more to it.

Nevertheless, providing good scalable architecture doesn’t always require a massive investment in vendor ESB solutions, and nServiceBus is something that could even be used solely on a small scale application to provide very real performance and reliability benefits.

It seems that version 2.0 is getting closer to being ready, and therefore I am using the latest beta as my learning platform.

The nServiceBus guys are pretty up front about the lack of documentation around this. Therefore I take it upon myself to document my own first steps.

Here are a couple few pages to get started:

http://www.nservicebus.com/ArchitecturalPrinciples.aspx

http://sourceforge.net/apps/mediawiki/nservicebus/index.php?title=Main_Page

http://justinram.wordpress.com/2009/08/03/how-the-new-host-feature-works-in-nservicebus/

http://andreasohlund.blogspot.com/search/label/NServiceBus

Quickly speed up Silverlight 3 graphics with the GPU enhancements

Posted July 12, 2009 by andrewwhitten
Categories: .NET, Bing Maps, silverlight

My last two posts have me drawing over 2,000 graphics objects onto the Virtual Earth Silverlight control. (Each pushpin represents an airport)

map

One side effect of managing all these objects on screen was high CPU usage:

cpu1

So this application is pushing my Quad Core machine pretty hard. ( On my dual core laptop, the utilization is about 85% )

Therefore a really easy way to fix this is to use the GPU enhancements in Silverlight 3. By explicitally letting my powerful Garphics card take care of this painting, I can significantly reduce my load.

First I add this property to my Silverlight control:

EnableGPUAcceleration=”true”

For example:


<body>

    <form id="form1" runat="server" style="height:100%;">

        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<div  style="height:100%;">

            <asp:Silverlight ID="Silverlight1"  EnableGPUAcceleration="true"  EnableFrameRateCounter="true" runat="server" 

            Source="~/ClientBin/FlightTracks.xap" 

            MinimumVersion="3.0.40307.0" 

            Width="100%" Height="100%" /></div>
</form>

</body>

Then simply add a new BitMApCache object to each Image:


Image image = new Image();
image.CacheMode = new BitmapCache();
image.Source = bmp;

That results in the following low CPU utilization:
cpu2

Adding airport locations to VirtualEarth, Part 2

Posted June 11, 2009 by andrewwhitten
Categories: .NET, Bing Maps, Virtual earth, silverlight

I went to Remix today and found out that the well regarded VirtualEarth brand is now known as ‘Bing Maps‘. I prefer Virtual Earth, but Microsoft were right to bring all their online services together as Bing, if only for the fact it makes it easier to explain.

Yesterday I added 6,000 pushpins to a layer on top of my map. This seemed to be way too much for Silverlight, and performance suffered.

I didn’t actually require every single airport code in the world, and I found this list of 1900 codes from this website. There was no location data, but I was able to filter my origional list of 6,000 against it with good success. The smaller list was clearer and performance much improved.

I also added some extra data as a tooltip with each pushpin, such as the Airport name, code and associated city.

mapsv2

Creating a tooltip is really easy. First I defined a really simple control to display these vales:


<UserControl 

xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"

x:Class="FlightTracks.Controls.AirportTooltip"

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

Width="125" Height="50">

<Grid x:Name="LayoutRoot" Background="White">

<StackPanel>

<TextBlock Text="{Binding Name}"></TextBlock>

<TextBlock Text="{Binding Code}"></TextBlock>

<TextBlock Text="{Binding City}"></TextBlock>

</StackPanel>

</Grid>

</UserControl>

I then bound it to each ‘Airport’ object I had, and then made it part of the Tooltips content. Finally I set the tooltip to the pushpin image:


private Image CreateImage(BitmapImage bmp, Airport airport)

{

           // Picture of pushpin

            Image image = new Image();

            image.Source = bmp;

            image.Opacity = 0.8;

            image.Stretch = Stretch.None;

            // Content of Tooltip

            Controls.AirportTooltip at = new Controls.AirportTooltip();

            at.DataContext = airport;

            // Tooltip

            ToolTip toolTip = new ToolTip();

            toolTip.Content = at;

            // Add tooltip to Image

            ToolTipService.SetToolTip(image, toolTip);

            return image;

}

It is a pity I only get an hour or so to play with this each night! When I finished I’ll release the code on Codeplex and write a large article about all the steps ^-^

Adding airport locations to VirtualEarth, Part 1

Posted June 10, 2009 by andrewwhitten
Categories: .NET, Virtual earth, silverlight

I am playing with the Virtual Earth Silverlight control, and I wondered how hard it would be to make a quick application that could record my flights around the world? 

It turns out the major task is getting a decent list of airport codes with locations! These guys from Holland have a really comprehensive list of airports in a CSV file that I converted to XML and included in my Silverlight project.

(I considered using a WCF service to provide my airports from a DB, but how many new airports are there exactly in these economic times? Instead I embedded the 6K file in the Silverlight app)

I used LinQ to create a pin in a seperate layer on top of the map and here is the result:

Way too many airports in this world

Way too many airports in this world

Having 6000+ pins in your map is not great for responsiveness, and anyway you can’t find your desired airport anyhow ^-^

What is the answer? I think some smarter rendering of layers.. that is the challenge for the next post

Sybase to SQL Server Migration Powerpoint Presentation Available

Posted April 24, 2009 by andrewwhitten
Categories: Uncategorized

Greg Low has published all the presentations from the SQL Down Under Code Camp in 2008, including a short one by myself :)

http://www.sqldownunder.com/Sessions2008/tabid/299/Default.aspx

The main part was the demo of a simple migration which unfortunately is too large to include.

Displaying HTML text in Silverlight

Posted April 24, 2009 by andrewwhitten
Categories: .NET, silverlight

I’m displaying text in my Silverlight 3 application that is using HTML markup, for example: 

うんどうかい で <b> いち </b> い に なった よ

the <b> tag makes the letter bold, but there is no standard text control in the Silverlight toolbox to process this as rich text such as:

うんどうかい で いち い に なった よ 

Luckially David Anson’s post provides a simple Silverlight control that I can include in my project and display the rich text as intended.


<MyLibrary:HtmlTextBlock Text="{Binding Sentences.Text}"  />

Thanks David!

Formatting Code in WordPress

Posted April 14, 2009 by andrewwhitten
Categories: Uncategorized

I havn’t blogged for a while.. possibly for the fact that it was a bit painful to get my code to come up correctly.

Well, here is a test post :)


    /// <summary>
    /// Just a test
    /// </summary>
    public interface IBlobDriveObject
    {
        string ObjectName { get; }
        string FullName { get; }
        void CopyTo(string dstPath);
        void CopyTo(string dstPath, bool overwrite);
    }

 

Here is a description of how:

http://support.wordpress.com/code/

Yet another iPhone post

Posted February 19, 2009 by andrewwhitten
Categories: Uncategorized

Since the internet has so little discussion about the iPhone, I obviously have to write something ;)

I have been a long time Windows Mobile developer.. all the way from PocketPC 2000 devices to Windows Mobile 6. (and I still think the origional Compaq iPaq is one of the most cool devices you can hold in your hand)

However, after 2 years of really good service, my HTC TyTN (Version 1) had been slowly dying with blank screens and broken keyboard. As a result I started looking at upgrade options.

Since my other favorite device was my iPod Nano, it made sence to give the iPhone 3G a look. Dan Obasanjo already has a post in which he compares his iPhone to his previous Windows Mobile.

Some additional thought of my own:

 

Good

Consolidation: iPod and mobile phone in one: I only have to check for one device in my pocket at any one time

Size: Always in my pocket without me noticing

International keyboards: I can type in Korean or Japanese very easily. This was something I could never really enable on my Windows Mobile device without third party software

Exchange Integration: I think Dan is more of an Exchange ‘power user’ than I am. I have only had positive experience with emails and agreeing meeting schedules, although I would only schedule my own meetings from Outlook.

Wifi hotspot detection: Windows Mobile makes life really hard to try and pick up a new Wifi signal (at least on my devices). I can pull out my iPhone anywhere and use an available network very quickly.

 

Bad:

Development: $199 for a developers kit? Microsoft really did a great job with the Compact Framework and SQL Server Compact.

Typing and link clicking: Maybe I have the wrong fingers, but I miss the precision I got with windows Mobile and a stylus. Small hyperlinks on a web page are also really annoying.

Speed: The iPhone is more than usable.. it just seems to lack a degree of responsiveness…

3rd Party Applications: Searching the iTunes store for useful and free apps is difficult. Also like music, apps are sold to each particular region so to download a useful public transport application to a different country you will need to set up anther iTunes account :(

Pay Apple to make song into Ringtone: Dan pointed this out, and it really justifies a lot of negative opinion people have about Apple. Luckially you can get around this for free by exporting your music file by AAC and renaming the file suffix. (You can easily google for this hack)

 

Personal Conclusion: 

The iPhone 3G is a great purchase, and makes up for lack of flexibility by just employing a simple interface. I really hope Windows Mobile 7 can catch up with this, but it will be a stretch…

New development box

Posted December 22, 2008 by andrewwhitten
Categories: Uncategorized

Its been quiet, but I am back with a new custom development rig, Vital Stats:

CPU : Q9400
MB:   Gigabyte 45-DS4
RAM:  OCZ Platinum CC4 8GB
HD:   3 x Samsung 500GB  Sata 2 (RAID 5 configuration)
GPU:  NVidia 9800GTX+

newquad1

Add my new 24” Widescreen Ultrasharp Dell monitor, and I have an acceptable development platform :)

I remember back at college I would dual boot Windows ME and Windows 2000… I have now returned to that with Windows Vista ( for productivity enhancing Fallout 3 sessions) and Windows Server 2008 (Hyper-V for all my VM requirements)

The only issue installing this was getting the Windows install process to use the RAID driver from my USB key.

SQL Server 2000 Performance Tuning

Posted October 15, 2008 by andrewwhitten
Categories: SQL Server

I recently looked at an underperformaing 32-bit SQL Server 2000 server recently, and had to come up with some suggestions as to how performance could be increased. Surprisingly the ‘best practice’ guides for this version of SQL Server were hard to come by, and quite often refered to facilities only available in SQL Server 2005 and above.

This is not a comprehensive list, but more of a starting point:

1) Implement new indexes

Run profiler against a realistic load of your database, and take note of the Reads, Writes and CPU count of each operation. Quite often a disproportionatly expensive query does not have a matching optimized index and is performing full table scans. If that query is very common, then you have an obvious candidate for performance improvement.

2) Remove duplicate existing indexes

Conversly you can have too many indexes, which are expensive to maintain. If you have two similar indexes, one on columns A & B and another on A & B & C, consider removing the second one. You may find overall perfroamnce gains

3) Consider using AWE

If your server has a lot of RAM and your SQL Server edition allows it, then consider turning on AWE to start accessing more than 1.7GB of RAM for your database. This will:

  • Reduce use of TempDB
  • Reduce general disk access

4) Consider upgrading to SQL Server 2005 64-bit

Although you can get 64 bit memory access in SQL Server 2000 Data Center edition, a more cost effective (and now supported) option would be to migrate up to SQL Server 2005

5) Maintainance Plan that Rebuilds Indexes Frequently

Fairly obvious, but a good maintainance plan will optimise your database on a nightly basis. (assuming you can afford the downtime overnight)

6) Remove use of Cursors

Despite what some people say, there are very few scenarios where you need to use cursors. Replace them with good queries inside Stored Procedures and see great increases in performance.

7) Rewrite queries that use ‘SELECT *’

Should be obvious, but a query that runs SELECT * is probably scanning the table far more than it really needs to. It also makes changes to that table risky.

8) Remove HINTS from queries

There might be some debate about the usefullness of HINTS, but the reality is that SQL Server 2000 can optimise queries far better than you can with a manual HINT prompt. If anything you are likely to make the query slower as a result by using it.

 

Links:

Finding duplicate indexes

SQL Server Sopport Timelines

General SQL Server storage best practice