{"id":3983,"date":"2021-12-24T13:59:00","date_gmt":"2021-12-24T12:59:00","guid":{"rendered":"https:\/\/blog.besharp.it\/?p=3983"},"modified":"2021-12-22T16:13:49","modified_gmt":"2021-12-22T15:13:49","slug":"gradual-migration-and-refactoring-of-applications-to-serverless-leveraging-amazon-api-gateway","status":"publish","type":"post","link":"https:\/\/blog.besharp.it\/gradual-migration-and-refactoring-of-applications-to-serverless-leveraging-amazon-api-gateway\/","title":{"rendered":"Gradual migration and refactoring of applications to serverless leveraging Amazon API Gateway"},"content":{"rendered":"\n
Nowadays, more and more apps, services, and projects are developed following the serverless approach.<\/p>\n\n\n\n
Several applications may leverage the serverless paradigm to improve performance while achieving both high availability and elasticity. Still, they need to be migrated and heavily refactored.<\/p>\n\n\n\n
Migrating an application to serverless often involves a partial rewriting of the codebase to implement an execution model suitable for the FaaS service chosen. Also, the overall architecture should embrace microservices and an event-based flow, favoring, when possible, asynchronous processing and high decoupling using messaging services.<\/p>\n\n\n\n
To achieve the above specifications, especially in the case of complex applications, the effort and time required can easily reach impressive magnitudes.<\/p>\n\n\n\n
Sometimes, it’s simply not feasible to completely refactor a whole application before its deployment.<\/p>\n\n\n\n
This article will illustrate a technique that uses API Gateway to perform the routing and adaptation of user’s requests, allowing the gradual migration and refactoring of complex applications without affecting their availability.<\/p>\n\n\n\n
Amazon API Gateway is a managed service that serves as the front door of your application. It acts as a managed gateway for the backend; it can also directly integrate with other supported AWS services to push the payload into the appropriate processor or message system. API Gateway can handle hundreds of thousands of concurrent API calls and perform traffic management, CORS support, authorization, access control, throttling, monitoring, and API version management. <\/p>\n\n\n\n
The technique illustrated in this article leverages API Gateway capabilities to act as a proxy for the entire application, accept the requests, make the required changes to the payload format, and perform the routing between the legacy application and the refactored endpoints.<\/p>\n\n\n\n
The method we propose in this article is to map all the application endpoints undergoing migration to a single API Gateway which will act as a centralized access point for the application.<\/p>\n\n\n\n
Once all the requests flow towards a single infrastructural object, it will be possible to maintain two distinct versions of the application: the legacy one and the new version, which we can implement incrementally.<\/p>\n\n\n\n
<\/p>\n\n\n\n