3 min readUpdated Aug 4, 2023

Integrating serverless WebSockets with AWS Lambda

An application is said to have a serverless architecture if a significant part of its computing depends on various third-party services such as Amazon AWS, Microsoft Azure, or Google Cloud. Application developers use serverless architectures to eliminate complexity and cost. The third-party supplier guarantees that infrastructure is always available and that it automatically scales up and down according to the changing load.

Ably is a serverless WebSocket-based realtime messaging platform. What's more, we play nicely with other serverless architectures, so you can add realtime features for live and collaborative experiences using the ecosystems you’re already invested in.

We provide managed integrations with other cloud services, so you can do anything from building a profanity filter to processing data elsewhere for analytics. We have ready-made integrations with the following services:

Ably combines with your preferred platform for serverless functions, so you don’t need to spend time and resources learning how to use a different serverless platform if you just want to add realtime features to extend it.

An example of using serverless WebSockets with AWS Lambda

Let’s consider an example where you decide to send a welcome message when someone comes online in a chat system.

In theory, this seems straightforward to implement, but consider a platform with millions of users, where a large percentage of them come online in a short period. A function that handles this use case may add significant load to your server and perhaps result in failed requests if you do not have sufficient capacity. Even if you are aware of an expected load, it is often costly to have sufficient spare capacity available. And if you miscalculate the load expectations, you risk overloading your servers.

Instead, you could use a serverless approach and invoke an AWS Lambda function to send the message asynchronously while your application carries out further operations. If you are using Ably to detect presence change events, it is straightforward to trigger the Lambda function as soon as one occurs.

In summary

Ably provides cloud infrastructure and APIs to help developers simplify complex realtime engineering. We make it easy to power and scale realtime features in apps or distribute data streams to third-party developers as realtime APIs.

A fundamental part of our platform is providing ready-built third-party integrations and data processing pipelines so you can continue to use the services and compute you’re already working with while Ably handles complexity and scale issues such as ordering, rate limiting, buffering and load balancing.

You can create a free Ably account to get started with realtime messaging and webhook integrations.

New call-to-action

Further reading

Note: This article was first published February 2018. Updated July 2022

Join the Ably newsletter today

1000s of industry pioneers trust Ably for monthly insights on the realtime data economy.
Enter your email