๐๐ฒ๐'๐ ๐ฏ๐ฒ ๐ต๐ผ๐ป๐ฒ๐๐: generally, debugging is not a fun task ๐คข
Especially for serverless, event-driven & distributed systems.
From Lambda's logging basics to ๐๐ฎ๐๐ถ๐ป๐ด ๐๐ถ๐บ๐ฒ & ๐ป๐ฒ๐ฟ๐๐ฒ๐ โ
Lambda's a serverless technology provided by AWS.
But that ๐ฑ๐ผ๐ฒ๐๐ป'๐ ๐บ๐ฒ๐ฎ๐ป that there are no servers.
In the background, there are countless micro-containers running on top of the traditional servers.
Where do all the logs of those containers go to?
By default, they will end up in CloudWatch.
Every Lambda will receive its own ๐น๐ผ๐ด ๐ด๐ฟ๐ผ๐๐ฝ.
Like a repository for logs.
Not only that, every micro-container will create a new so-called ๐น๐ผ๐ด ๐๐๐ฟ๐ฒ๐ฎ๐บ.
Think of it as a text file where logs are written to.
As a micro-container can live several minutes and also serve dozens of requests in that live-time, there can be countless logs in a single stream.
If there are parallel requests, we're even having multiple log streams written in parallel!
You already see the problem: finding corresponding logs to your request in CloudWatch is cumbersome.
Even if you know the time window for your failed request, you need to browse all log streams.
Maybe the target log stream was created way before the failed request and contains endless other unrelated logs.
In addition, CloudWatch Console Interface is not very user-friendly. You can just load a short period of logs - scrolling up or down will load another small batch.
Before even starting to address the issue, you've maybe already spent 30 minutes.
So what's the solution?
We can make use of the ๐ฆ๐ง๐๐ฅ๐ง/๐๐ก๐ logs containing a dedicated request identifier (per invocation) and set up ๐๐ผ๐ด ๐๐ฟ๐ผ๐๐ฝ ๐ฆ๐๐ฏ๐๐ฐ๐ฟ๐ถ๐ฝ๐๐ถ๐ผ๐ป๐.
By subscribing ๐๐ถ๐ป๐ฒ๐๐ถ๐ to our log groups and configuring a Log Parser we'll get the logs and break them up into invocations
Finally, each piece of log related to one invocation can be saved individually in a database (such as CloudSearch) for later search and debugging.
You can build this yourself & try out other options like @thedashbird, where you get it out of the box ๐
Biased, as I'm dashbird's dev-๐ฅ & I'm using it for my own SaaS ๐
Also in the box:
โข well-architected hints
โข alerting (e.g. slack)
โข security warnings
... & more ๐
โข โข โข
Missing some Tweet in this thread? You can try to
force a refresh
It's managed, highly available & scales on-demand with low latencies.
For getting you hooked, at Prime Days 2021 DynamoDB served ๐ด๐ต.๐ฎ ๐บ๐ถ๐น๐น๐ถ๐ผ๐ป ๐ฟ๐ฒ๐พ๐๐ฒ๐๐๐/๐๐ฒ๐ฐ๐ผ๐ป๐ฑ at its peak.
I'm still in the early stages & already got a lot of lessons learned โ
๐๐ฎ๐๐ป๐ฐ๐ต ๐ฒ๐ฎ๐ฟ๐น๐
Maybe you've got another dozen ideas for features you think are needed for your MVP.
But until you've launched and you've got actual (paying) users, you've got no guarantee that your business case is even valid.
Intersects with the previous point: don't make the shinest code, with 100% code coverage and the perfect architecture, as it requires way too much effort.
Don't over or underdo it.
Make it work & manageable.
Guarantees to not miss out on new features or services, but also contains interesting statistics and other insights from AWS itself.
Gets updated very regularly, sometimes several times a day.
If you're focusing on keeping up with the new capabilities AWS provides, that's your major source.
You'll learn about improvements to existing services, introductions of new ones as well as region expansions.
A physical server, only utilized by you
โข you have to know or guess the CPU & memory capacities you need
โข high risk of overpaying (underutilized server) or under-provisioning (too much load)
โข you're able to run multiple apps, but need to make sure that you're not causing conflicts by resource sharing
โข you're solely responsible for the security
โข up- or downscaling is tedious & not quickly possible