Tech Dive (@techhdive) header
Tech Dive (@techhdive) profile picture

helping engineers understand how systems scale, fail & recover in production.

Joined March 2023
Photo by Tech Dive (@techhdive)Photo by Tech Dive (@techhdive)Photo by Tech Dive (@techhdive)Photo by Tech Dive (@techhdive)Photo by Tech Dive (@techhdive)Photo by Tech Dive (@techhdive)Photo by Tech Dive (@techhdive)Photo by Tech Dive (@techhdive)Photo by Tech Dive (@techhdive)Photo by Tech Dive (@techhdive)
Tech Dive retweeted
if your agent does multiple operations, then you need a failure strategy as well. let's say your agent: - creates an order - reserves the item - charges the user - schedules delivery now let's say scheduling delivery fails, but the user has already been charged. you can't treat all these operations as a single transaction. instead, each operation should have a corresponding compensating operation. for example: - create order ➡️ cancel order - reserve item ➡️ release item - process payment ➡️ initiate refund this way, if a later step fails, you execute the required compensating operations for the steps that were already successful. one thing to understand is that this isn't a db rollback. it's another business operation and that operation can fail too.
6
1
4
183
Tech Dive retweeted
you use embedding models to convert text into vectors. to store these vectors for fast retrieval, you can use chroma db or postgres with the pgvector extension. when a user asks a question, you convert the query into a vector using the same embedding model and compare it against the stored vectors to find the closest matches. these matches can then be used as relevant context for the LLM before it generates a response. that's the basic idea behind retrieval augmented generation (RAG)
1
1
63
Tech Dive retweeted
and a lot of it is a mental thing. the task remains the same, but how hard it feels depends on how you have framed it in your head. tell yourself it's hard every day and your brain will keep finding reasons to avoid it. but if you change that, the same action can start feeling effortless after a few repetitions, just like brushing your teeth.
Não existe atalho. acordar cedo é difícil, cuidar do corpo é difícil, estudar é difícil, trabalhar é dificil, crescer espiritualmente é difícil. Mas é justo que muito custe o que muito vale.
1
1
195
Tech Dive retweeted
top k results may or maynot be relevant results in your vector search. when building a rag system, we decide how many documents we want to retrieve. for example, retrieve the top 5 documents that are most similar to the user's query. but there's one thing we should understand here. vector search will try to return the closest matches available in your dataset. it doesn't mean those results are actually relevant to the query. let's say a user asks something about postgres indexing, but your knowledge base doesn't have any document covering that topic. so your vector database can still return 5 documents. they might be the closest matches available, but that doesn't mean they are useful or can answer the user's question. so how do we handle this? -introduce a similarity threshold. - retrieve only those matches that are above this threshold. - reject the rest. this is a decent approach to make sure you either return something relevant or don't return something completely unrelated.
5
1
3
109
Tech Dive retweeted
don't make jokes with your colleagues just for the sake of it. if a joke doesn't land the way you intended, things might not stay the same. and you still have to work with that person every day. things can get awkward and the working relationship might not be the same anymore. so try to be as professional as possible. that's it.
1
1
28
Tech Dive retweeted
parallel tool calls are not only about reducing latency, you also need to think about concurrency. an ai agent can request multiple tool calls in a single response. say your agent needs to: - fetch a customer's profile - get their recent orders - check their payment history these operations are independent, so you can execute them in parallel and reduce the overall response time. but what if the agent needs to update the customer's account and then fetch the updated details? here you can't run both in parallel because the second operation depends on the first one. otherwise you might end up fetching stale data. so before executing parallel tool calls, you need to think about: • are these operations independent • are they modifying the same resource • does the execution order matter • what happens if one of the calls fails • are there any limits on concurrent requests also make sure you map every tool result back to its original tool call id. parallel execution helps reduce latency, but you need to handle dependencies and side effects properly.
1
1
37
Tech Dive retweeted
if you change your embedding model, you do need a data migration. it's not just a config change. if you build a RAG system using one embedding model and later decide to switch to another because it gives you better retrieval results, there's something you need to consider. each model generates embeddings in a different vector space. even if the vector dimensions are the same, the embeddings may not be compatible. so you need to treat this seemingly small change as a data migration. here's how you do it : 1. keep your existing vector collection available. 2. generate new embeddings using the new model. 3. store them in a separate collection. 4. evaluate retrieval using the same test queries. 5. switch traffic to the new collection once everything looks good. 6. keep the old collection around for rollback for some time. also make sure your query embeddings are generated using the new model when you switch to the new collection. so changing the embedding model affects your entire retrieval pipeline.
1
3
12
Tech Dive retweeted
say in a file upload system like dropbox or google drive, if a user changes 5 mb of a 10 gb file, would you upload the entire 10 gb again? we can solve this using chunks. the idea is simple: • divide the file into chunks • keep track of which chunks belong to each version • when the user makes a change, find which chunks changed • upload only those changed chunks but s3 objects are immutable, so you can't just update 5 mb of an existing 10 gb object. instead of that : • store the chunks separately in s3 • reuse the chunks that did not change • upload a new version of the changed chunks • store the list of chunks in the file metadata when the user downloads the file, the client gets the list of chunks from the metadata and puts them back together in the right order. so if a user changes 5 mb of a 10 gb file, you only need to upload the changed chunks instead of uploading the entire 10 gb again. that's a pretty useful pattern when you're dealing with large files.
1
1
4
Tech Dive retweeted
earlier writing the code used to take a lot of time. now it probably takes the least. time consuming work now is to decide the approach, review it and test it. before writing a feature, we now spend time thinking about the flow: - input validation - queries - integration - processing - threads / async - retries - failure cases - response once these decisions are clear, writing code is the easy part with ai. its great.
1
1
8
Tech Dive retweeted
if you are designing a system like google drive, how would you keep files synced across multiple devices? say there is a file called boomer. two users have access to it, device a and device b. now device a makes some changes and uploads them to the server. how would device b know about this change? one approach is to use websocket connection with the server. the flow would be: • device a uploads the updated file • server saves the changes • server sends a notification to device b through websocket • device b knows that the file has changed • device b calls the download api and gets the latest version this is it. but there is one problem. what if the websocket connection is interrupted or device b misses the notification? device b would have no idea that it is out of sync. so you need another mechanism to reconcile with the server. you can use periodic polling: • device b polls the server every few minutes • it sends its last known version • server checks if there are any changes after that version • if there are changes, device b calls the download api • device b gets the latest version and is back in sync so the approach becomes: websocket for fast notifications + polling for reconciliation. that's the kind of hybrid approach you can use for keeping files synced across devices.
1
1
5
Tech Dive retweeted
rapido generates the same otp for each user every time, as per this post. if users get a 4 digit otp, there are only 10^4 combinations. so if you have more than 10^4 rides at the same time, some users will end up with the same otp. so in case of collision, the system must be checking more than just the otp, maybe something like ride_id + otp or even ride_id + otp + assigned vehicle. this way, even if the same otp repeats across rides, it does not matter because it is tied to the ride. this removes the collision concern. if there is a better way rapido might be using to handle this same otp case, would like to know.
Interviewer: Why does Uber generate a different OTP for every single ride, while Rapido uses the same OTP?
1
1
4
140
Tech Dive retweeted
one retry shouldn’t mean two payments. the method that avoids duplicates when users or systems retry is called idempotency. so how do we achieve it? to make an api idempotent, the goal is simple: avoid duplicate side effects when retries happen. the client creates an idempotency key and sends it with the request. the server stores this key along with the request result or status. now if the same request is sent again with the same key, the server knows it’s not new. it doesn’t process it again. it either returns the stored result or skips the duplicate work, depending on the state. that’s how idempotency works at a high level.
1
1
9
141
Tech Dive retweeted
cache works well until it starts serving stale data. a good way i got to know for handling cache invalidation, especially at large scale is using cdc (change data capture). cdc reads database logs and you can configure it to trigger an event whenever there is a change in the db. like on insert, update, or delete, you can publish an event. then you update your cache: either overwrite the existing data or invalidate it and write fresh data. this way, your cache stays reasonably fresh and reduces unnecessary db hits. stale cache serves wrong data. and wrong data is worse than no data.
2
1
4
117
Tech Dive retweeted
i had to migrate an application from a shared aws account to a team specific aws account. i was new to that system, and the person who had been maintaining it was let go. it was a challenging task, as everything had to be created in the new account: new codebase, new airflow instances, etc. i needed to collaborate with multiple teams regarding what was changing, setting up dns, new api endpoints, rds creation and cost optimization scopes. it made me realize how good it is to do things end-to-end, as it just allows you to learn everything very well.
1
1
6
106
Tech Dive retweeted
the reason this gap exists in tech is that signals of value are easy to fake on the surface and slow to verify in reality. and the sdes who get great compensation are the ones who make themselves hard to replace by owning outcomes, not just tasks. a task is what you are asked to do. owning a task means you did what was asked. owning an outcome means you cared if it actually worked, caught nobody asked you to catch, and improved things around you without being told. this is a mindset, and it can be developed.
Most people want high-paying jobs without becoming high-value individuals.
1
1
58
Tech Dive retweeted
uber does not use a separate database for every microservice. this sounds different from what we learn in theory. in theory, each microservice should have its own database. but at scale, things don’t work the same way. uber has hundreds of microservices. running a separate database for each would be expensive and hard to manage. so they built docstore. an in-house distributed database platform on top of mysql. multiple microservices use docstore to store their data. each service still owns its data logically with its own tables, schemas, and access patterns. the docstore takes care of sharding, replication, and scaling. so instead of many separate databases, they use a shared system with clear data ownership. this reduces cost, improves resource usage, and makes operations easier. at the end of the day, it comes down to constraints, not just what theory says.
1
1
4
81
Tech Dive retweeted
scaling reads is easier than scaling writes. most of the time.
1
2
60
Tech Dive retweeted
the highest leverage thing ai cannot do is be accountable someone has to own the decision, take responsibility for the tradeoff and be the one responsible when things go wrong that accountability builds judgment not just skill but skin in the game that makes it better over time ai can suggest it cannot own the outcome
If your only value as an engineer is writing code, you're directly competing with AI and you'll lose. Start focusing on the things AI can't do yet: system design, business context, real life debugging
1
1
4
98
Tech Dive retweeted
a message queue and an event stream are different. that's it. that's the post.
1
1
4
102
Tech Dive retweeted
one tab crashes. everything else keeps running. why? in chrome you have multiple tabs open and one crashes but others still keep running fine? how is this done? each chrome tab runs as a separate process and that is how it achieves this it is about keeping tabs isolated from each other. processes run in isolation and do not interfere with each other each process has its own memory space and stack and they share cpu over time not a dedicated cpu per process so if one tab process crashes it does not affect other tabs because they are in separate memory spaces managed by the operating system
1
1
27