Why Would I Choose Serverless Again?
In 2021, I Co-Founded a startup and built the entire platform on AWS using serverless services with a microservices architecture. Now, three years later, if I had to do it all over again, would I make the same call? Oh yes, I would definitely choose serverless again.
The Serverless Revelation
When I first encountered the term Serverless, I was a bit sceptical. How could I run my Java application without a server? This initial confusion quickly faded away as I delved deeper into the concept of serverless computing. I realised it wasn't about eliminating servers altogether, but rather about shifting server management responsibilities to the cloud provider. This paradigm shift allows developers to focus solely on writing code, freeing us from the tedious tasks of installing and configuring server environments. It felt like someone had finally answered my prayers!
Beyond simplified management, serverless architecture offers built-in security and unparalleled scalability. Applications can scale from zero to thousands of requests per second, following a pay-as-you-use consumption model. Yes, you read that correctly – if you have zero requests, you pay nothing. It's a game-changer for startups and established businesses alike.
Building a Serverless Backend
When I started designing the architecture for my startup, I needed an API to act as the front door for the backend system, a service layer for the microservices, and a database. My requirements were that all these layers should be scalable, cost-effective, and I shouldn't have to wake up in the middle of the night to restart the servers. AWS Serverless was the best option for me due to all the those reasons.
For the API, Amazon API Gateway emerged as the perfect solution, offering incredible scalability with a soft limit of 10,000 requests per second. It provided all the essential features I needed: REST API support, rate limiting, and authorisation through Amazon Cognito, a serverless identity platform supporting OAuth2.
The microservices architecture relied heavily on AWS Lambda as the foundation for the service layer. With Lambda, I could focus solely on writing the business logic in Java, deploy it, and it would function seamlessly. The integration with Amazon API Gateway was incredibly smooth, enabling me to establish a single API with multiple endpoints, each invoking a different Lambda function. The way Lambda can automatically scale its execution capacity behind the scenes is awe-inspiring. I highly recommend exploring Lambda in greater depth to truly appreciate its power and capabilities.
To address my database requirements, I opted for DynamoDB, a NoSQL database renowned for its exceptional scalability and high-performance capabilities. Although I am way more familiar with relational databases, I struggled to find an alternative that matched the impressive scalability and cost-effectiveness offered by DynamoDB.
Finally, to achieve loose coupling and enhanced scalability, I implemented an event-driven approach in our backend. Amazon EventBridge, a serverless event bus, played a crucial role in this aspect, allowing me to build a more resilient and reactive system.
Cost-Effectiveness of Serverless
One of the most attractive aspects of serverless architecture for startups is its cost-effectiveness. The generous free tier offered by these serverless services allowed me to develop the platform with minimal expenses. During the development phase, the AWS costs were $0, and even in production, I paid less than $10 per month. This level of cost optimization is crucial for startups or companies operating on limited resources.
Embracing the Serverless Future
My experience with serverless architecture has been overwhelmingly positive, and I wouldn't hesitate to choose it again for future projects. The combination of simplified management, unparalleled scalability, cost-effectiveness, and rapid development makes serverless an excellent choice for businesses of all sizes. By using AWS serverless, I felt like AWS experts were part of my team, without any additional charge.