Modernization pathways for a legacy .NET Framework monolithic application on AWS
AWS Architecture BlogModernization pathways for a legacy .NET Framework monolithic application on AWSby Ramakant Joshi | on19 MAY 2022| inAmazon Elastic Container Service,Architecture,AWS App2Container,AWS Database Migration Service,AWS Schema Conversion Tool|Permalink|ShareOrganizations aim to deliver optimal technological solutions based on their customers’ needs. Although they may be at any stage in their cloud adoption journey, businesses often end up managing and building monolithic applications. However, there are many challenges to this solution. The internal structure of a monolithic application makes it difficult for developers to maintain code. This creates a steep learning curve for new developers and increases costs. Monoliths require multiple teams to coordinate a single large release, which increases the collaboration and knowledge transfer burden. As a business grows, a monolithic application may struggle to meet the demands of an expanding user base. To address these concerns, customers should evaluate theirreadiness to modernize their applications in the AWS Cloudto meet their business and technical needs.We will discuss an approach to modernizing a monolithic three-tier application (MVC pattern): a web tier, an application tier using a .NET Framework, and a data tier with a Microsoft SQL (MSSQL) Server relational database. There are three main modernization pathways for .NET applications: rehosting, replatforming, and refactoring. We recommend following thisdecision matrixto assess and decide on your migration path, based on your specific requirements. For this blog, we will focus on a replatform and refactor strategy to design loosely coupled microservices, packaged as lightweight containers, and backed by a purpose-built database.Your modernization journeyThe outcomes of your organization’s approach to modernization gives you the ability to scale optimally with your customers’ demands. Let’s dive into a guided approach that achieves your goals of a modern architecture, and at the same time addresses scalability, ease of maintenance, rapid deployment cycles, and cost optimization.This involves four steps:Break down the monolithContainerize your applicationRefactor to .NET 6Migrate to a purpose-built, lower-cost database engine.1. Break down the monolithMigration to theAmazon Web Services (AWS)Cloud hasmany advantages. These can include increased speed to market and business agility, new revenue opportunities, and cost savings. To take full advantage, you should continuously modernize your organization’s applications byrefactoring your monolithic applications into microservices.Decomposing a monolithic application into microservices presents technical challenges that require a solid understanding of the existing code base and context of the business domains.Several patternsare useful to incrementally transform a monolithic application into microservices and other distributed designs. However, the process of refactoring the code base is manual, risky, and time consuming.To help developers accelerate the transformation, AWS introducedAWS Microservice Extractor for .NET. This helps breakdown architecting and refactoring applications into smaller code projects. Read howAWS Microservice Extractor for .NET helped our partner, Kloia, accelerate the modernization journey of their customersand decompose a monolith.The next modernization pathway is to containerize your application.2. ContainerizeWhy should you move to containers? Containers offer a way to help you build, test, deploy, and redeploy applications on multiple environments. Specifically,Docker Containersprovide you with a reliable way to gather your application components and package them together into one build artifact. This is important because modern applications are often composed of a variety of pieces besides code, such as dependencies, binaries, or system libraries. Moving legacy .NET Framework applications to containers helps to optimize operating system utilization and achieve runtime consistency.To accelerate this process, containerize these applications to Windows containers withAWS App2Container (A2C). A2C is a command line tool for modernizing .NET and java applications into containerized applications. A2C analyzes and builds an inventory of all applications running in virtual machines, on-premises, or in the cloud. Select the application that you want to containerize and A2C packages the application artifact and identified dependencies into container images. Here is astep-by-step articleandself-paced workshopto get you started using A2C.Once your app is containerized, you can choose to self-manage by using Amazon EC2 to host Docker with Windows containers. You can also useAmazon Elastic Container Service (ECS)orAmazon Elastic Kubernetes Service (Amazon EKS). These are fully managed container orchestration services that frees you to focus on building and managing applications instead of your underlying infrastructure. ReadAmazon ECS vs Amazon EKS: making sense of AWS container services.In the next section, we’ll discuss two primary aspects to optimizing costs in our modernization scenario:Licensing costs of running workloads on Windows servers.SQL Server licensing cost.3. Refactor to .NET 6To address Windows licensing costs, consider moving to a Linux environment by adopting .NET Core and using theDockerfile for a Linux Container. Customers such asGoDataFeedbenefit by porting .NET Framework applications to more recent.NET 6and running them on AWS. The .NET team has significantlyimproved performance with .NET 6, including a 30–40% socket performance improvement on Linux. They have added ARM64-specific optimizations in the .NET libraries, which enable customers to run onAWS Graviton.You may also choose to switch to a serverless option usingAWS Lambda(which supports .NET 6 runtime), or run your containers onECS with Fargate, a serverless, pay-as-you-go compute engine. AWS Fargate powered byAWS Graviton2 processorscan reduce cost by up to 20%, and increase performance by up to 40% versus x86 Intel-based instances. If you need full control over an application’s underlying virtual machine (VM), operating system, storage, and patching, run .NET 6 applications onAmazon EC2Linux instances. These are powered by the latest-generation Intel and AMD processors.To help customers port their application to .NET 6 faster, AWS added .NET 6 support toPorting Assistant for .NET. Porting Assistant is an analysis tool that scans .NET Framework (3.5+) applications to generate a target .NET Core or .NET 6 compatibility assessment. This helps you to prioritize applications for porting based on effort required. It identifies incompatible APIs and packages from your .NET Framework applications, and finds known replacements. You can refer to ademo videothat explains this process.4. Migrate from SQL Server to a lower-cost database engineAWS advocates that you build use case-driven, highly scalable, distributed applications suited to your specific needs. From a database perspective, AWS offers 15+purpose-built enginesto support diverse data models. Furthermore, microservices architectures employ loose coupling, so each individual microservice can independently store and retrieve information from its own data store. By deploying thedatabase-per-servicepattern, you can choose the most optimal data stores (relational or non-relational databases) for your application and business requirements.For the purpose of this blog, we will focus on a relational database alternate for SQL Server. To address the SQL Server licensing costs, customers can consider a move to an open-source relational database engine.Amazon Relational Database Service (Amazon RDS)supports MySQL, MariaDB, and PostgreSQL. We will focus on PostgreSQL with a well-defined migration path. Amazon RDS supports two types of Postgres databases:Amazon RDS for PostgreSQLandAmazon Aurora PostgreSQL-Compatible Edition. To help you choose, readIs Amazon RDS for PostgreSQL or Amazon Aurora PostgreSQL a better choice for me?Once you’ve decided on the Amazon RDS flavor, the next question would be “what’s the right migration strategy for me?” Consider the following:Convert your schemaMigrate the dataRefactor your applicationSchema conversionAWS Schema Conversion Tool (SCT) is a free tool that can help you convert your existing database from one engine to another. AWS SCT supports a number of source databases, including Microsoft SQL Server, Oracle, and MySQL. You can choose from target database engines such as Amazon Aurora PostgreSQL-Compatible Edition, or choose to set up a data lake using Amazon S3. AWS SCT provides a graphical user interface that directly connects to the source and target databases to fetch the current schema objects. When connected, you can generate a database migration assessment report to get a high-level summary of the conversion effort and action items.Data migrationWhen the schema migration is complete, you can move your data from the source database to the target database. Depending on your application availability requirements, you can run a straightforward extraction job that performs a one-time copy of the source data into the new database. Or, you can use a tool that copies the current data and continues to replicate all changes until you are ready to cut over to the new database. One such tool isAWS Database Migration Service (AWS DMS)that helps you migrate relational databases, data warehouses, NoSQL databases, and other types of data stores.With AWS DMS, you can perform one-time migrations, and you can replicate ongoing changes to keep sources and targets in sync. When the source and target databases are in sync, you can take your database offline and move your operations to the target database. ReadMicrosoft SQL Server To Amazon Aurora with PostgreSQL Compatibilityfor a playbook or use thisself-guided workshopto migrate to a PostgreSQL compatible database using SCT and DMS.Application refactoringEach database engine has its differences and nuances, and moving to a new database engine such as PostgreSQL from MSSQL Server will require code refactoring. After the initial database migration is completed, manually rewriting application code, switching out database drivers, and verifying that the application behavior hasn’t changed requires significant effort. This involves potential risk of errors when making extensive changes to the application code.AWS builtBabelfish for Aurora PostgreSQLto simplify migrating applications from SQL Server toAmazon Aurora PostgreSQL-Compatible Edition. Babelfish for Aurora PostgreSQL is a new capability for Amazon Aurora PostgreSQL-Compatible Edition that enables Aurora to understand commands from applications written for Microsoft SQL Server. With Babelfish, Aurora PostgreSQL now understandsT-SQL, Microsoft SQL Server’s proprietary SQL dialect. It supports the same communications protocol, so your apps that were originally written for SQL Server can now work with Aurora. Read abouthow to migrate from SQL Server to Babelfish for Aurora PostgreSQL. Make sure you run theBabelfish Compass toolto determine whether the application contains any SQL features not currently supported by Babelfish.Figure 1 shows the before and after state for your application based on the modernization path described in this blog. The application tier consists of microservices running on Amazon ECS Fargate clusters (or AWS Lambda functions), and the data tier runs on Amazon Aurora (PostgreSQL flavor).Figure 1. A modernized microservices-based rearchitectureSummaryIn this post, we showed a migration path for a monolithic .NET Framework application to a modern microservices-based stack on AWS. We discussed AWS tools to break the monolith into microservices, and containerize the application. We also discussed cost optimization strategies by moving to Linux-based systems, and using open-source database engines. If you’d like to know more about modernization strategies, read thisprescriptive guide.Ramakant JoshiRamakant Joshi is an AWS Solutions Architect, specializing in the analytics and serverless domain. He has a background in software development and hybrid architectures, and is passionate about helping customers modernize their cloud architecture.
Organizations aim to deliver optimal technological solutions based on their customers’ needs. Although they may be at any stage in their cloud adoption journey, businesses often end up managing and building monolithic applications. However, there are many challenges to this solution. The internal structure of a monolithic application makes it difficult for developers to maintain code. […]
Ramakant Joshi
Amazon Elastic Container Service Architecture AWS App2Container AWS Database Migration Service AWS Schema Conversion Tool