Why Rust for Serverless?
Hmmmmm...
What you'll learn
- Why Rust makes sense for Lambda
- Comparing Rust to JS and Python in production
We used to optimize for how fast we could write code. Now, I mostly optimize for how fast that code runs and what it costs me at the end of the month.
"I used to think Rust was overkill for a simple Lambda function. Why bother when Node or Python works fine?"
"Until I saw the AWS bill and the cold start latency. Then I realized I was just paying a 'laziness tax' every single month."
What is "Serverless" anyway?
If you're new to this, the name is a bit of a lie. There are definitely servers involved, you just don't have to manage them, patch them, or worry about them crashing.
Think of it like this: instead of renting a whole apartment (a server) that you pay for even when you're not there, you're just paying for the time you're actually inside. You upload your code, it sits there doing nothing, and the moment someone hits your API, AWS runs it, handles the request, and then shuts it back down.
If zero people use your app, you pay zero dollars. If a million people suddenly show up, AWS handles spawning enough copies of your code to handle the load. It's the ultimate "set it and forget it" for infrastructure. But, it comes with one catch: Cold Starts.
The cold start problem is real
If you've spent any time with FaaS, you know the drill. Your code isn't always running. When someone hits your API, AWS has to wake it up. If you're using Java or even Node, that "waking up" process can take a few hundred milliseconds.
Rust doesn't have a virtual machine or a runtime to load. It's just a tiny binary that starts almost instantly. We're talking 10ms vs 500ms. It doesn't sound like much until you have a few functions talking to each other, and suddenly your "simple" API call takes 2 seconds to respond.
I'm tired of JS bundling
I love TypeScript, but setting it up for Lambda is a headache. You need a bundler like esbuild or webpack just to get your code into a single file. Then you have to worry about node_modules, layers, and making sure the runtime version matches what you tested locally.
With Rust, you just compile the code into a single binary. No node_modules, no layers, no "hidden" dependencies. You ship one file, and it just runs. It’s a lot cleaner when you start managing a real codebase.
Why not just use Python?
Python is great for writing scripts quickly, but it’s just not built for performance. If you're doing any heavy data work or need strict types, Python starts to feel a bit loose.
Rust's compiler is strict, but in a good way. It catches the bugs that usually end up causing a 500 error in production at 3 AM. Plus, it uses way less memory. Most of my Rust lambdas run comfortably in 128MB, while my Python ones usually need at least 256MB or 512MB to stay fast.
I've done the hard part for you
Look, this is my personal preference. I’m not saying you have to use Rust. I’m writing this series because I spent weeks banging my head against the wall trying to figure out the right way to set up SAM, handle cross-compilation, and get IAM permissions working without losing my mind.
I wanted to put this out there because I’ve simplified the process. I’ve figured out the boring parts so you can just focus on writing the actual logic. If you've been wanting to try Rust but were worried about the setup, I've got you covered. This isn't a "Hello World" that you'll throw away. We're going to build a production-ready API with proper error handling, shared libraries, and build automation.
You can find the full source code for this series on GitHub↗.
In the next post, I'll show you exactly what tools you need to install to get this running on your own machine.