Posts

When Atomicity Meets Idempotency: DynamoDB Transactions + Powertools (S3 → Lambda → DynamoDB)

Image
  When Atomicity Meets Idempotency: DynamoDB Transactions + Powertools (S3 → Lambda → DynamoDB) # aws # s3 # lambda # dynamodb In distributed systems, reliability isn’t luck — it’s architecture. Sometimes, “helpful retries” can turn your database into a mess. You didn’t do anything wrong — your system just delivered  twice as promised. Now let’s make it bulletproof. Problem Your event-driven pipeline looks clean on paper: S3 → Lambda → DynamoDB Each time a file lands in S3, Lambda logs it in a DynamoDB table and writes a short audit entry to another table. Everything works beautifully — until one day you notice this: { "main_records" : 2 , "audit_log" : 1 } Same file. Same event. Two main entries. One audit entry. Lambda retried in the middle of your transaction. Now your data is  out of sync. Clarifying the Issue AWS services like  S3  and  Lambda  guarantee  at-least-once delivery . That means you’ll never lose an event — but you ...

The Async Iterator: When Regular Loops Block the Event Loop

Image
  The Async Iterator: When Regular Loops Block the Event Loop # python # coding # programming # softwaredevelopment Timothy stared at his screen, puzzled. His async web server was working beautifully for most requests, but whenever someone requested the log file analysis endpoint, the entire server seemed to freeze for several seconds. "Margaret, I don't understand," he said, showing her the code. "I'm using async/await everywhere, but this one endpoint still blocks everything." Margaret walked over and looked at his screen. import asyncio from pathlib import Path async def analyze_logs (): """ Analyze a large log file """ log_file = Path ( " server.log " ) # 1GB file error_count = 0 print ( " Starting log analysis... " ) # Read and process the file with open ( log_file , ' r ' ) as f : for line in f : # Regular for loop if ...