How we leveraged AWS Native Serverless to deliver a voting app for the DDD East Midlands 2023 conference.
Who are DDD East Midlands?
DDD East Midlands run a yearly conference supporting the tech community in the midlands and a key part of this is providing a platform for local developers. Topics for past conferences have ranged all the way from “Open Banking vs Defi” to “How to ruin kid’s games with machine learning”, and they all come from within the community.
Unsurprisingly crowd sourcing the topics for their conference provides a challenge, how to choose which ones to present at the conference? They are often oversubscribed with ideas for talks.
That’s where we came in.
What was the ask?
Naturally, we were thrilled when DDD asked to be part of the San4Good campaign. The proposal, to create a simple voting app to allow ticket holders to shortlist and vote for up to 10 potential topics. Well-defined projects delivering value in a short time frame is what we do and we set to work choosing the right technology for the job.
The app would be live for a short period of time, and would most likely be used in a short burst after tickets went on sale. Therefore serverless tech was the perfect fit for this project, paying on-demand the app could stay live for months without costing DDD a penny.
Using AWS was the only technical requirement provided, giving free reign over the AWS estate. APIs could be easily provided with API Gateway and Lambda integration, using DynamoDB as the serverless database of choice.
However hosting the NextJS frontend in a serverless manner proved to be a bit more of a challenge, statically hosting single page apps is practically bread and butter these days but optimised server side rendering, that normally requires the odd provisioned instance.
Luckily NextJS provides an option to export itself to a set of small JS bundles and by combining this with AWS Cloudfront’s Lambda@Edge capability, hey presto server side rendering. All without any pesky servers!
Serverless Server Side Rendering (Credit to https://github.com/serverless-nextjs)
For those in the audience who have worked painfully with CORS, I should probably make you aware of this OPTION. NextJS’s api routing functionality integrates easily with Lambda@Edge, meaning you can easily front your backend services on the same domain as the ui and relieve all the usual worrying over “Allow“ headers.
Database and tallying votes
DynamoDB is AWS’s native serverless NoSQL database, and it offers a on-demand provisioning model which only charges you if someone’s using it! But it has its quirks. One of which being fiddly on-demand cost optimisation. Hot partitions can lead to large bills for on-demand pricing, so choosing a good partition key is an important up-front task for developing most apps.
Hot Conference Partition
With a voting app however, simply using the user_id as the partition key meant that a partition was only as hot as a voting user and therefore load was easily spread across all partitions.
Cold Voting Partition
Aggregating votes to topics became forefront problem for us during the project, aggregating in realtime could cause partitions for a given, popular, topic to get particularly hot (as in the “Hot Conference Partition” diagram above). This was until we realised we were straying into the danger territory of over-engineering.
We’ve all done it, why wouldn’t a conference admin want this feature? But if this one-time process, of counting votes, could be done as an off-line human process, why not crack out our old friend excel!
Its probably worth talking about CI/CD at this point, and Github actions provided us with a very simple, easy pipeline to auto deploy the main branch to dev with a manual deploy option to the master environment. We wanted DDD to be able to extend our solution in the future so intention driven unit tests made an appearance. Local DynamoDB is quite the handy thing if you are unaware of it, writing integration tests for db queries is something I definitely could not live without.
The DDD voting app went from concept to production in a week, best practices around testing and CI/CD meant that we could provide a quick and value driven delivery.
We look forward to using the app ourselves when it goes live for DDD 2023, in the meantime keep your eyes peeled for ticket sales and you yourself can vote for what topics are discussed at the next conference!