White Paper
Building Scalable Applications Using Microsoft Technologies
Introduction
CIOs lay great emphasis on application scalability and performance and rightly so. As business grows, the number of transactions and users grow exponentially. Every development team wants to build “scalable” applications. Teams need to have the skills and experience in building scalable applications that can handle several thousand transactions per second. This paper will examine some of the best practices followed by Trigent to develop highly scalable and performing web applications.
Trigent follows several best practices prescribed by Microsoft’s Patterns and Practices group to design
scalable applications (http://msdn.microsoft.com/en-us/library/ff921345.aspx). This paper will list some
of the most important and practical suggestions followed by our development teams.
Definition of Scalability
Scalability Types
- Scaling Up: This is a commonly used term for achieving scalability using better, faster, and more expensive hardware. Scaling up includes adding more memory, adding more or faster processors, or simply run the application on a more powerful, single machine. This method allows for increase in capacity without source code changes.
- Scaling Out: Scaling out leverages the economics of using relatively low-cost hardware to distribute the processing load across more than one server. Scaling out is achieved using a collection of machines, essentially functioning as a single unit. By dedicating several machines to a common task, application fault tolerance is also increased. From an administrator's perspective, scaling out presents a greater management challenge, due to the increased number of machines.
Best Practices for Achieving Scalability
- Application layering techniques: This section recommends best practices on the application structure.
- Design and development techniques: This section provides design and development recommendations that can be applied to all layers.
- Database techniques: This section recommends best practices on the database design and development.
- Other techniques: This section provides some specific alternate solutions and deployment recommendations like Microsoft Azure.
Application Layering Techniques
Logical Separation of Layers
Loose Coupling Across Layers
Design and Development Techniques
Manage Resources
Minimize Round Trips
Multithreading, .NET 4.5’s Async Support to Handle Blocking Calls
Session State Management
Caching
Use StringBuilder
Trust the Garbage Collector
Scaling Techniques for Web Client Layer
Database Techniques
Database Fine Tuning
- Frequently check the performance of the application on the database side during the development cycle.
- Ensure non clustered indexes are created for the frequently used slow running queries.
- Query fine tuning to be done to ensure proper joins are maintained instead of Cartesian or cross joins.
- Limit the use of “Order by” and “Distinct”.
- Limit the use of sub query - better, replace with other joins appropriately .
- Ensure Select query returns only the required columns and not all the columns.
- Use some of the latest improvements in SQL Server 2012 like Pagination and Column Store Indexes.
- Use database partitioning as appropriate. For example, if you have a very large table used in say a banking environment where the current month of data is being constantly updated and the previous months’ data is being constantly reported on, then you can partition this table by month. With partitioning, maintenance operations such as index rebuilds and defragmentation can be performed on the single month of write-only data, while the read-only data is available for online access.
- Use Stored procedures for compute intensive queries. This will always perform faster than an ORM mapper which may not optimize the SQL calls.