varletint (@varletint) profile picture

backend engineer | system design | node.js is home • building https://teapawt.net/t.co/U4ccrvDvXe | https://teapawt.net/t.co/Tvnl1YKyK1 founder @ https://teapawt.net/t.co/EsSj8tTHWm

Joined March 2023
Photo by varletint (@varletint)Photo by varletint (@varletint)Photo by varletint (@varletint)Photo by varletint (@varletint)Photo by varletint (@varletint)Photo by varletint (@varletint)Photo by varletint (@varletint)Photo by varletint (@varletint)Photo by varletint (@varletint)Photo by varletint (@varletint)
Payment flows aren’t linear. They survive timeouts, retries, and human approvals.
1
21
and correctness. CORE SKILLS
13
May the 4th be with you
1
27
When building distributed systems, people don’t realize they’ve already shipped something that might give them a crazy production issue. For instance, you save data to your database, then publish an event to a message broker. Simple, right? Until it isn’t. I'll break down "Transaction Outbox Pattern" using a real-world example. With all today's Twitter gbasgbos so I'll use the same e-commerce to explain the pattern; So, imagine you’re building an e-commerce system. A customer places an order: You write the order into your database. You publish an “OrderCreated” event to Kafka (or RabbitMQ). Now here’s the problem: these two steps are NOT atomic. If your DB write succeeds but your event publish fails: 1. Your system now has an order that other services (inventory, payment, shipping) don’t even know exists. If your event publish succeeds, but your DB write fails: 2. Other services react to an order that was never actually created. This is how systems quietly corrupt themselves. And no… wrapping both in a single transaction is not possible because: 1. Your database and your message broker are two completely different systems. 2. Distributed transactions (2PC) are slow, fragile, and rarely worth the complexity. So what do you do? This is where the Transaction Outbox Pattern comes in. Instead of trying to write to the DB and publish an event at the same time, you change the flow: You write your business data (e.g., Order) In the SAME database transaction, you also write an “event record” into an outbox table Now, both operations succeed or fail together. No inconsistency. Then separately: 1. A background worker (or polling service) reads from the outbox table 2. Publishes events to your message broker 3. Marks them as processed Now your system becomes: Eventually consistent, Fault-tolerant, Retryable without duplication (if done right), Real-world example: Say you’re running a marketplace like Jumia. When an order is placed: Orders service writes to the orders table Same transaction writes to outbox table → { type: "OrderCreated", payload: {...} } Then a worker: Picks that row Publishes to Kafka Updates status → “processed” Is Kafka down? No problem, the event stays in the outbox and retries later. If your app crashes? No problem, the event is still in the DB. This pattern solves: Lost events Partial failures Inconsistent state across services It’s one of those patterns that looks like it's stressing you out until your system scales and you realize it’s the only reason things aren’t falling apart. In the next threads, I’ll show: What the traditional (broken) approach looks like visually What the outbox pattern flow looks like Why one silently fails while the other survives real-world chaos
5
14
1
44
2,155
avoid vague states like “done” or “ok”.
28
Robust order flow via FSM
35
a robust payment system is not just about “success or failed” it’s about tracking money across its entire lifecycle with absolute consistency
32
I'm trying to understand how ACID based database function by implementing all the functionalities from scratch together with FSM
43
mixing codecs with the wrong containers and parsing stderr like a fortune teller gets your FFmpeg live recorder hanging and generating broken audio files and this can cause playback errors try my new live audio streaming app saamee.vercel.app
54
automated stream recording 🤯 icecast mount_add - trigger recording mount_remove - stop + upload to cloud
19
You're building a complex dashboard with 1000+ rows that update in real-time. What is your go-to combo right now? - TanStack Table + Virtualizer - AG Grid (and pray the license fits) - Just react-window + custom everything - "I gave up and went full server components" Drop your stack & why? #react #frontend
4
2
1
16
2,592
lesson - browser privacy rules are part of your system design, not edge cases.
12
Replying to @ConsciousRide
This is how it works: 1. Client sends request with Accept: text/event-stream 2. Server keeps connection open 3. Server sends events as data: ...\n\n lines 4. Each \n\n triggers a client-side event 5. Client uses EventSource API to listen SSE is simpler than WebSockets when you only need server→client streaming.
1
1
6
446
Replying to @mysticwillz
I usually parse all query params at once into a clean object or dto first. Then I chain small functions that each handle one thing like addFilter, addSearch, addSort, addPageLimitOffset. Each function checks if the param exists and only adds the clause if it does. This way controller stays short, just calls the chain in order and executes.
1
1
22
3,449
is it okay to have something like this
10
do you think implementing page view analytics could help you make more data-driven decisions for the project?
12
Yesterday I worked on my Icecast streaming setup. Sounds simple. It wasn’t. Auth flows, stream stability, reconnects, duplicate mounts you can’t just push audio and pray.
16
I’d love to get your feedback on my new idea. Radio-as-a-service
17