At base2Services, we live and breathe cloud infrastructure. While our daily operations focus on stability and scalability, our HackDays are the perfect excuse to push boundaries and get our hands dirty with the very latest AWS releases. For our most recent session, we set our sights on a challenge that has frustrated developers for years: building a truly synchronous API on top of an asynchronous, event-driven architecture.
Our tool of choice? The recently released AWS Durable Lambda functions.
In the world of IoT, communication is almost exclusively asynchronous. You send a command to a device via MQTT, and eventually, the device reports back. However, modern web applications often demand a synchronous RESTful experience - the user clicks a button, waits a moment, and expects an immediate confirmation that the action was completed on the device.
Historically, bridging this gap involved complex workarounds:
We wanted to see if the new AWS Durable Lambda feature could solve this architecture problem without the polling overhead.
Our goal was to create a solution where an Amazon API Gateway request could trigger a process that communicates with a physical device and returns a response in a single HTTP transaction - without the Lambda function spinning idly or polling a database.
We built a Proof of Concept (PoC) leveraging AWS IoT Core and the new AWS Durable Lambda capabilities. Here is the flow we designed:
The theory was sound, but we were sceptical about the performance. Could a request travel from a user to the cloud, to a physical device, and back through a paused function fast enough for a web API?
The results were impressive.
Testing a round trip from a user in Melbourne, connecting to our API in Sydney, which communicated with a device back in Melbourne, we achieved latency of less than 1 second.
Key Takeaway: We achieved a fully event-driven architecture with zero polling. The Lambda only runs when it is processing or resuming, making it highly cost-effective, while the user gets the instant feedback of a synchronous web request.
This HackDay proved that AWS Durable Lambdas are a game-changer for "Device-in-the-loop" or "Human-in-the-loop" workflows.
By abstracting away the state management that usually requires Amazon DynamoDB or Step Functions, we were able to write code that looks synchronous but behaves asynchronously. This significantly reduces the complexity of IoT APIs and opens up new possibilities for real-time device interaction.
We validated that you can indeed have the best of both worlds: the reliability of event-driven architecture and the simplicity of RESTful APIs.
Contact us today to discuss modernising your cloud infrastructure with the latest AWS serverless capabilities.