Pinned Tweet
Classic pagination bug: a product search feels instant on the first few pages, then gets slower the deeper it goes. A few hundred pages in, response times stretch into seconds and CPU usage goes up. OFFSET is the culprit, and the fix is a one-line change to the query.
The core AWS services:
AWS lists over 200 services, and most apps only touch a handful of them.
EC2, Lambda, S3, RDS, DynamoDB, VPC, IAM and CloudWatch cover compute, storage, databases, networking, access and monitoring.
8
336
A sneaky Amazon S3 and Lambda problem:
- Your system uploads images to an S3 bucket
- Each upload triggers a Lambda function
- The function saves a thumbnail to the same bucket
Does this sound right? Each thumbnail is also an upload, and it triggers the function again.
The outbox pattern: how to solve the lost event problem.
The app writes the order to the orders table and the OrderCreated event to a separate outbox table, in one Postgres transaction. Both commit, or neither does.
A relay reads new outbox rows and publishes them to Kafka.
System design problem: an order is saved in Postgres, then an OrderCreated event is published to Kafka. No single transaction covers both writes.
If the app crashes between the commit and the publish, the order is saved and the event is lost.
How would you fix it?
The answer is 2.
The LEFT JOIN keeps Cy with o.amount set to NULL.
NULL > 10 is not true, and WHERE removes that row.
SQL quiz.
Table customers: Ana (id 1), Ben (id 2), Cy (id 3).
Table orders: customer 1 spent 50, customer 2 spent 20.
What's the output of this query?
SELECT COUNT(*)
FROM customers c
LEFT JOIN orders o ON o.customer_id = c. id
WHERE o.amount > 10;
With named arguments, a call explains itself: open_file(path, create=True, append=True)
C, Java and Go don't have them. The call would be open_file(path, true, true, false), which doesn't show which boolean is which.
Bit flags are a common fix: open_file(path, CREATE | APPEND)
URL path. The path and query string are sent inside the encrypted request.
IP address and port are in the packet headers, and the data size shows in the packet lengths.
HTTPS encrypts traffic, but part of a request stays visible to anyone watching the network. Three of these are visible on the wire:
- IP address
- Port
- URL path
- Data size
Which one does HTTPS hide?
DSA Basics: DFS.
DFS (depth-first search) goes down one branch of a tree to a leaf before backing up.
A stack is the data structure that enables it:
1. Pop the top node, starting with the root
2. Push its children, right child first
3. Repeat until the stack is empty
7
483
A. It accepts the upload.
S3 checks the expiry once, when the HTTP request arrives. An upload that starts before 12:05 completes.
A presigned S3 upload URL expires at 12:05. A large upload starts at 12:04 and finishes at 12:07.
A) S3 accepts the upload
B) S3 rejects it at 12:05
Which one happens?
236
A presigned S3 upload URL expires at 12:05. A large upload starts at 12:04 and finishes at 12:07.
A) S3 accepts the upload
B) S3 rejects it at 12:05
Which one happens?
Encryption and hashing both turn "hello" into unreadable output, what's the difference between the two?
The difference is the way back. Encrypted data can be read again with the key. A hash has no key and cannot be reversed.
That's why passwords are stored as hashes.
The dual write problem: the file is uploaded to S3, then the Postgres insert fails.
One fix is to insert the row first with status pending, and mark it ready after the upload.
A cleanup job handles rows still pending after an hour.
A Python dict built from pairs with a duplicate key:
pairs = [("a", 1), ("b", 2), ("a", 3)]
What does dict(pairs) return?
A tree, written as each node's children:
A: B, C
B: D
C: E, F
In what order does a breadth-first search (BFS) from A visit the nodes?
The answer nitter.gq/The_HappyPath/status/2…
A B C D E F.
BFS visits every node on one level before going deeper: A, then its children B and C, then their children D, E and F.
1
119





















