Our Blog

where we write about the things we love

24

Oct

Updating Microsoft’s StockTrader Sample Application

StockTrader is a sample application provided by Microsoft to help developers understand how to build a .NET application that can run at scale, using a real-life scenario.

StockTrader

 

As the name of the application suggests, the solution is built around the scenario of share trading and illustrates an n-tier, SOA-based application based on the Microsoft stack.

StockTrader is now well over five years old and has changed over time to take advantage of new and emerging technologies (including Windows Communication Foundation (WCF), cloud and mobile). As a result, StockTrader is a little different from your standard ‘Hello World’ technology sample: not only does it provide an end-to-end application solution, it also shows how an application can be extended to enable new scenarios and support new platforms.

Last week the latest version of Microsoft’s .NET StockTrader sample application was released – its sixth release – bringing with it a new set of mobile clients and cloud optimisations. Intergen was pleased to work with Microsoft to deliver this latest release.

 

Underneath the hood

With smartphone and mobile device adoption growing rapidly, basic web applications are often no longer sufficient to deliver a solution that is appropriate for all customers or users. StockTrader now includes native clients for Apple iOS, Google Android, Windows Phone 7 and Windows 8 as well as a new ASP.NET MVC4 and HTML5 web application. All of the new clients are written in .NET and C#, with Xamarin Mono enabling support for non-Microsoft platforms. Each client has its own platform-specific UX layer delivering a platform-specific experience, however they use a significant shared code base for common functions such as data access and configuration.

Taking this approach ensures a first-class user experience on each device while also delivering a significant reuse of both code and developer skills. It also avoids the challenge of maintaining duplicate implementations of common functions for each device while at the same time providing a more native experience than HTML5-based solutions such as PhoneGap. The MVC web application also provides a tailored mobile experience through the use of responsive CSS. This allows the website to return the same content to all clients, with CSS applying a layout specific to the user’s screen resolution. Also, existing WCF services were reconfigured to expose REST endpoints, quickly enabling mobile-friendly access (compared with existing SOAP messages).

The StockTrader sample is designed to show a real-life scenario and to show how .NET applications are able to run at scale. While StockTrader 5 was Azure-enabled, the new version is ‘Azure-optimized’; optimized to run at massive scale. A successful migration to Azure requires more than mere compatibility; taking full advantage of the platform is often required to deliver the promised scalability and reliability of cloud computing. Since the last release, Azure has grown into a mature cloud platform and two new technologies are ideally suited to this sample: SQL Azure Federations and Service Bus.

SQL Azure Federations enables massive data scale-out by horizontally partitioning your database into physically separate databases (called ‘federation members’). This not only allows your databases to grow beyond the SQL Azure limit of 150GB but it also allows load to be distributed across many nodes instead of just one. Furthermore, federation members can be split on demand and under load, leading to a highly scalable data tier. Only minor changes were required to migrate from SQL Azure to SQL Azure Federations; however, there were a number of gotchas around connection and transaction management (discussed further in the Intergen-authored whitepaper below). Federations provide the database tier with the same scale-out capabilities as Windows Azure provides at the application tier.

Service Bus provides durable and asynchronous messaging in the cloud through queues and topics (‘pub/sub’). By leveraging the out of the box WCF support, introducing Service Bus was almost as simple as updating configuration. Service Bus allowed us to decouple the two major application components (the ‘Brokerage’ and the ‘Exchange’), allowing critical trade messages to be reliably sent regardless of system availability. The mobile clients also use Service Bus through its mobile-friendly REST interface to receive news updates. Service Bus is emerging as key part of cloud-based design to deliver the level of reliability required for business critical operations.

In summary, StockTrader provides an excellent reference for new and existing applications wanting to take advantage of the cloud or introduce a broad set of mobile clients. If you’re interested in learning more, take a look at the whitepaper, watch some of the online presentations or download the application from the StockTrader home page. Here is a list of useful resources:

If you’re interested in building large scale cloud hosted apps then we’d love to talk further. Please contact

James.Carpinter@intergen.co.nz and Chris.Auld@intergen.co.nz.

Posted by: James Carpinter, Senior Developer, Enterprise Applications | 24 October 2012

Tags: Windows Azure, Microsoft, .NET, SQL, Windows Communication Foundation


Top Rated Posts

Blog archive

Stay up to date with all insights from the Intergen blog