Moving an Old Monolith to AWS Lambda with Zero Downtime: A 9-Year Story
Practical steps and lessons from breaking a single large codebase into microservices and serverless AWS Lambda without any downtime.

When you manage a core system for nearly 10 years, you see how software architecture changes over time. During my 9+ years at Krestech, one of our biggest milestones was breaking a large monolithic app into microservices, and then moving key parts to serverless AWS Lambda—all without taking the system down for users. Here is how we did it.
1. Problems with the Old Single-Server System
Like many apps built in the early 2010s, our system started as one big codebase. Over the years, deployments became slow, database connections ran out during peak hours, and changing one small feature could accidentally break billing.
We realized that simply buying bigger servers did not solve the root issue. We needed a setup that could scale parts of the app independently and let us ship fixes quickly.
Important Rule for Migrations Never rewrite everything at once. A full rewrite almost always takes longer than planned, and business needs will change while you are still working on it.
2. Moving Pieces One by One
Instead of rewriting everything from scratch, we moved parts one by one. We placed an API Gateway in front of the old system.
Whenever we worked on a specific feature—like login or notifications—we pulled it out into a standalone microservice or an AWS Lambda function.
The API Gateway routed new requests directly to Lambda, while older requests still went to the old server.
// Route dispatcher logic at the Edge
export async function routeRequest(req: Request) {
const path = new URL(req.url).pathname;
// New endpoints handled by Serverless Lambda functions
if (path.startsWith("/api/v2/auth") || path.startsWith("/api/v2/notifications")) {
return invokeLambdaService(req);
}
// Older endpoints still go to the original server
return forwardToLegacyCluster(req);
}
3. Handling Cold Starts and Database Connections
AWS Lambda works great, but you need to think about two things: cold starts and database connections. We reduced cold starts by keeping our code bundles small and removing libraries we did not need.
For databases, having many Lambda functions connect directly to MySQL or PostgreSQL will quickly use up all available connections. We added a database connection pool (like AWS RDS Proxy), which keeps connections open and shares them across Lambda functions.
4. Switching Over Without Downtime
To make sure nothing broke, we tested with copy traffic first. Before switching users to the new Lambda endpoints, our gateway sent a copy of real requests to Lambda in the background to verify the results.
Once the output matched and response times were fast, we slowly routed 10% of real users to Lambda, then 50%, and then 100% over two days. If anything went wrong, the system would automatically roll back.
Results We cut hosting costs by 42%, deployed updates multiple times a day instead of every two weeks, and had zero downtime during the switch.
Conclusion
Modernizing a system is not about using trendy tools. It is about making things easier for your team and more reliable for your users. Serverless is a powerful choice when you set it up step by step.