Modernizing monolithic applications to serverless architecture on AWS

Impetus Technologies
5 min readSep 15, 2021

--

By Aditya Parasrampuria

Serverless architecture is a modern application design paradigm that allows enterprises to build and run applications and services without worrying about server management. It enables users to focus on writing business logic, while the cloud service provider takes care of infrastructure management tasks like server/cluster/capacity provisioning, patching, and operating system maintenance.

This, coupled with pay-as-you-go pricing, lightweight code deployment artifacts, and shorter CI/CD cycles make serverless a compelling choice when modernizing legacy monolithic architecture-based applications.

This blog outlines how you can leverage serverless architecture on Amazon Web Services (AWS) for modernizing monolithic applications. It focuses on effective compute and API management using AWS Lambda and Amazon API Gateway.

From monolithic to serverless in 4 steps

Monolithic applications are self-contained, which means each component and the associated components must be present for the code to be executed and compiled. This often makes it difficult for developers to scale components or implement changes. The ability of an enterprise to move to serverless computing depends largely on their existing technology stack and the proficiency of their developers in languages and frameworks supported by cloud providers. AWS supports the most popular runtimes and offers custom runtimes, empowering developers to write code in languages of their choice.

Though AWS serverless computing may not be suitable for modernizing all your legacy applications, with careful planning, it can accelerate migration to a microservices-based architecture. Here’s an overview of our proven 4-step strategy to move from monolithic to a serverless architecture.

· Step 1Break down monolithic architecture into microservices

The first step while moving from monolithic to serverless architecture is to identify important areas of functionality across each application. These functionalities can then be considered as transformation candidates for microservices. For example, if you are managing a user account and profile, then a “user account” could be one of your microservices. If you are running a digital content website, then “articles” and “subscriptions” could be your next set of candidates. Post migration, these microservices can power various functionalities in your application.

Moreover, each microservice can be a collection of API endpoints corresponding to a specific operation. So, for the microservice “user”, you could use APIs to create new users, update existing users, and delete users from the system.

· Step 2 Identify the best-fit microservices

After breaking down functionalities into a set of microservices, the next step is to identify a fit between these microservices and the serverless architecture.

From an implementation perspective, each microservice can be implemented as a REST API in Amazon API Gateway. API endpoints can be implemented as “resources” within those APIs. For instance, you can have an API in Amazon API Gateway named “user”, which will have resources like “/user/create,” “/user/update,” “/user/delete”. Each of these resources can support HTTP methods like POST, PUT, DELETE, etc. This logic can be extended to all the microservices identified in Step 1.

· Step 3 Move the identified microservices to serverless architecture

As part of the implementation, provision the API endpoints using Amazon API Gateway and write the business logic in AWS Lambda, a serverless event-driven compute service. To reduce the turnaround time, you can port your existing logic into Lambda. While Lambda offers significant advantages, it has certain limitations:

- AWS provisions resources for function execution each time an invocation is made. However, the first time a function is invoked, or if it is invoked after a long time, there might be a delay in preparing the runtime container for execution. This introduces a type of latency known as Cold Start. Runtimes like Java are most affected by this phenomenon because of their runtime size and the additional resources required for running JVM. However, choosing runtimes like NodeJS or C# leads to considerably lower latencies. This results in lower memory provisioning, and faster execution and application response time, which in turn helps save cost.

- Currently, the maximum memory that can be allocated to Lambda functions is 3008 MB. Lambda does not provide any additional dedicated computing resources. So, if your application needs more memory or dedicated compute capacity, then Lambda may not meet your requirements.

· Step 4Leverage serverless architecture across use cases

In the previous steps, our focus was to identify application functionalities that can be transformation candidates for microservices. However, in most enterprise applications, it is not possible to transform all the business logic into microservices.

Here are some use cases where you can take advantage of serverless architecture even when microservices are not a good fit for your application:

· Scheduled jobs — Many strategic operations are executed with fixed scheduling. For instance, a leading management e-publication customer checks for active user subscriptions at a particular time every day. Such actions are not initiated externally through an API invocation, as applications tend to use Cron jobs for scheduling. To cater to such requirements, Lambda supports the scheduled execution of functions.

· Bridge services — Some applications comprise multiple services whose code is maintained separately. To promote code reusability and avoid redundancy, we recommend placing such code fragments in a centralized repository. This is especially helpful for use cases where only part of the code needs to be shared — such as connector code or utilitarian code. To facilitate this, Lambda provides a feature called “Layers,” which allows you to write commonly used code and refer to it across multiple Lambda functions. This helps reduce the size of the Lambda code package and drives faster updates.

Migration from monolithic to serverless architecture: Overview of the solution implemented for an e-publication

Ensuring a seamless transition

Attempting an all-out deployment of your monolithic applications in a single go poses several risks. Depending on the size and complexity of your existing applications, it could cause serious disruption for end users.

To ensure a smooth, risk-free migration, we recommended following a staggered deployment approach. Once you have identified transformation candidates for microservices, it is important to develop, test, and deploy them one by one, and verify each one’s integrability with the rest of the system. This cycle should be continuous until the application has been completely migrated to the new architecture.

Developing serverless applications to drive strategic benefits

Today, there are multiple off-the-shelf tools available to write serverless applications, including those offered by leading cloud providers. These tools help:

· Reduce the time required to write code for applications

· Improve code structuring

· Simplify version management for functions

· Manage different stages of the migration lifecycle — development, production, etc.

· Integrate various event triggers like API endpoints, queues, and others

Serverless computing is fast gaining popularity for the benefits it offers. It helps enterprises accelerate their journey to modern application architecture, enable the rollout of new features quickly, and improve responsiveness to market changes. With extensive experience in data platform modernization and cloud expertise, Impetus is well-positioned to help you leverage the flexibility and agility of serverless architecture to achieve your digital transformation goals. To know more, get in touch with us today.

--

--

Impetus Technologies
Impetus Technologies

Written by Impetus Technologies

Impetus is focused on creating powerful enterprises through deep data awareness, data integration, and advanced data analytics. https://bit.ly/38pelOr

No responses yet