{"id":875,"date":"2019-07-12T15:56:18","date_gmt":"2019-07-12T13:56:18","guid":{"rendered":"https:\/\/blog.besharp.it\/lets-create-a-serverless-notification-system-with-amazon-api-gateway\/"},"modified":"2021-03-24T18:11:04","modified_gmt":"2021-03-24T17:11:04","slug":"lets-create-a-serverless-notification-system-with-amazon-api-gateway","status":"publish","type":"post","link":"https:\/\/blog.besharp.it\/lets-create-a-serverless-notification-system-with-amazon-api-gateway\/","title":{"rendered":"Let\u2019s create a serverless notification system with Amazon API Gateway"},"content":{"rendered":"

In recent years, the widespread diffusion of Cloud computing has led to a massive adoption of the “microservices” application development paradigm. Refactoring of monolithic applications in microservices allows getting the most out of some intrinsic features of the Cloud itself, including the use of many \u201cmanaged\u201d<\/em> services, useful for delegating to the Cloud provider the management and reliability of critical tasks which aren\u2019t part of the application core<\/em>.<\/p>\n

beSharp is no exception: this refactoring process, in fact, also involved Noovolari Smart Backup<\/a> – our product for the management of Backup and Disaster Recovery of AWS infrastructures.<\/p>\n

In this regard, the refactoring of the application\u2019s notifications system, which are shown in the web interface upon the occurrence of specific events (such as the conclusion of a backup job or the opening of a file-level recovery session), is of particular interest.<\/p>\n

The old monolithic solution was based on Ruby\/ActionCable <\/strong>and Redis <\/strong>and centralized the operations for sending notifications in a single application controller.<\/p>\n

By taking advantage of the recent release of the API Websocket for Gateway by AWS, we decided to refactor the notifications\u2019 management engine in a microservice, completely serverless, using SQS to decouple the sending and receiving of messages.<\/p>\n

The introduction of Lambda Layers and the possibility of writing Lambda functions in Ruby (the main language with which Noovolari Smart Backup is developed) is also recent; thanks to these two features we were able to re-use most of the original backend code, thus keeping the code clean and easy to integrate in other future applications.<\/p>\n

This approach has given us several technical ideas that we decided to share in this article, creating a small tutorial on how to create a fully serverless notifications microservice based on AWS services.<\/p>\n

Technologies used<\/h2>\n

To implement this solution we will use the following languages and services:<\/p>\n