Today I found some features of Windows Server 2008 that can be used in the application to build scalable and more reliable applications and I added summary of my learning to my blog.
Application Recovery and Restart(ARR)
ARR is designed for C and C++ developers and is available starting from Windows Vista operating system. The APIS are available for .Net developers using PInvoke ARR allows a developer to customize an application’s behavior when WER terminates the application due to an unrecoverable error. The Application Recovery feature helps application to perform data recovery and cleanup operations such as capturing application state and releasing resources before termination. The Application Restart feature helps to specify whether WER should automatically restart an application after termination. Please look at this ARR APIs for more details
- An application that is using both Application Recovery and Application Restart cannot register for restart in its recovery code.
- Programs would be able to determine whether an application is starting up normally or is being restarted by WER after being forced to terminate and can take appropriate actions for recovery.
- Application Recovery can be canceled by the user via the Cancel button in the WER dialog window.
- WER will not restart an application if it executed for less than 60 seconds before being terminated. This behavior prevents applications from repeatedly restarting if they crash at or near startup time.
- Application can also specify certain available conditions under which the application should not be restarted. Some of the available conditions are crash due to an unhandled exception., application not responding. installation needs server to boot up again, installation demands application termination.
Be aware Applications can and should use the recovery function to attempt to free resources and shut down gracefully. Don not assume that you can successfully acquire system resources such as database connections and write your application. Have application persist user data and state information periodically while the application is working as expected.
Transactional Enhancements(TxF and TxR)
Applications use transactions to group operations on resources and ensure that the operations either succeed or fail as a single unit (that is, atomically). Applications rely on resource managers within the operating system to ensure that updates to resources are atomic, consistent, isolated, and durable (ACID). But if an application wants to perform a transaction involving file system, registry and SQL Server, the application programmer was solely responsible to perform complex error handling and recovery logic to handle situations where only part of the update is able to succeed or a catastrophic error occurs, such as a system crash. This was because SQL server supported resource manager that participate in DTC transaction, while file system has registry had no resource manager to take part in DTC transaction.
Windows Server 2008 comes with Kernel Transaction Manager (KTM) infrastructure to manages transactions. Developers can also use KTM to develop custom resource managers that support atomic operations and enforce concurrent updates and data consistency. Based on KTM infrastructure, Transactional Registry (TxR) is also readily available to allows applications to perform registry operations in a transacted manner and Transactional NTFS. (TxF) is also ready available to allow applications to perform file operations on an NTFS volume in a transacted manner. Using TxF and TxR, an application can also participate in DTC transaction enabling a transaction that runs across file system,registry, SQL Server and MSMQ.