From the article, you’ll learn about a simple system that the author migrated from DigitalOcean droplet to AWS Lambda. A system where WebSocket is a necessity.

AWS Lambda is known for its scalability and ease of use. However, it is also known for its limitation – the maximum duration of 15 minutes. That’s why, most of the time, it is connected with HTTP API. What if I told you that you can build WebSocket-related systems with AWS Lambda? Heresy! Let me tell you a story of a simple system that we migrated from DigitalOcean droplet to AWS Lambda. A system where WebSocket is a necessity. So here’s how I implemented WebSocket with AWS Lambda and API Gateway.

At The Software House, we use Slack… a lot. It became a kind of foundation for our company and so did all the emojis. 😀 Obviously, at some point we started to think about which emoji is used the most often. A really simple question but difficult to answer without coding. In order to get the necessary data, I decided to build a very simple app.

  • Node.js backend app with MongoDB consisting of two parts:
    • Express.js API used as a subscriber for Slack reacting added/removed events and GET reaction endpoint.
    • WebSocket server allowing us to send information about changes in reactions count.
  • React SPA used for displaying the current count.

Everything hosted on a Digital Oceans droplet.

Obviously, even the smallest droplet was overkill for such a small app. However, because of the stateful nature of WebSocket, I couldn’t use a Serverless approach… or could I?

#aws #websocket #api #cloud #developer

Implementing WebSocket with AWS Lambda and API Gateway
2.35 GEEK