Resi Dwi Thawasa

TIL — Today I Learned

Quick notes and discoveries from my learning journey

Idempotency keys stop duplicate charges

On a charge endpoint, a retry or a double click can turn one payment into two. The fix is an idempotency key. The caller sends...

#payments #idempotency

Verifying an ECDSA signature in Go

We had a server-to-server callback that came signed, and I needed to verify it in Go. The flow is short: parse the public key (usually...

#go #cryptography

find vs find_by to avoid noisy errors

Our error tracker was full of RecordNotFound exceptions for cases that were completely fine. A missing row was expected, not a real problem.

#rails

closure_tree: filter early

In a side project I use the closure_tree gem for hierarchical data in Rails. Methods like #leaves and #hash_tree are handy, but once I added...

#rails #postgres #performance

Set max idle connections, not just max open

Under load we kept getting “bad connection” errors that came and went. The connection pool had a sane max open setting, so that was not...

#postgres #performance #go

Quorum is ceil(N/2)

Quorum is the smallest number of nodes that have to agree before a decision counts. The formula is ceil(N/2):

#distributed-systems

Delete all evicted pods in one line

Evicted pods pile up and clutter kubectl get pods. They are done, they just sit there. Here is a one-liner to clean them up across...

#kubernetes #kubectl

Killing an N+1 with preload

A hot read endpoint was slow and I could not see why from the code. Watching the query log gave it away: one query to...

#rails #performance #postgres