Miah
banner
mdshahjahan.bsky.social
Miah
@mdshahjahan.bsky.social
Staff Software Engineer | More on smiah.dev
𝗪𝗵𝗲𝗿𝗲 𝗜𝘁 𝗚𝗲𝘁𝘀 𝗖𝗼𝗺𝗽𝗹𝗶𝗰𝗮𝘁𝗲𝗱
• A trading system needs locking to avoid double execution.
• A social media platform shines on loose coordination for scalability.
• A hybrid approach balances both—strict locks for money, relaxed rules for interactions.

Lock where it matters, scale where it doesn't.
April 3, 2025 at 7:18 AM
𝗖𝗼𝗺𝗯𝗶𝗻𝗲 𝗕𝗼𝘁𝗵 𝗳𝗼𝗿 𝗥𝗼𝗯𝘂𝘀𝘁 𝗦𝘆𝘀𝘁𝗲𝗺𝘀
Most successful architectures blend both:
• Use locking for critical consistency (transaction finalization).
• Use async messaging for scalable processing (sending confirmations).
April 3, 2025 at 7:18 AM
𝗪𝗵𝗲𝗻 𝗧𝗼 𝗖𝗵𝗼𝗼𝘀𝗲 𝗔𝗦𝗬𝗡𝗖𝗛𝗥𝗢𝗡𝗬:
• High-throughput systems(price feeds, order-book updates, post-trade)
• Scalability is more important than strict consistency.
• Failures can be handled via retries rather than immediate rollback.
April 3, 2025 at 7:18 AM
𝗪𝗵𝗲𝗻 𝗧𝗼 𝗖𝗵𝗼𝗼𝘀𝗲 𝗧𝗥𝗔𝗡𝗦𝗔𝗖𝗧𝗜𝗢𝗡 𝗟𝗢𝗖𝗞𝗜𝗡𝗚:
• Critical business operations (e.g. bank transfers, order execution).
• Data must be immediately correct at all times.
• The system has low concurrency but needs high accuracy.
April 3, 2025 at 7:18 AM
𝗔𝘀𝘆𝗻𝗰𝗵𝗿𝗼𝗻𝘆 (𝗘𝘃𝗲𝗻𝘁-𝗱𝗿𝗶𝘃𝗲𝗻, 𝗕𝗮𝗰𝗸𝗴𝗿𝗼𝘂𝗻𝗱 𝗣𝗿𝗼𝗰𝗲𝘀𝘀𝗶𝗻𝗴)
→ Removes blocking, maximizes throughput by allowing concurrency
→ Requires failure handling like retries, as rollbacks aren’t immediate
→ Ideal for market data feeds, trade notifications, and post-trade
April 3, 2025 at 7:18 AM
𝗧𝗿𝗮𝗻𝘀𝗮𝗰𝘁𝗶𝗼𝗻 𝗟𝗼𝗰𝗸𝗶𝗻𝗴 (𝗣𝗲𝘀𝘀𝗶𝗺𝗶𝘀𝘁𝗶𝗰, 𝗢𝗽𝘁𝗶𝗺𝗶𝘀𝘁𝗶𝗰 𝗟𝗼𝗰𝗸𝗶𝗻𝗴)
→ Ensures strict consistency by locking resources
→ Guarantees rollback, ensuring atomicity and preventing duplicates
→ Works well for high-stakes, time-sensitive operations (order matching)
April 3, 2025 at 7:18 AM
Profiling is the only reliable way to know where your program spends its time. Guessing is a waste of time, yours and the computer’s.

How it works programmatically: bit.ly/4kxPdL7
GitHub - mdshahjahanmiah/go-profiling: A basic Go program demonstrating CPU and memory profiling using pprof
A basic Go program demonstrating CPU and memory profiling using pprof - mdshahjahanmiah/go-profiling
bit.ly
April 2, 2025 at 12:07 PM
𝗣𝗼𝗽 𝗧𝗶𝗺𝗲 (𝟱,𝟬𝟬𝟬 𝗼𝗽𝘀):
- ArrayStack: 9.541 µs (1.9 ns/pop)
- LinkedListStack: 13.208 µs (2.6 ns/pop)
- Result: ArrayStack is ~1.4x faster, avoiding LinkedListStack’s pointer overhead.
April 2, 2025 at 12:07 PM
𝗣𝘂𝘀𝗵 𝗧𝗶𝗺𝗲 (𝟭𝟬,𝟬𝟬𝟬 𝗼𝗽𝘀):
- ArrayStack: 59 µs (5.9 ns/push)
- LinkedListStack: 336.417 µs (33.6 ns/push)
- Result: ArrayStack is ~5.7x faster due to contiguous memory, while LinkedListStack’s node allocations slow it down.
April 2, 2025 at 12:07 PM