Powering the Supply Chain with Serverless Architecture — Part 2

Abu Shoaib
Nov 15, 2018 · 7 min read

This is the second part of an article about how we use server-less architecture at Gousto to power our supply chain operations. The first part elaborates on our journey to the new architecture, and this part details the architecture itself along with benefits and drawbacks.

A server-less architecture

The principles highlighted in the first part guided us towards an architecture based on the publish-subscribe pattern. Within our AWS platform, we already had the ability to define events that any deployable micro-service could publish and consume, following a convention-based approach using Amazon SNS and SQS.

Along with the capabilities offered by our chosen ERP system, these building blocks enabled us to rapidly iterate on our integration strategy, making substantial use of Amazon SQS, SNS, S3 and Lambda. Using these Amazon services eliminated the need to manage message brokers, file servers, or application servers, making the architecture entirely server-less.

Physical architecture for server-less integrations between the Gousto platform, WMS, and new ERP system

The architecture is composed of a few different components.

  • The Gousto platform and the ERP system itself, both of which provide REST APIs and event sources for interfacing.

The utilisation of this architecture is illustrated in the following example for purchasing carrots from a supplier.

Simplified workflow for purchasing carrots


Adopting this architecture has provided a significant number of benefits, to both the business, and to the Engineering teams who develop and maintain this ecosystem.

Specifically, some of the key benefits emanate from our use of AWS Lambda.

  • Spikes in transactions, especially our order volumes, are handled seamlessly by AWS Lambda’s cost-efficient scalability — this new pipeline can easily handle over 100,000 transactions an hour, compared to only 4,000 with our first-generation systems. We are only limited by the ingest rate of the WMS and adjustable concurrency limits in AWS itself.

This architecture and the use of other AWS server-less components provide a number of other technical benefits as well.

  • Treating transactions in a platform-agnostic way using consistent JSON schemas allows replacement or addition of end systems and interfaces, without any changes to the architecture.

Finally, with our first-generation systems, we often had very limited knowledge of issues or bottlenecks until we were informed by business teams about missing data. Resolving these issues could take hours due to a lack of visibility of data flow between systems.

By using native AWS services in our new architecture, we are automatically provided with native monitoring support through AWS CloudWatch.

Measuring and alerting on CloudWatch metrics such as the number of events published to an SNS topic, queue depth of an SQS queue, or execution time of a Lambda function allows our developers to proactively identify bottlenecks and failures and resolve issues within minutes.

AWS CloudWatch dashboard for monitoring sales orders

Business value

Moreover, these technical benefits have allowed us to release immense value to the business.

With the new architecture, sales orders can be made available for picking seconds after being confirmed on our e-commerce platform. Compared to the hours that this process took previously, this has provided us with the ability to significantly reduce the lead time between order placement and delivery.

With data synchronisation occurring within seconds between the warehouse, the ERP system, and our e-commerce platform, business teams now have real-time insight into warehouse operations and transactions, which can then be analysed and optimised.

The same real-time insight allows us to provide value to our customers too. For example, we can identify the specific batch of chicken packed into a customer’s box. This data can be made available to our e-commerce platform seconds after picking, and we can use the expiry date from the batch to present a customised meal planner for the customer, based on when ingredients should be consumed by.

Finally, a special Lambda function, which consumes and archives all messages published within this pipeline, is used to provide a detailed audit log of all transactions that occurred between these systems. This is especially beneficial because of the strict traceability requirements within the food industry.


However, we have also needed to adapt ourselves to cater for a number of drawbacks that accompany such an architecture.

The sheer number of entities and types of transactions that can occur in an e-commerce platform, the WMS, and the ERP system means that there is a large number of AWS Lambda functions, SNS topics, and SQS queues to monitor. Our engineering teams are responsible for building, deploying, and supporting their own services in production, which can add a significant overhead with the amount of components to monitor.

Additionally, with the use of native AWS components, it is not trivial to develop and test against the entire cloud-based ecosystem on a local development machine. We make use of a combination of Docker containers, mocking certain AWS components, and contract-testing, along with end-to-end testing on multiple AWS environments to overcome this limitation.

Finally, even though we have an automated and scalable pipeline, the end systems are still operated by humans, leaving scope for human error.

By ensuring that data validation rules are consistent in our e-commerce platform, ERP system, the WMS, and in all stages in between, we can reduce the likelihood of human error causing data consistency and integrity issues.

The future

Since going live with our new ERP system and architecture, we have already realised a significant number of benefits and provided additional value.

However, such a flexible architecture provides countless more opportunities, and with an exciting roadmap ahead of proposition enhancements leveraging this architecture, we are only limited by our imagination and the capacity of our engineering team!

An obvious improvement we can make is replacing our dedicated WMS with a more modern, scalable system. Whether we build something ourselves, buy off-the-shelf software, or a combination of both, the only modification required is a new Lambda function to convert JSON messages into the appropriate interface format.

Additionally, using transactions from pick-events in the warehouse, we can potentially update stock on our website in real-time, or intelligently manage stock depending on objectives.

Finally, one of the most exciting use-cases involves a virtual simulation of our warehouse, where our engineers run machine-learning algorithms to optimise warehouse capacity.

Virtual simulation of Gousto’s warehouse

By tapping into the sales order pipeline and sending real sales orders to the virtual warehouse, we can run parallel simulations of boxes being routed around our warehouse, and ensure that our real picking line is optimised for any given set of orders.

The benefits and value created by our new ERP system and the architecture around it have been revolutionary for Gousto, and we are tremendously excited to realise its full potential in the years ahead.

If you are interested in working with any of the technologies mentioned in this blog post, we are hiring! Visit https://www.gousto.co.uk/jobs to apply.

Gousto Engineering & Data Science

Gousto Engineering Blog

More From Medium

More from Gousto Engineering & Data Science

More from Gousto Engineering & Data Science

How to refactor some horrible code

More from Gousto Engineering & Data Science

More on Software Engineering from Gousto Engineering & Data Science

More on Software Engineering from Gousto Engineering & Data Science

Lean delivery in a physical world

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade