<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Chronicles of a Cloud Engineer - Medium]]></title>
        <description><![CDATA[A Developer’s Journey Through AI, AWS, and Everything In-Between - Medium]]></description>
        <link>https://medium.com/chronicles-of-a-cloud-engineer?source=rss----d1f0f70df60b---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Chronicles of a Cloud Engineer - Medium</title>
            <link>https://medium.com/chronicles-of-a-cloud-engineer?source=rss----d1f0f70df60b---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 19:51:51 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/chronicles-of-a-cloud-engineer" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Honey, I Deleted the Production Glue Database!]]></title>
            <link>https://medium.com/chronicles-of-a-cloud-engineer/honey-i-deleted-the-production-glue-database-0283a8576a27?source=rss----d1f0f70df60b---4</link>
            <guid isPermaLink="false">https://medium.com/p/0283a8576a27</guid>
            <category><![CDATA[aws-glue]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[disaster-recovery]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Alaa Nassef]]></dc:creator>
            <pubDate>Thu, 12 Feb 2026 21:58:11 GMT</pubDate>
            <atom:updated>2026-02-12T21:58:13.290Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A7G08t-W7MaIz8OBvqO96Q.png" /></figure><blockquote>So, I deleted a prod Glue Database with data that we have been collecting for about a couple of years now, and this is, to say the least, kind of catastrophic.</blockquote><p>It was not an accident. I intentionally deleted the database. It was definitely not for any nefarious reasons, but it was a part an update I needed to make, but this has its own story.</p><h3>The Context</h3><p>I was tasked to create a disaster recovery run-book for our production and actually execute it to have a full process on how we can backup our data and restore it to a different AWS account/region and be fully up and running. This includes data from DynamoDB, Neptune and S3, amongst other things.</p><p>For Neptune, it should be quite easy. We just use AWS’s own <a href="https://docs.aws.amazon.com/neptune/latest/userguide/export-service.html">Neptune-Export Service</a>, which we already have deployed since forever, then copy the exported files to the other account/region, and restore there.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*rLHHL2pI0xzQYBWd.gif" /></figure><p>Well, in theory, yes. However, you need to understand how this service works. Basically, there’s an AWS Batch Job Definition which is a docker container with a java application that does the actual export. To expose this, there is a python lambda that takes your input and actually runs the batch job, and to make it RESTful, they put the lambda behind an API gateway. Now for this to be secure, the API gateway is a private one, and is exposed via a VPC endpoint. Now, why am I telling you all this? Well, I wanted to paint you a picture so that you can understand my feeling when I discovered that for some reason the VPC endpoint created by the Neptune-Export stack has been deleted by someone ages ago, hence, I can’t run the export service the way it was designed, unless I fix it. You might say, “simple, redeploy the stack”. NOPE! The VPC endpoint <strong><em>resource</em></strong> was deleted, but the CloudFormation stack itself has the resource defined, so redeploying, with the stack not changed will accomplish nothing.</p><p>OK, so let’s do a drift detection and fix. Perfect solution, but only if it worked. I don’t know whether the reason was that the stack is a wrapper for another stack that has 3 nested stacks, or whatever, but it just didn’t work and CloudFormation told me that everything is great and that there is no drift.</p><p>So the next logical step for me was to delete the nested stack that defines the VPC endpoint and redeploy, which is what I did. Problem is, redeployment failed, and now I’m left with a corrupted stack definition, and still no VPC endpoint. I clould of course create the VPC endpoint myself, but doing things manually is not the way we do things, and the stacks must always point to the truth, so the only option I was left with was to delete the whole stack, and redeploy it.</p><p>The only problem was, we used the security group created by the stack for some other stack, but that’s a different story.</p><h3>Back to What I Deleted</h3><p>Basically, we have a daily job that exports an incremental PITR snapshot of our main DynamoDB table with the changes made in the past 24 hours to S3, then we run an EMR job to create a temporary delta iceberg table in AWS Glue containing what was changed during the day, and finally, we merge that with our main iceberg glue table. This way, we can use SQL queries for our data, and we can use iceberg’s time travel queries to see what was changed over time if we want to.</p><p>So, what does Neptune Export’s security group has to do with this? Logically, absolutely nothing. However, in some PR made during the implementation of the above feature a year and a half ago, the security group for the EMR application was set to be the exact same one as the one defined by the Neptune Export, and it slipped through to production. And since the reource is being used by something outside the application, I can’t delete the Neptune Export stack, since it won’t be able to delete the security group because it’s in use. I’m left with two choices; fix the database exporter stack to remove the security group usage, or delete it and redeploy it. Of course, the sane thing to do for a production environment is the first option, but since I was traumatized by what the Duffer Brothers did with the Stranger Things Finale, I stopped caring about life and chose the latter option.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i5dmhm24sSGIzeNoT6vkeg.jpeg" /></figure><p>Joking aside, I didn’t fully know why the security group was used, and was under the impression that the DB exporter application was using Neptune somehow, so maybe it was needed the security group to be able to access Neptune. And since I was writing a disaster recovery run-book, what better time would be there to cause a disaster?</p><h3>The Big Delete</h3><p>Alright, so first things first. Number one, make sure that the S3 buckets containing the iceberg files are there: check. Number two, create backup S3 buckets with versioning, and sync the files to them: check. Number three, ensure that the files were synced correctly: check. Perfect, now we delete the DB exporter stack followed by the Neptune exporter one.</p><p>I didn’t do things in the above order TBH. I made sure of point one, deleted, then backed things up. When I was sure that I had all the data, I deleted the retained buckets, deployed the Neptune exporter stack, then deployed the DB exporter stack back. Now it’s time for the restore, and it should be easy.</p><p>What I did is a couple of simple <em>s3 mv</em> commands for both of our buckets to move close to 300 GBs of data. Then, I went to Athena to check that everything is back. They weren’t! The problem was simple, our glue table is created on the first full export, not as a part of the CloudFormation template. I created the table with the correct JSON schema, and pointed to the correct S3 location. Now let’s try the incremental export. It failed!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*9AVpK9r_UcebJFtGKFV8wQ.jpeg" /></figure><p>On this cold winter night, I started sweating. I started convincing myself that the moisture I feel in my pants are because of the sweat and nothing else. I do have the raw files, but the export function doesn’t work and Glue doesn’t actually see the data.</p><p>Let me try the full export. I’ll lose the history, but let’s get things working first, then worry about the history. I have the files after all. OOPS! Our full export script ensures that we have a clean state, which deletes the data I just moved, and our destination bucket does not have versioning! More sweat.</p><p>The good thing is that I ensured that the backup is in vact versioned, so I had to write a script to remove all the delete markers from the backup bucket, then do an <em>s3 sync</em> (no <em>s3 mv</em> this time, learned my lesson), then look into the problem a bit more deeply.</p><p>Turns out it was simple. If I try to edit the glue table, in the table properties I had to set the locations of the current and the previous metadata files, and since I had everything in S3, and the metadata file names are sequential, it was easy to set those up, and things started working</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iGNjcAGkDN4LQt0mE7tgFw.png" /></figure><p>So, with this fixed, I ran the incremental update(s) I missed during my adventure and it was a happy ending. Coming to think about it, it was a good thing since it gave me more experience, and it gave me a clearer scenario on what to do to back this thing up. Also, it humbled me a bit. Having too much confidence when messing around with production systems is really bad, so this was kind of important to get me back in line. Also, it gave me a fun story to tell.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0283a8576a27" width="1" height="1" alt=""><hr><p><a href="https://medium.com/chronicles-of-a-cloud-engineer/honey-i-deleted-the-production-glue-database-0283a8576a27">Honey, I Deleted the Production Glue Database!</a> was originally published in <a href="https://medium.com/chronicles-of-a-cloud-engineer">Chronicles of a Cloud Engineer</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Beyond the Big Three: DevOps, Security, Networking & Hybrid Innovations]]></title>
            <link>https://medium.com/chronicles-of-a-cloud-engineer/beyond-the-big-three-devops-security-networking-hybrid-innovations-6f3e38c09096?source=rss----d1f0f70df60b---4</link>
            <guid isPermaLink="false">https://medium.com/p/6f3e38c09096</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Alaa Nassef]]></dc:creator>
            <pubDate>Sat, 13 Dec 2025 19:31:42 GMT</pubDate>
            <atom:updated>2025-12-13T19:31:41.523Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>The devil is in the details. While headlines focus on big AI models and new chips, re:Invent 2025 quietly shipped features that will change how we design, secure and manage cloud systems.</blockquote><p>This final post rounds up announcements that did not fit neatly into AI or compute categories but are just as impactful.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P2iSxe8hMyIv4D52zgbbcA.jpeg" /></figure><h3>DevOps &amp; Developer Tools</h3><ul><li><strong>AWS DevOps Agent (Preview):</strong> An AI-powered on-call engineer that digests signals from CloudWatch, GitHub and ServiceNow to identify root causes and coordinate incident response.</li><li><strong>AWS Transform Custom &amp; Modernization:</strong> An agent that learns your codebase and performs large-scale code upgrades and tech debt tasks. Full-stack Windows modernization features can port Web Forms apps to Blazor and migrate SQL Server to Aurora Postgres.</li><li><strong>Route 53 Global Resolver (Preview):</strong> A globally distributed DNS resolver that simplifies managing private and public DNS across hybrid environments.</li><li><strong>Partner Central in AWS Console:</strong> Partners now get a first-class experience integrated into the AWS Management Console.</li></ul><h3>Security &amp; Compliance</h3><ul><li><strong>AWS Security Agent (Preview):</strong> An AI-driven application security tool that provides design reviews, code analysis and contextual penetration testing across an application’s lifecycle.</li><li><strong>Amazon GuardDuty Extended Threat Detection:</strong> Provides unified threat visibility across EC2 and ECS, making it easier to detect multi-stage attacks.</li><li><strong>AWS Security Hub (GA):</strong> Now generally available with near real-time analytics and improved risk prioritization.</li><li><strong>IAM Policy Autopilot:</strong> An open-source tool that uses AI to suggest least-privilege IAM policies based on your code.</li></ul><h3>Hybrid &amp; Global</h3><ul><li><strong>AWS AI Factories:</strong> A new offering that puts pre-integrated AI infrastructure in customers’ own data centers. It includes foundation models, specialized chips and management services, letting customers train and deploy AI on premises while complying with data-residency rules.</li><li><strong>AWS Support Plans with AI:</strong> Enhanced support tiers that combine human experts with AI insights for proactive guidance and faster response times.</li><li><strong>Amazon CloudWatch Unified Data Management:</strong> Brings together operational, security and compliance data with automatic normalization and support for open standards.</li><li><strong>Clean Rooms Synthetic Data Generation:</strong> A privacy-enhancing feature that synthesizes machine learning datasets without exposing real records.</li></ul><h3>Migration &amp; Mainframe</h3><ul><li><strong>AWS Transform for Mainframe:</strong> Adds “Reimagine” capabilities and automated testing to convert legacy mainframe applications into modern architectures.</li><li><strong>AWS Transform for Windows:</strong> Accelerates modernization of Windows apps end to end, moving from .NET Framework to newer versions and porting SQL Server to Aurora.</li></ul><h3>Final Thoughts</h3><p>These “everything else” announcements highlight how AWS is embedding AI into every layer of the stack, from on-call duties to policy generation. They also show AWS’s push toward hybrid and on-premises solutions, meeting customers where they are with AI Factories and integrated support. Paying attention to these quieter features can make day-to-day development smoother and more secure.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6f3e38c09096" width="1" height="1" alt=""><hr><p><a href="https://medium.com/chronicles-of-a-cloud-engineer/beyond-the-big-three-devops-security-networking-hybrid-innovations-6f3e38c09096">Beyond the Big Three: DevOps, Security, Networking &amp; Hybrid Innovations</a> was originally published in <a href="https://medium.com/chronicles-of-a-cloud-engineer">Chronicles of a Cloud Engineer</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Compute, Databases, Containers & Storage: Lower Costs, New Chips and Smarter Operations]]></title>
            <link>https://medium.com/chronicles-of-a-cloud-engineer/compute-databases-containers-storage-lower-costs-new-chips-and-smarter-operations-daff17a57511?source=rss----d1f0f70df60b---4</link>
            <guid isPermaLink="false">https://medium.com/p/daff17a57511</guid>
            <category><![CDATA[s3]]></category>
            <category><![CDATA[rds]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[ec2]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Alaa Nassef]]></dc:creator>
            <pubDate>Mon, 08 Dec 2025 19:37:00 GMT</pubDate>
            <atom:updated>2025-12-08T19:36:59.552Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>In the fight against cloud bills, every percent matters. AWS spent re:Invent 2025 talking about squeezing more performance per watt and more value per state transition.</blockquote><p>Where the AI announcements felt futuristic, the compute and data updates were about efficiency and choice. Here is what stood out.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G0BX0LV9qhEjjBtSNCUYyg.jpeg" /></figure><h3>Compute &amp; Chips</h3><ul><li><strong>Graviton 5 and M9g Instances:</strong> The fifth generation Graviton chip promises 25 % higher performance than its predecessor. If you are running Go, Java or containerized workloads, there is little reason not to benchmark it.</li><li><strong>Trainium 3 UltraServers:</strong> AWS’s first 3 nm chip powers EC2 Trn3 UltraServers. With 144 chips per system, these machines are designed for training large AI models at lower cost.</li><li><strong>Lambda Managed Instances:</strong> This new feature lets you run Lambda functions on dedicated EC2 capacity (even with custom hardware). This would allow you to optimized for your specific workload requirements, like high-bandwidth networking for data-intensive applications, without taking on the operational burden of managing Amazon EC2 infrastructure.</li><li><strong>Lambda Durable Functions:</strong> A feature that enables long-running workflows on Lambda without building a Step Function state machine. You can coordinate multi-step tasks, pause for events, and resume later without paying for idle time.</li><li><strong>EC2 X8aedz Instances:</strong> Memory-optimized machines with 3 TiB RAM and 5 GHz AMD EPYC processors; ideal for EDA workloads.</li></ul><h3>Databases &amp; Vector Stores</h3><ul><li><strong>Database Savings Plans:</strong> AWS is bringing Savings Plans to databases. Commit to a certain level of spend and receive discounts across RDS engines, Aurora, Neptune and even DocumentDB.</li><li><strong>RDS Enhancements:</strong> Support for SQL Server Developer Edition, new M7i and R7i instances with Optimized CPU, and storage scaling up to 256 TiB.</li><li><strong>OpenSearch Vector Improvements:</strong> GPU-accelerated vector search and auto-tuning deliver up to 10 × better performance at a quarter of the cost.</li><li><strong>S3 Vectors:</strong> As mentioned in <a href="https://medium.com/chronicles-of-a-cloud-engineer/ai-ml-at-re-invent-2025-a-new-frontier-of-models-and-agents-b703534abfb2">my previous post</a>, earlier, S3 now supports vector storage for similarity search.</li></ul><h3>Containers &amp; Orchestration</h3><ul><li><strong>EKS Enhanced Orchestration:</strong> Amazon EKS now offers fully managed workload placement and resource management. Less YAML, more reliability; especially useful for large clusters.</li><li><strong>Serverless–Container Crossovers:</strong> With Lambda Durable Functions and Managed Instances, the line between serverless and containers is blurring. Expect to see hybrid patterns in architectural diagrams next year.</li></ul><h3>Storage</h3><ul><li><strong>Amazon FSx for NetApp ONTAP with S3 Integration:</strong> You can access ONTAP file data through S3 APIs. This is useful for analytics or machine learning jobs that need POSIX files and object storage in one workflow.</li><li><strong>Amazon S3 Tables:</strong> Adds cross-region and cross-table replication along with Intelligent-Tiering for automatic cost optimization.</li><li><strong>S3 Storage Lens:</strong> Provides new metrics that scale to billions of prefixes and lets you export metrics directly into S3 Tables.</li></ul><h3>The Bigger Picture</h3><p>AWS is focusing on giving customers more performance per dollar. Whether it is moving to Graviton 5, using Trainium 3 for AI training or leveraging Database Savings Plans, cost efficiency is the underlying theme. Integration between file systems and object stores indicates AWS expects data pipelines to span multiple modalities seamlessly.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=daff17a57511" width="1" height="1" alt=""><hr><p><a href="https://medium.com/chronicles-of-a-cloud-engineer/compute-databases-containers-storage-lower-costs-new-chips-and-smarter-operations-daff17a57511">Compute, Databases, Containers &amp; Storage: Lower Costs, New Chips and Smarter Operations</a> was originally published in <a href="https://medium.com/chronicles-of-a-cloud-engineer">Chronicles of a Cloud Engineer</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AI & ML at re:Invent 2025: A New Frontier of Models and Agents]]></title>
            <link>https://medium.com/chronicles-of-a-cloud-engineer/ai-ml-at-re-invent-2025-a-new-frontier-of-models-and-agents-b703534abfb2?source=rss----d1f0f70df60b---4</link>
            <guid isPermaLink="false">https://medium.com/p/b703534abfb2</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[aws-reinvent-2025]]></category>
            <dc:creator><![CDATA[Alaa Nassef]]></dc:creator>
            <pubDate>Fri, 05 Dec 2025 18:41:16 GMT</pubDate>
            <atom:updated>2025-12-05T18:41:16.345Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>As engineers there are moments when you can feel the industry shift beneath your feet. re:Invent 2025 was one of those moments.</blockquote><p>The conversations surrounding this year’s conference all centered on the same theme: AI is no longer an add-on; it is the core of how we build. AWS responded with a barrage of announcements that make it clear they want to own the generative AI stack end to end.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xPEWKSv_aLQsPcRDWqxHWw.jpeg" /></figure><h3>Conversational Models Become Mainstream</h3><ul><li>Amazon Nova 2 Sonic: A speech-to-speech model that lets you build real-time conversational experiences. It supports multiple languages and can modulate tone on the fly.</li><li>Amazon Nova 2 Lite: A lighter reasoning model designed to be inexpensive and fast, yet it still supports a million-token context window.</li><li>Amazon Nova 2 Omni: Announced in preview, this is a true multimodal model that accepts text, images, video and speech, and outputs both text and images.</li></ul><p>These models are available through Bedrock, with pricing aimed at making adoption straightforward. Sonic handles telephony integration out of the box, indicating that AWS is targeting call-centre and enterprise voice markets directly.</p><h3>Build Your Own Frontier Model</h3><p>One announcement that could be game-changing is Amazon Nova Forge. It is a program that lets customers train their own “frontier models” on AWS infrastructure. Customers bring domain data and training objectives while AWS provides compute, optimization and orchestration. With high-end frontier models consuming hundreds of millions in training budget, this democratization could open the door for vertical-specific large language models.</p><h3>Agentic Frameworks Mature</h3><p>Building agents felt like the wild west last year. This re:Invent, AWS tried to bring order. They launched Amazon Nova Act, a new service for creating reliable browser-automation agents that can handle tasks like form filling, data extraction and online booking. This is complemented by Amazon Bedrock AgentCore, which now has quality evaluations and policy controls for safety and memory management. The lesson is that AWS wants agents to be reliable tools rather than academic experiments.</p><h3>Vector Storage Comes to S3</h3><p>Perhaps the most exciting release for everyday builders is Amazon S3 Vectors. Instead of spinning up a separate vector database, you can now store up to 2 billion vectors per index directly in S3 and perform similarity search with roughly 100 ms latency. AWS claims up to 90% cost savings compared with specialized vector databases. This will be appealing for teams working with embeddings.</p><h3>Smaller but Noteworthy Enhancements</h3><ul><li>Bedrock adds 18 new models (including Mistral Large 3).</li><li>Reinforcement Fine-Tuning for model customization boosts accuracy by around 66 % with less data.</li><li>SageMaker HyperPod and Serverless Fine-Tuning now support checkpoint-less training and elastic scaling.</li><li>Clean Rooms introduces synthetic data generation to create privacy-preserving training sets.</li></ul><h3>Why It Matters</h3><p>The key takeaway from re:Invent is that AWS is positioning itself as the place to build, train and deploy AI. If Nova’s quality catches up to OpenAI and Anthropic, Bedrock’s marketplace becomes a comprehensive shop for models. Tools like Nova Act and AgentCore suggest a future where anyone can spin up autonomous agents to automate workflows without being an AI expert.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b703534abfb2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/chronicles-of-a-cloud-engineer/ai-ml-at-re-invent-2025-a-new-frontier-of-models-and-agents-b703534abfb2">AI &amp; ML at re:Invent 2025: A New Frontier of Models and Agents</a> was originally published in <a href="https://medium.com/chronicles-of-a-cloud-engineer">Chronicles of a Cloud Engineer</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From $450 to $1 - Part 0.5: Intro to Step Function Activities]]></title>
            <link>https://medium.com/chronicles-of-a-cloud-engineer/from-450-to-1-part-0-5-intro-to-step-function-activities-2af295c4e89f?source=rss----d1f0f70df60b---4</link>
            <guid isPermaLink="false">https://medium.com/p/2af295c4e89f</guid>
            <category><![CDATA[aws-step-functions]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-ecs]]></category>
            <category><![CDATA[cost-optimization]]></category>
            <category><![CDATA[aws-cost-optimization]]></category>
            <dc:creator><![CDATA[Alaa Nassef]]></dc:creator>
            <pubDate>Sat, 15 Nov 2025 21:26:53 GMT</pubDate>
            <atom:updated>2025-11-15T21:26:53.334Z</atom:updated>
            <content:encoded><![CDATA[<h3>From $450 to $1: How We Slashed AWS Step Functions Costs with Activities (Part 0.5): Intro to Step Function Activities</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_QSLRUChSUj2tsr-kZMcjw.png" /></figure><h3>Recap &amp; Why Part 0.5</h3><p>I started this whole blog with a two part series about how we slashed the price of a single execution of an AWS step function from 450 USD to only 1 USD (check out parts <a href="https://medium.com/chronicles-of-a-cloud-engineer/from-450-to-1-how-we-slashed-aws-step-functions-costs-with-activities-part-1-23642db71a9d">1</a> and <a href="https://medium.com/chronicles-of-a-cloud-engineer/from-450-to-1-how-we-slashed-aws-step-functions-costs-with-activities-part-2-5f90c0dae3ba">2</a> if you’re interested). Our work resulting in this two-parter (now a three-parter) was originally inspired by <a href="https://x.com/edjgeek">Erick Johnson</a>’s talk titled <a href="https://www.youtube.com/watch?v=gdGgBKJiM2E"><em>Advanced Workflows with AWS Step Functions</em></a> from re:Invent 2025.</p><p>However, a good friend of mine told me that in those posts I did not go into the details about “What is an activity?”, “How to set it up?”, “What’s wrapped up in the ECS?”, “What will the cost of ECS be?” and similar questions. I intentionally didn’t have those as a part of the posts since they were going to make them much longer, but I do agree that this info might be very useful for some people, hence this post. And as for the numbering, I think that this should be considered as a prequel to the other two parts, but <strong>Part 0</strong> didn’t make much sense.</p><h3>Principles for cost-efficient orchestration</h3><p>Our story was rooted in a simple financial reality: <strong>you pay per state transition</strong>. Standard workflows <a href="https://aws.criticalcloud.ai/aws-step-functions-vs-lambda-workflow-automation-comparison/#:~:text=,has%20a%20steeper%20learning%20curve">cost roughly $0.025 per 1,000 transitions</a>, which doesn’t sound like much until you multiply it by hundreds of thousands of transitions per execution. The <a href="https://www.cloudzero.com/blog/aws-step-functions/#:~:text=Note%3A%20Step%20Functions%20pricing%20and,data%20transfer%20charges%20may%20apply">CloudZero guide</a> to Step Functions breaks down the cost model (free tier, Standard vs. Express workflows, cross‑region charges, retry costs, etc.) and provides a set of cost‑saving tips that are worth repeating:</p><ul><li><strong>Choose the right workflow type</strong>: Use Express for short, high‑volume jobs and Standard for long‑running or critical tasks. Mixing both can help you keep costs predictable.</li><li><strong>Limit retries:</strong> Exponential back‑off and sensible retry caps prevent runaway loops from inflating your bill.</li><li><strong>Monitor costs and performance:</strong> Track transitions and execution time via CloudWatch or Cost Explorer. Understand which part of the state machine is expensive and why.</li><li><strong>Reduce transitions:</strong> Combine simple steps and use intrinsic functions instead of extra Lambda calls. Every transition counts.</li><li><strong>Keep workflows in one region:</strong> Cross‑region calls can introduce data‑transfer fees.</li><li><strong>Avoid moving large payloads:</strong> Store big data in S3 and pass a pointer rather than huge objects.</li><li><strong>Use inline maps for small loops:</strong> The Distributed Map state charges per child workflow, so inline loops are cheaper for lightweight iterations.</li></ul><p>These principles, specifically the <strong>Reduce Transitions</strong> one guided our redesign. We didn’t eliminate the need for loops; we moved the costly shard‑processing loop outside of Step Functions so that each shard could be processed without incurring a state transition. Your workloads may differ, but the goal is the same: <strong>minimise transitions and evaluate where the work should run</strong>.</p><h3>The why and how of Activities</h3><p><strong>Activities</strong> are the unsung heroes of Step Functions. An activity represents a unit of work performed by a worker you manage (for example, an ECS task, container, EC2 instance, or even an on‑premises server). Instead of invoking a Lambda function or an AWS SDK integration directly from your state machine, you <strong>send a task token to the activity</strong>; your worker polls the Step Functions API for new tasks, does the work, and calls back when it’s done. Because the heavy lifting happens outside of Step Functions, you avoid paying for state transitions inside the loop and gain full control over how the work is executed.</p><p>In our use case, the inner Map state originally ran a DynamoDB query for each of 256 shards. Replacing that loop with a single process‑all‑shards‑activity state allowed us to process all shards in an ECS task. We still needed to handle autoscaling and backlog detection (see part 2), but moving the loop outside the state machine <a href="https://medium.com/chronicles-of-a-cloud-engineer/from-450-to-1-how-we-slashed-aws-step-functions-costs-with-activities-part-2-5f90c0dae3ba"><strong>reduced transitions by a factor of 256</strong></a>.</p><p>When using activities, keep these points in mind:</p><ul><li><strong>Long‑running tasks:</strong> Activities are ideal for tasks that might exceed the 15‑minute limit of Lambda.</li><li><strong>Scaling workers:</strong> You control how many workers poll the activity, so think about throughput and downstream limits (DynamoDB provisioned capacity, API rate limits, etc.).</li><li><strong>Monitoring:</strong> CloudWatch publishes metrics like ActivitiesScheduled, ActivitiesSucceeded, ActivitiesFailed and ActivityScheduleTime (the time an activity stays in the schedule queue). Unfortunately, none of these directly report the backlog size; that’s why part 2 <a href="https://medium.com/chronicles-of-a-cloud-engineer/from-450-to-1-how-we-slashed-aws-step-functions-costs-with-activities-part-2-5f90c0dae3ba#:~:text=Using%20ActivityScheduleTime">described</a> using ActivityScheduleTime as a proxy and manually scaling the ECS service when the queue backed up.</li><li><strong>Testing:</strong> Note that the <a href="https://builder.aws.com/content/2ba4EVjZB3VDb7beebiSdCXhzCc/elevating-orchestration-navigating-aws-step-functions-latest-features">new Test API</a> currently <strong>does not support Task states that use activities</strong>. You still need to write integration tests for your worker code.</li></ul><p>Activities shine when you have heavy loops or long‑running work that doesn’t belong in your state machine. They’re not a silver bullet, but they give you another tool for balancing cost, observability and control.</p><h3>So, What’s an Activity anyway?</h3><p>In Step Functions, an <strong>activity</strong> is just a task that you run yourself. Instead of invoking a Lambda function or a built‑in service integration, you create an activity resource and then write an <em>activity worker</em> that polls Step Functions for work. When the state machine reaches the corresponding Task state, it schedules the work and waits for a worker to pick it up. The worker calls the GetActivityTask API to retrieve the task’s input and a taskToken, performs the work somewhere outside Step Functions, and then calls SendTaskSuccess, SendTaskFailure or SendTaskHeartbeat to report progress and completion. Because you control the runtime environment, an ECS task, EC2 instance, on‑premises server or even a mobile device, activities can run for hours, use any language, and access local resources. The trade‑off is that you must manage the workers yourself and <a href="https://boto3.amazonaws.com/v1/documentation/api/1.26.1/reference/services/stepfunctions.html#:~:text=Activities%20must%20poll%20Step%20Functions,when%20polling%20from%20the%20activity">instrument them to poll and callback</a>, but in return you avoid paying for a state transition on every iteration of your loop.</p><h3>How to set it up?</h3><p>Setting up an activity involves three pieces: defining the activity, referencing it in your state machine, and running an activity worker.</p><ul><li><strong>Defining the activity:</strong> You must create activities before using them. To do this, you have the Step Functions console (shown below), the AWS CLI (e.g. running aws stepfunctions create-activity --name process-all-shards-activity which should return an ARN like arn:aws:states:us-east-1:123456789012:activity:process-all-shards-activity) and the <a href="https://docs.aws.amazon.com/step-functions/latest/apireference/API_CreateActivity.html">CreateActivity API</a>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DyEy4RgCbez-FzB8XigCVw.png" /></figure><ul><li><strong>Referencing in state machine: </strong>In your Amazon States Language definition, add a Task state whose Resource is the activity ARN. Set HeartbeatSeconds and TimeoutSeconds to reflect how long the worker should take once it polls it. For example:</li></ul><pre>{<br>  &quot;Type&quot;: &quot;Task&quot;,<br>  &quot;Resource&quot;: &quot;arn:aws:states:...:activity:process-all-shards-activity&quot;,<br>  &quot;HeartbeatSeconds&quot;: 300,<br>  &quot;TimeoutSeconds&quot;: 900,<br>  &quot;Next&quot;: &quot;NextState&quot;<br>}</pre><ul><li><strong>Running the worker:</strong> Basically, you need some process to keep polling the <a href="https://docs.aws.amazon.com/step-functions/latest/apireference/API_GetActivityTask.html">GetActivityTask</a> API (using long polling of course) passing the activity ARN to it to get any activity task that is triggered. If there is any task, the response will come back the input that was sent to the task, and a task token that you would need to periodically <a href="https://docs.aws.amazon.com/step-functions/latest/apireference/API_SendTaskHeartbeat.html">SendTaskHeartbeat</a> so that Step Functions knows the worker is alive, and to report success or failure after performing the business logic using <a href="https://docs.aws.amazon.com/step-functions/latest/apireference/API_SendTaskSuccess.html">SendTaskSuccess</a> and <a href="https://docs.aws.amazon.com/step-functions/latest/apireference/API_SendTaskFailure.html">SendTaskFailure</a>.</li></ul><p>All you need to do after building up the worker is to deploy it by packageing your worker and running it on ECS/Fargate, Kubernetes, EC2 or any environment you control. We used an ECS service with one task per activity; autoscaling policies scale up when the ActivityScheduleTime metric indicates a backlog (see <a href="https://medium.com/chronicles-of-a-cloud-engineer/from-450-to-1-how-we-slashed-aws-step-functions-costs-with-activities-part-2-5f90c0dae3ba">part 2</a>). Because the worker polls Step Functions, there is no risk of losing tasks if no worker is available, tasks remain queued until a worker retrieves them.</p><h3>OK, so what’s wrapped in the ECS task?</h3><p>The magic of our cost reduction wasn’t the activity itself. It was <strong>what we put inside the worker</strong>. Th original design had a Map state that looped over 256 DynamoDB shards and ran the same query for each shard. That loop is what drove our state‑transition count through the roof. In the refactored design we moved the entire loop into an ECS task. The activity worker’s main loop looks roughly like this (simplified):</p><pre>while True:<br>    task = sfn.get_activity_task(activityArn=ACTIVITY_ARN, workerName=&quot;ecs-worker&quot;)<br>    if not task or &quot;taskToken&quot; not in task:<br>        time.sleep(5)<br>        continue<br><br>    plan_id = json.loads(task[&quot;input&quot;])[&quot;plan_id&quot;]<br>    # Process all shards for this plan_id<br>    aggregated = {}<br>    for shard in range(0, 256):<br>        counts = query_dynamodb(plan_id, shard)<br>        merge_into(aggregated, counts)<br><br>    sfn.send_task_success(taskToken=task[&quot;taskToken&quot;], output=json.dumps(aggregated))</pre><p>This worker <strong>does exactly what the inner </strong><strong>Map used to do</strong>, but it does so inside a single process. It iterates through every shard, queries DynamoDB, aggregates the results, and returns the combined output to the Step Function. Because there’s no Map state involved, Step Functions sees only one state transition instead of 256 multiplied by all of the states inside this map. You also need to note that each block is not a single state change, but is three (started, processed and ended), so that’s a lot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/876/1*ubNGP24y8NObm36bNBikVQ.png" /></figure><p>We also send periodic heartbeat calls if the loop takes more than a few minutes to ensure the step doesn’t time out. Any exceptions result in a call to SendTaskFailure, allowing the Step Function to catch the error and route to the appropriate recovery branch.</p><p>Packaging this code as a container means we can reuse existing libraries, run it for as long as we need, and take advantage of ECS/Fargate’s autoscaling features. If throughput becomes an issue, we can spin up multiple worker tasks; Step Functions will distribute incoming jobs among them via GetActivityTask.</p><h3>That’s all good, but what will the cost of ECS be?</h3><p>Moving work out of Step Functions doesn’t make it free, you still pay for the compute resources that run your container. The good news is that ECS itself has <strong>no service charge</strong>; you only pay for the resources your workload consumes. When you run on the Fargate launch type, AWS bills by the second (with a one‑minute minimum) based on the vCPU and memory allocated to each task. <a href="https://www.microtica.com/blog/ecs-pricing-guide#:~:text=%240.04048%2FvCPU,off%20Fargate">As of late 2025</a>, Fargate in the us‑east‑2 region costs about <strong>$0.04048 per vCPU‑hour and $0.004445 per GB‑hour</strong>. Running a task with 1 vCPU and 2 GB of memory for 10 minutes therefore costs roughly:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/966/1*JL-VNy5lxwopo8Kx2T37Xw.png" /></figure><p>So taking into consideration that we are using a 0.25 vCPU and 0.5 GB of RAM, the cost of ECS is really negligible. Not just that, but our organization has compute reserved capacity <strong>AND</strong> savings plan, so it’s practically free for our load.</p><p>If you’re looking for even more cost reduction, Fargate Spot can reduce these costs by <a href="https://www.cloudzero.com/blog/fargate-cost/#:~:text=per%20vCPU%20per%20hour">up to 70%</a> in exchange for potential interruptions, making it attractive for non‑critical or retryable workloads. Alternatively, you can use EC2 launch types with reserved or spot instances depending on your needs.</p><p>In our case, the ECS costs were so small compared to the original Step Functions bill that we didn’t bother with Spot. The key takeaway is that <strong>pay‑per‑transition quickly dwarfs pay‑per‑compute</strong> for heavily looped workloads. By shifting the loop into a container, we trade hundreds of thousands of transitions for a few minutes of compute time, and the result is a bill that dropped from <strong>$450</strong> to roughly <strong>$1</strong> per run.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2af295c4e89f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/chronicles-of-a-cloud-engineer/from-450-to-1-part-0-5-intro-to-step-function-activities-2af295c4e89f">From $450 to $1 - Part 0.5: Intro to Step Function Activities</a> was originally published in <a href="https://medium.com/chronicles-of-a-cloud-engineer">Chronicles of a Cloud Engineer</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DPE Summit 2025 Videos Are Out]]></title>
            <link>https://medium.com/chronicles-of-a-cloud-engineer/dpe-summit-2025-videos-are-out-28ee2c59b92e?source=rss----d1f0f70df60b---4</link>
            <guid isPermaLink="false">https://medium.com/p/28ee2c59b92e</guid>
            <category><![CDATA[developer-experience]]></category>
            <category><![CDATA[developer-productivity]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Alaa Nassef]]></dc:creator>
            <pubDate>Sun, 09 Nov 2025 19:31:01 GMT</pubDate>
            <atom:updated>2025-11-09T19:31:01.752Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZAeQoNbiJnfiyxlPPboZGw.jpeg" /></figure><p>I mentioned a <a href="https://medium.com/chronicles-of-a-cloud-engineer/dpe-summit-2025-thoughts-c80f2cb633de">few weeks back</a> that I have attended Gradle’s Developer Productivity Engineering Summit 2025 and my thoughts about it. They started posting the videos about a month ago on their youtube channel, and I was waiting for them to finish uploading everyhing to share here. They finished uploading their daily videos more than a week ago, but I was waiting for them to share Elis Paradis’s session, which was one of the best in the whole event. Unfortunately, they did not publish this video, but I’m still hopeful. Anyway, I created a <a href="https://www.youtube.com/watch?v=VOXNJ9_sHuM&amp;list=PL4noKCE4oaVGxtF91ebAs7gDqgsD8Z5Yq">youtube playlist</a> in the order of the uploads in case you’re interested in watching them (some of them are really great). And now, I leave you with the keynote by Gradle’s own founder and CEO, which was also a very great and useful session.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FVOXNJ9_sHuM%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DVOXNJ9_sHuM&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FVOXNJ9_sHuM%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/5f4efcbdd65d178864858acb8b50224e/href">https://medium.com/media/5f4efcbdd65d178864858acb8b50224e/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=28ee2c59b92e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/chronicles-of-a-cloud-engineer/dpe-summit-2025-videos-are-out-28ee2c59b92e">DPE Summit 2025 Videos Are Out</a> was originally published in <a href="https://medium.com/chronicles-of-a-cloud-engineer">Chronicles of a Cloud Engineer</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How we reduced our DynamoDb costs by 86% with a couple of simple changes]]></title>
            <link>https://medium.com/chronicles-of-a-cloud-engineer/how-we-reduced-our-dynamodb-costs-by-86-with-a-couple-of-simple-changes-c2fc5e884c52?source=rss----d1f0f70df60b---4</link>
            <guid isPermaLink="false">https://medium.com/p/c2fc5e884c52</guid>
            <category><![CDATA[cost-reduction]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[dynamodb]]></category>
            <category><![CDATA[aws-cost-reduction]]></category>
            <dc:creator><![CDATA[Alaa Nassef]]></dc:creator>
            <pubDate>Sun, 26 Oct 2025 09:47:27 GMT</pubDate>
            <atom:updated>2025-10-26T09:47:26.978Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*138WbJag6BFKei-r5Lp2XQ.png" /></figure><h3>Introduction</h3><p>Back in 2021, our project was still in its infancy. A 5G telecommunications online charging system that is a multi-tenant SaaS! This was unheard of. This is why it was extremely important to be in MWC Barcelona to do banging demos to show that this is possible, and that our engine can withstand huge traffic from multiple regions.</p><p>Being multi-region was really important to our business leaders, because their vision is to be able to serve the whole world’s charging traffic with very low latency, so it was crucial to be able to demo that. So, one of the decisions made by the business technical team was, we’ll use <a href="https://aws.amazon.com/dynamodb/global-tables/">Global Tables</a> for DynamoDB.</p><p>For them, this was a clear choice. For the lowest latency, we had to have an offering in the region closest to the client, and the DynamoDb had to be in the same region for low latency. So for multi-region support, if we want to share the data and have very low latency in each region, Global Tables was the choice. And this was really important to show in our demos, but running loads on the same datasets from multiple regions and show that not only can our system handle a million transactions per second, but it can do that with a very low latency.</p><h3>So what is “Global Tables” anyway?</h3><p>In short, <strong>Amazon DynamoDB Global Tables</strong> let you deploy a single DynamoDB table that spans multiple AWS Regions. Instead of managing your own data replication or dealing with cross-region latency, you define which Regions should host replicas, and DynamoDB handles the rest automatically.</p><p>Each Region gets its own <strong>replica table</strong> that shares the same name and primary key structure. When data is written to any replica, DynamoDB asynchronously replicates that change to every other Region, usually within a second or two. This design gives you <strong>multi-active</strong> behavior, meaning all replicas can accept both reads and writes at the same time.</p><p>From an application perspective, you simply connect to the local Region endpoint. Reads and writes happen locally for low latency, while DynamoDB ensures the data eventually (or immediately, if you enable strong consistency) becomes consistent across all Regions. Conflict handling is built in: if two Regions modify the same item, DynamoDB applies a <strong>last-writer-wins</strong> rule or, for strong consistency, throws a retryable exception to let your application handle it safely.</p><p>Global Tables are ideal for globally distributed systems that need sub-10-millisecond local access and automatic failover without manual replication logic. They integrate with existing DynamoDB APIs and tools, so you can scale across Regions with minimal code changes and maximum resilience.</p><h3>Why are we spending 16K USD a day?</h3><p>This was a question sent by our head of engineering to my manager. This was a few weeks after MWC was wrapped up, so we were not doing the one million TPS anymore (but we were still simulating some large traffic). The number was quite shocking to be honest, so we needed to investigate, and so I did.</p><p>First thing I did was to get our AWS bill for June, and here’s the snapshot of our AWS costs. Notice something?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YuJPSVx6aT0BK-JPwRE0DA.png" /></figure><p>Our DDB costs before our EDP Discounts was around 394K USD, and the replication cost alone was more than 330K USD! That was 83.9% of our DDB costs JUST for the replication.</p><p>My manager was shocked, and wanted to get back to AWS support to ask if this is real, but I assured him that this does make sense, and the question is, do we really need the replication.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0Z5oYyHAn6wv_aZgUjWx9w.png" /></figure><p>Well, since this was a business decision, we had to go back to our business unit for the decision, and once they saw the numbers, it was a no brainer. Our multi-tenant solution will only be served from a single region, and if we need multiple regions, those regions will be independent. If at any time we get a customer who wants to have a multi-region deployment, we can spin that up for them, but those customers would need to cover the replication costs. And so, with just a simple decision, we just slashed 84% off our DDB costs.</p><h3>More cost reduction</h3><p>You might have noticed in the invoice snapshot that each region had 2 main sections for read/write costs, one for provisioned and another for on-demand. Well, our solution was making use of four DynamoDB tables, and some of them were configured to be on-demand. The problem is, on-demand tables pricing, back at the time was around 5–10 times more than provisioned, so by calculating our actual needs and using provisioned auto-scaling, we could shed off another 10K USD for the same traffic, which is another 2.6% of our ridiculously high invoice, or about 16% from the remaining cost.</p><p>Other than the technical decisions that reduced 86% of our ridiculous costs, there were a few more business decisions that were made to reduce the cost further, like reducing the simulated traffic to maybe 10% which reduced our DDB costs even more, reduced the number of EC2 instances and load balancers we needed and so on. Another decision was to buy an annual Gatling license instead of paying the much higher premium price for the Amazon Marketplace option. And finally, we decided that we don’t currently need the EU region, so that also removed a big chunk of our costs. All in all, I believe that we have reduced our costs there by 95 to 99%, but the first 84% was simply the decision to remove global tables.</p><h3>Current Pricing</h3><p>Thankfully, in <a href="https://aws.amazon.com/blogs/database/new-amazon-dynamodb-lowers-pricing-for-on-demand-throughput-and-global-tables/">November 2024</a>, AWS reduced the on-demand pricing by 50% and global tables price by up to 67%. However, this is still too much to pay if there is no real business need, e.g. the need for disaster recovery where both the RTO (Recovery Time Objective) and RPO (Recovery Point Objective) is a few seconds. In my opinion, other than extreme DR objectives, for most other problems Global Tables is not the solution (at least not out of the box).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c2fc5e884c52" width="1" height="1" alt=""><hr><p><a href="https://medium.com/chronicles-of-a-cloud-engineer/how-we-reduced-our-dynamodb-costs-by-86-with-a-couple-of-simple-changes-c2fc5e884c52">How we reduced our DynamoDb costs by 86% with a couple of simple changes</a> was originally published in <a href="https://medium.com/chronicles-of-a-cloud-engineer">Chronicles of a Cloud Engineer</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Randomization is a B***ch]]></title>
            <link>https://medium.com/chronicles-of-a-cloud-engineer/randomization-is-a-b-ch-644b9dec2c40?source=rss----d1f0f70df60b---4</link>
            <guid isPermaLink="false">https://medium.com/p/644b9dec2c40</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[debugging]]></category>
            <category><![CDATA[randomization]]></category>
            <category><![CDATA[software-design]]></category>
            <dc:creator><![CDATA[Alaa Nassef]]></dc:creator>
            <pubDate>Fri, 17 Oct 2025 09:01:56 GMT</pubDate>
            <atom:updated>2025-10-17T09:01:56.142Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>On the 22nd of August 2025, my son, my nephews and me went on a star gazing trip in Egypt’s amazing western desert, along with the incredibly experienced <a href="https://www.instagram.com/mahmoudmarai1?igsh=MWJ6bWVjNW1yaXB4MQ==">Mahmoud Marai</a> to witness the <a href="https://en.wikipedia.org/wiki/Perseids">Perseids meteor showers</a>. Yes, it was far from the peak of the showers, but with the moonless night, star gazing would be amazing, and the meteors were going to be really easy to see, not to mention the clear view of the Milky Way.</p><p>After a fun day in the desert, watching the sunset, and having a really nice barbecue, it was time to turn off all lights and fire, and enjoy the stars and the meteors. The only annoyance for me was the gasping of the others and shouting “WOW! Did you see this last one?”, while I was looking at a totally different direction to totally miss some meteors. It’s not that I didn’t get to see any meteors; on the contrary, I saw plenty. The nuisance was that I don’t know where the next one going to show up, and totally missing some parts of that great show. It was totally random!</p><p>This got me thinking about another major annoyance I faced just one week before, also caused by randomization, but that time it was totally man made.</p><h3>Confusion</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LnioZgKqLmHpzKW9T0J2wg.jpeg" /></figure><p>It all started on August 12th when we received a customer bug explaining that plan renewal was not working with her test plan and test account. To give you more context, in case you haven’t read my previous posts, I’m working on a multi-tenant charging system for telecommunication providers. This means that we manage all accounts subscriptions to plans, including plan renewals and all. Now, for plans to renew, we need two things: a scheduler that looks for subscriptions that need to renew and an on-the-fly renewal flow in case a charge request comes in after the renewal time but before the scheduler actually renews the subscription.</p><p>For a system that’s as large as ours with tens of millions of accounts that are subscribed to different on different times, this is not an easy feat, especially that we want to be precise by the second. Yes, on-the-fly renewals do work, but that’s a safety net. Imagine someone on an hourly plan who shuts down his phone for a week. We need to be able to charge for the renewal every hour without actual charging requests via his usage to come in.</p><p>The way we implemented this was simple. We have a recurring jobs DynamoDB table with the provider ID and a random shard as the partition key, and the renewal time down to the nanosecond level as the sort key. We have a process that queries all providers amongst all shards for records with the sort key before a time in the future, and for each one we send to an SQS queue with a delay for the messages to be visible at exactly the renewal time, and delete the record. On the other end, we have the system that does the actual renewal which polls for messages and when one comes, it renews the subscription and creates a new record for the next renewal. Pretty straightforward.</p><p>Then, we get this bug report where the customer created an hourly test plan and a test account that subscribed to this plan and waited. For a full day, the plan was not renewed!</p><p>The first thing we do in such things is to create an integration test to duplicate the customer behavior which should fail, then we debug to find the root cause. So, we wrote a test that would create an hourly plan exactly like the customer’s, an account with similar attributes. subscribe the account, then, to not wait for an hour, we call an internal non-exposed endpoint that would make our system poll all jobs for a specific account before a date we set (an hour in the future) to send the SQS message without any visibility delay. And BOOM! The test succeeded without failure!!</p><p>I went back to the customer support’s reproduction of the issue before they sent it to engineering, and they did reproduce it. However, when I looked into the event data records, the plan did renew once or twice, then stopped, and there were no more jobs for it to renew again. OK, then it’s kind of intermittent, so let’s change our test to do the renewal an hour after another for a few times until it fails. Well, we repeated the renewal 2, 3 and even 10 times. It renewed just fine!</p><h3>Clarity</h3><p>Something was clearly wrong with our test. We did everything the customer and the support team did, EXCEPT for waiting the full hour and instead using our internal endpoint that we created specifically for integration testing, which means that we can’t rely on that endpoint. The other thing is that it was clear that the bug is intermittent, so we need to find a pattern to figure out when and why it fails.</p><p>So what should be the next step? The obvious answer was logging. Tons of logs need to be added at every step of the logic to see where does the execution of the renewal stop, and see every value of every variable in the flow. And man this was a pain! The addition of the log statements was not a big deal, since it’s just telling the AI agent to add the messages in a specific format in the whole flow, but when the flow is really complex with so many branches, and you have to wait for the deployment update to run the first part of the integration test to get the data ready, then wait for hours for the renewal to fail to check the logs, then <strong>IT IS A PAIN!</strong> And when you discover that you have missed a few branches, and even with all the logs, the pattern is not really clear, it becomes unbearable.</p><p>So, a couple of days of adding logs, deploying, running the test, waiting for hours (since the smallest plan period unit we support is in hours and not minutes), and we finally had a few failed renewals that we could use to see the pattern.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SNs06069iQ5tz9GUVa_p9g.jpeg" /></figure><p>The first few fails were always the same. The plan would renew 2 times and fail on the third, but then we had one that failed on the second, and one on the first. Again, randomness was key, but there was a pattern. Let me show you example timestamps of the renewals</p><pre>2025-08-14T12:00:18.198732835Z<br>2025-08-14T13:00:18.487329296Z<br>2025-08-14T14:00:18.721785106Z<br>2025-08-14T14:00:18.378623603Z &lt;--- THIS FAILS RENEWAL<br><br>2025-08-14T15:30:11.438908682Z<br>2025-08-14T16:30:11.726983370Z<br>2025-08-14T17:30:11.873262581Z<br>2025-08-14T17:30:12.076723108Z<br>2025-08-14T18:30:11.686282073Z &lt;--- THIS FAILS RENEWAL<br><br>2025-08-15T09:42:17.562083739Z<br>2025-08-15T10:42:17.386282403Z &lt;--- THIS FAILS RENEWAL</pre><p>Did you notice it? For this hourly plan, the failed job was always a few milliseconds before the exact end of the hour of the plan, while the successful renewals were always after the end of that hour. Now all we needed to know is why this happens.</p><p>So, do you remember when I mentioned the following?</p><blockquote>We have a recurring jobs DynamoDB table with the provider ID and a random shard as the partition key, and the renewal time down to the nanosecond level as the sort key.</blockquote><p>Turns out that we only need the renewal date at the seconds level, and we only need the nanoseconds part for uniqueness of the sort key. It also turned out that the nanosecond part we use in the sort key is randomized when we generate the new job.</p><h3>Epiphany</h3><p>So, the reason for the randomization was to reduce the probability of key conflicts. I mean, imagine a large telecom provider with 100M subscribers, with more than half of them subscribed to a monthly plan that renews at midnight of the middle of the night. We’ll end up with sort keys all for the same day at 00:00:00 with only the nano part different, and with so many EC2 instances running in parallel, all of them trying to schedule the jobs at the same time, there is a possibility (albeit being low) that we might get two jobs at the exact nanosecond. The sharding of the partition key (primarily done to reduce hot partitions) would reduce the possibility even further, but someone decided that randomizing the nanoseconds part would reduce the chance of conflict even further to make it practically impossible to have key collisions.</p><p>The main problem with the logic we had was that we were <strong>ALWAYS</strong> regenerating the random nanoseconds part on every renewal, not just at the subscription creation time, which means that we would definitely run into the case where the actual renewal time (job processing time) might be a little bit before the calculated renewal time (previous renewal time plus period). “And why would this be a problem?” you might ask. Well, since we do have an on-the-fly renewal, we always check the invocation timestamp of the event we are getting before we do any actual plan renewals, and if that time is before the calculated renewal time, we skip the whole plan renewal workflow, since it’s not time yet to renew the plan. And even though I did say that we don’t <em>need</em> the nanosecond accuracy for the plan renewal, we do need it for the charging and other parts of the system, so we had to keep it in the invocation time.</p><p>And why did our integration tests fail to find this? Well, because our internal non-exposed endpoint takes a time to poll the jobs that should be executed before it, so naturally, our IT was written to always set that time after the time expected renewal time, ending up with setting the invocation time to be a few seconds in the future of the renewal time.</p><p>The learned lesson from this? <strong>Use randomization sparingly!</strong> Randomization is a great tool for many use cases, like encryption, generating a one-time password, or in our case when you’re choosing which shard to put the record into; maybe even the nanoseconds part of the sort key. However, for our case, once a shard and nanoseconds part were chosen, there is no need to do that randomization again on every renewal. Adding randomization to your logic is a key ingredient in getting random bugs, so unless there is a strong business need for it, do not use it, and when you have to, <strong>ONLY</strong> use it when necessary.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SmiE0Gk1DJsInZQ8gcK_mA.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=644b9dec2c40" width="1" height="1" alt=""><hr><p><a href="https://medium.com/chronicles-of-a-cloud-engineer/randomization-is-a-b-ch-644b9dec2c40">Randomization is a B***ch</a> was originally published in <a href="https://medium.com/chronicles-of-a-cloud-engineer">Chronicles of a Cloud Engineer</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DPE Summit 2025 Thoughts]]></title>
            <link>https://medium.com/chronicles-of-a-cloud-engineer/dpe-summit-2025-thoughts-c80f2cb633de?source=rss----d1f0f70df60b---4</link>
            <guid isPermaLink="false">https://medium.com/p/c80f2cb633de</guid>
            <category><![CDATA[gradle]]></category>
            <category><![CDATA[developer-experience]]></category>
            <category><![CDATA[ai-productivity]]></category>
            <category><![CDATA[developer-productivity]]></category>
            <dc:creator><![CDATA[Alaa Nassef]]></dc:creator>
            <pubDate>Sat, 11 Oct 2025 13:07:45 GMT</pubDate>
            <atom:updated>2025-10-11T13:07:45.303Z</atom:updated>
            <content:encoded><![CDATA[<p>A couple of weeks ago I had the pleasure of attending Gradle’s annual <a href="https://dpe.org/dpe-summit/">DPE Summit</a>, and to tell you the truth, I really loved it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MZ3uaeV7x3ig1Uw3sE_fOw.jpeg" /></figure><p>In case you’ve never heard of it, DPE summit is a convention focusing on Developer Productivity Engineering (and also Developer Experience) that is hosted by Gradle and takes place in San Francisco during late September of each year. There are always remarkable speakers from the likes of Netflix, Uber, Meta, Microsoft, Google and much more, sharing a lot of their learned lessons and knowledge related to developer productivity and experience.</p><h3>So, what exactly is it?</h3><p>Well, there are two tracks running in parallel, each having eight to 10 talks each day (some are about an hour long, and some are lightning 15 minutes presentations). The talks can be categorized in one of four areas in my opinion:</p><ul><li>Research done on productivity</li><li>Processes employed by organizations to help measure and boost productivity</li><li>Specific examples on tools/code changes made to boost productivity</li><li>Misc talks about tools/products and their features</li></ul><p>So, from Okta sharing what they did to reduce the build time (without testing) from 25 minutes to 2.5 to Google Research on how might we improve the impact of AI on developer productivity, there’s a broad scope where you’ll find something you’ll learn from.</p><p>Of course not every session was a bang, for example there was a session by JP Morgan titled “Reimagining CI/CD with Agentic AI: The Future of Platform Engineering in Financial Institutions”, where what they presented was just what they <strong><em>want</em></strong> to implement, with no real life success story, but in general, most of the sessions were beneficial.</p><h3>AI and Productivity</h3><p>Well, we’re in 2025, so if people don’t talk about AI in a convention about developer productivity, they will be deemed heretics by the AI gods, and pitchforks will be raised. So, as expected, AI was strongly present in the convention. However, it was not the typical “AI is the best invention since sliced bread”, but it was more of a realistic presentation, with what might look on the surface as conflicting messaging.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-9fSP8gOu8ZdemPCdXHqow.jpeg" /></figure><p>So, on one hand, we hear from the likes of Meta on how AI code generation have boosted productivity a lot internally, while on the other hand we see the result from Claude’s research in 2025 that AI made coding slower by 19%, and the DORA report showing lower throughput and lower delivery stability with higher AI adoption!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*30uUsskMFx0c29rwxiR-UA.jpeg" /></figure><p>This was tackled during <a href="https://www.linkedin.com/in/eliseparadis/">Elise Paradis’s</a> great talk, where she explained how the results vary based on project maturity and task complexity, which explains a lot, and goes hand in had with what we (developers) have been trying to tell our CEOs for quite a long time. AI productivity is highest on small, well-scoped tasks in mature codebases; lowest on complex, immature projects.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9xWMlnSfC0JQrYKrFNq-uA.jpeg" /></figure><p>So, how does this go together with what Meta reports about their productivity boosts? Well, it was mentioned in passing during one of their presentations that they have <strong><em>several </em></strong><em>internal non-open-source</em> models that they use for the different projects. Models trained on their huge source code base and fine tuned for their needs. And it’s not one model, it’s several ones, for different languages, and different code-bases. Well, when you have the resources of Meta, you can do that, but when you use the generic out-of-the-box GPT-5 or Claude, then you won’t see the same numbers that are reported by the likes of Meta.</p><p>And just before I’m deemed a heretic, I love using AI for <em>specific tasks</em>. I just hate the huge hype around it and the expectations of CEOs that AI will allow one developer to do the work of ten.</p><h3>Developer Experience</h3><p>Another main talking point in many of the talks was the developer experience, since, believe it or not, happy developers are productive developers, and research did show that. This was clear in many talks like Elise’s I mentioned above, the one about <a href="https://lp.jetbrains.com/devex-productivity-report-full-2025-dataviz/?tab-OneOfTabWrapperBlock-1756889760421-44980=their-top-pain-points-">JetBrains DevEco survey</a>, the Meta and Airbnb talks and many others.</p><h3>Conclusion</h3><p>I think that this convention is really useful for anyone interested in developer productivity and experience. I think that companies must send representatives each year to gain knowledge from the great talks, and have a realistic understanding on what to expect from AI and such.</p><p>Will I be going back? Well, if I’m ever in the US around the time of the convention, I’ll certainly go. I can even plan my trips around it. However, for me to travel specifically from Egypt to San Francisco, well, I won’t, since even though it’s great, it’s not world-changing to the extent that I spend 10–20x the price of the convention ticket price to go. However, for anyone in the US, even if not in California, I think that it’s useful enough to travel for. I certainly think I might plan other trips around the time of this convention in the future.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c80f2cb633de" width="1" height="1" alt=""><hr><p><a href="https://medium.com/chronicles-of-a-cloud-engineer/dpe-summit-2025-thoughts-c80f2cb633de">DPE Summit 2025 Thoughts</a> was originally published in <a href="https://medium.com/chronicles-of-a-cloud-engineer">Chronicles of a Cloud Engineer</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From $450 to $1: How We Slashed AWS Step Functions Costs with Activities (Part 2)]]></title>
            <link>https://medium.com/chronicles-of-a-cloud-engineer/from-450-to-1-how-we-slashed-aws-step-functions-costs-with-activities-part-2-5f90c0dae3ba?source=rss----d1f0f70df60b---4</link>
            <guid isPermaLink="false">https://medium.com/p/5f90c0dae3ba</guid>
            <category><![CDATA[aws-ecs]]></category>
            <category><![CDATA[aws-cost-optimization]]></category>
            <category><![CDATA[aws-step-functions]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[cloudwatch]]></category>
            <dc:creator><![CDATA[Alaa Nassef]]></dc:creator>
            <pubDate>Thu, 18 Sep 2025 17:02:06 GMT</pubDate>
            <atom:updated>2025-11-15T21:35:11.607Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f6cb4CRX3Sg7rYuXuD0JdA.png" /></figure><h3>Recap of Part 1</h3><p>Our system is a multi-tenant charging platform for telecom providers, and one component of that system is a step function that syncs the actual number of subscribers of each plan to the plan records. This queries the different DynamoDB partitions to get the count of each plan. The problem was that this was using hundreds of thousands of state transitions with each execution making the single invocation cost around 450 USD.</p><p>Then during AWS re:Invent 2024, my manager and I attended an incredible talk by <a href="https://x.com/edjgeek">Erick Johnson</a>, titled <a href="https://www.youtube.com/watch?v=gdGgBKJiM2E"><em>Advanced Workflows with AWS Step Functions</em></a>, which, among other things, introduced us to Step Function Activities, which seemed like a good tool to use to solve our cost issue.</p><p>In <a href="https://medium.com/chronicles-of-a-cloud-engineer/from-450-to-1-how-we-slashed-aws-step-functions-costs-with-activities-part-1-23642db71a9d">part 1</a>, I explained our original design, and how we replaced the contents of the innermost map with an activity run to reduce the cost of the invocation by 44%. In this part I’ll continue with how we improved this further to slash the cost down to be around 1USD per invocation, and all of the hurdles that faced us during this journey.</p><h3>A Problem of Scale</h3><p>The next step to reduce cost was pretty clear for me; get rid of the shards map and process the whole plan as a single activity in ECS. I didn’t want to tackle this problem before handling the problem of the auto-scaling of our ECS service. This was important for a few reasons:</p><ol><li>We needed to finish this activity fast. We do not want the step function to hang around for hours waiting for the huge amount of data to be processed.</li><li>In the same time, we do not want to throttle our DynamoDB table. We are using provisioned capacity with auto-scaling, so scaling up to tens of ECS tasks at the same time would cause the table reads to throttle for a while until the provisioned capacity scales up.</li><li>We had our own rate limiter in place to ensure that we do not hit DynamoDB hard, but rather allow the traffic to DynamoDB to increase gradually. You might think, “Well, that’s great, then there’s no problem in scaling up quickly, and point 2 is invalid”. To that I would say, maybe, but that would still be a problem because we’ll have all of those resources sitting idle, doing nothing for a long time except for asking the rate limiter “Can I do something now?” for it to be answered “I SAID NO!”. This would be a huge waste of resources.</li></ol><p>So, the answer was simple. Use <a href="https://docs.aws.amazon.com/step-functions/latest/dg/procedure-cw-metrics.html#:~:text=or%20an%20alias.-,Activity%20Metrics,-The%20AWS/States">the metrics</a> from activities to gradually scale up the ECS tasks up to a maximum, and when all activities are processed, scale down. Simple, right? <em>RIGHT??</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*tzv4LZAZnLZBAqn_.jpg" /></figure><h4>Using ActivitiesScheduled metric</h4><p>The straightforward solution was to use the ActivitiesScheduled metric, since as per the documentation it represents the <strong>Number of scheduled activities.</strong> The problem was that it does not represent the number of activities in the backlog, but the actual scheduling of activities regarding if those were processed or not. OK, not a problem, we can use it along with ActivitiesSucceeded, ActivitiesFailed and ActivitiesTimedOut, then we can <strong><em>simply</em></strong> figure out the backlog? Right?</p><p>Turns out, no, not right. Those metrics represent the events within the minute, so if in the first minute we get 100 activities scheduled, 2 processed and nothing timed out or failed, so the backlog would be calculated as 100 -2 = 98. Now the next minute, we get 20 more scheduled and 48 processed, you would expect that the backlog should be 70 (100 + 20 -2 -48= 70), but because CloudWatch takes it a minute at a time, the value would be 20 -48 = -28 !</p><h4>Using RUNNING_SUM()</h4><p>What seemed to be the natural thing to do was to use theRUNNING_SUM() function in CloudWatch metric math to calculate the whole series. This should fix it, I thought naively. Again, this was not straightforward, because we would get minutes without readings, i.e. nil. Basically, because there’s a maximum hard limit concurrency for step function maps, activities would be generated very quickly in the beginning, then it halts waiting for activities to be processed to get to the next map items to create activities for them, and if this halt takes more than a minute, we get null readings.</p><p>“So what?”, you might ask? Well, any null, the running sum function decides that it’s the end of the series, and it returns null, and if the next minute it gets a reading, it starts a new series, breaking the whole idea of me calculating the backlog of pending tasks.</p><h4>FILL() to the rescue?</h4><p>Another CloudWatch metric math function that could help us is FILL(), where we decided to use it to fill in null values with zeroes. Theoretically this should have fixed the issue, meaning that we use it together with the RUNNING_SUM() of the metrics we’re observing. However, this was extremely flaky, totally inaccurate, reporting values that when we refresh we see different ones. One reason is that CloudWatch metrics reporting is not real time and is delayed, so FILL() would put in a zero because nothing was reported, but a minute later, the value for the <strong>previous</strong> minute is reported, but RUNNING_SUM() is depending on the previous value that it streamed, and all hell breaks loose. This was certainly not the way forward.</p><h4><strong>Using ActivityScheduleTime</strong></h4><p>After discussions with AWS premium support and our TAM team, it was suggested to use a totally different metric, which is ActivityScheduleTime . As per the documentation, it represents the <strong>Interval, in milliseconds, for which the activity stays in the schedule state</strong>. Perfect! Now, by checking the average or the max of that metric, I’ll have some sort of an indication of the backlog size, since if it is really large, the number will be getting larger until I catch up with the activity task creation. Right???</p><p>The problem was that this metric was only getting that it’s reported after the activities are processed, which means that I cannot scale up from zero instances, because to get a metric I need to process a task, which means that I need ECS to be scaled up in advance. The funny thing is that this was not mentioned anywhere in the documentation. I understand the design decision, but the fact that it’s not mentioned in the docs, and was suggested to us by the AWS support team and TAMs was shocking.</p><h4>Design Decision</h4><p>A design decision had to be made. AWS at the time of writing this post, does not have a metric to represent the backlog size. Using metric math like FILL() and RUNNING_SUM() would work with delayed values, so functions like the latter would be approximations. We had to keep a part from our interim design where we scale the ECS service manually at the start, but only to a minimum to make it start processing tasks, and to make use of the ActivityScheduleTime metric (with a FILL() of zeroes for missing points) as an indication of whether there’s something in the backlog or not. This was the best we could do with what we’ve got. We also submitted a feature request for AWS to add a metric for the pending activity tasks size, which would certainly solve our problem. With that out of the way, it was time to go back to cost optimizing this thing.</p><h3>The One Dollar Run</h3><p>As I have mentioned in the previous section, the solution to reduce the number of states drastically was quite simple. We had the innermost map with 256 items for the shards, and all it did was run activity. Why not get rid of it and have the activity processor process all the shards itself?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YF6hMYhMVtmno_4Pm_1ssQ.png" /></figure><p>This simple change in the step function meant that we would reduce the cost by a factor of 256. It also meant that we had to make a small change in the logic in the code run by the ECS task to loop over the shards, and parallelize the queries without hitting our limits. The code change was not complicated, so it was definitely worth it. And the final step function design looks something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/621/1*66DX9LS_Ok55klowNKcUqQ.png" /></figure><p>This much simpler step function design ended up reducing our original cost by 99.7%, since the cost for the run now is around only one US dollar!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GWdMlVEi5czGt-DigDJ17g.png" /></figure><p>Yes, that tiny speck on August 9 was the cost of the step function! This was a great accomplishment, and I have learned a lot through this journey. It was not the only time in this project where a small decision had a great effect on utilizing cost. There’s that one time where I reduced the monthly cost of our AWS account by more than 250K USD, but that’s a story for another time.</p><p>If you are interested in more technical details on what activities are, how to use them and how we set everything up, I just published a <a href="https://medium.com/chronicles-of-a-cloud-engineer/from-450-to-1-part-0-5-intro-to-step-function-activities-2af295c4e89f">Part 0.5</a> with all of the details there.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5f90c0dae3ba" width="1" height="1" alt=""><hr><p><a href="https://medium.com/chronicles-of-a-cloud-engineer/from-450-to-1-how-we-slashed-aws-step-functions-costs-with-activities-part-2-5f90c0dae3ba">From $450 to $1: How We Slashed AWS Step Functions Costs with Activities (Part 2)</a> was originally published in <a href="https://medium.com/chronicles-of-a-cloud-engineer">Chronicles of a Cloud Engineer</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>