Alex Xu Profile picture
Jan 23 9 tweets 3 min read
/1 8 Data Structures That Power Your Databases. Which one should we pick?
/2 The answer will vary depending on your use case. Data can be indexed in memory or on disk. Similarly, data formats vary, such as numbers, strings, geographic coordinates, etc. The system might be write-heavy or read-heavy.
/3 All of these factors affect your choice of database index format.

The following are some of the most popular data structures used for indexing data:

🔹Skiplist: a common in-memory index type. Used in Redis
/4 🔹Hash index: a very common implementation of the “Map” data structure (or “Collection”)
🔹SSTable: immutable on-disk “Map” implementation
🔹LSM tree: Skiplist + SSTable. High write throughput
🔹B-tree: disk-based solution. Consistent read/write performance
/5 🔹Inverted index: used for document indexing. Used in Lucene
🔹Suffix tree: for string pattern search
🔹R-tree: multi-dimension search, such as finding the nearest neighbor
/6 This is not an exhaustive list of all database index types. Over to you:

1). Which one have you used and for what purpose?
2). There is another one called “reverse index”. Do you know the difference between “reverse index” and “inverted index”?
/7 I will provide a more in-depth analysis of this topic. Subscribe to our newsletter to get the latest update: bit.ly/3whEH2D
/8 I hope you've found this thread helpful.

Follow me @alexxubyte for more.

Like/Retweet the first tweet below if you can:
Also posted the thread on hackernews. Upvote would be appreciated: news.ycombinator.com/item?id=344916…

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Alex Xu

Alex Xu Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @alexxubyte

Jan 24
/1 𝐆𝐢𝐭 𝐌𝐞𝐫𝐠𝐞 𝐯𝐬. 𝐆𝐢𝐭 𝐑𝐞𝐛𝐚𝐬𝐞

What are the differences? Image
/2 When we 𝐦𝐞𝐫𝐠𝐞 𝐜𝐡𝐚𝐧𝐠𝐞𝐬 from one Git branch to another, we can use ‘git merge’ or ‘git rebase’. The diagram below shows how the two commands work.
/3 𝐆𝐢𝐭 𝐌𝐞𝐫𝐠𝐞
This creates a new commit G’ in the main branch. G’ ties the histories of both main and feature branches.

Git merge is 𝐧𝐨𝐧-𝐝𝐞𝐬𝐭𝐫𝐮𝐜𝐭𝐢𝐯𝐞. Neither the main nor the feature branch is changed. Image
Read 8 tweets
Jan 19
/1 How do Visa 𝐝𝐢𝐬𝐩𝐮𝐭𝐞 and 𝐜𝐡𝐚𝐫𝐠𝐞𝐛𝐚𝐜𝐤 work?

A dispute happens when a cardholder disagrees with a merchant’s charge. A chargeback is a process of reversing the charge. Sometimes, the two terms are used interchangeably. Image
/2 A dispute is 𝐞𝐱𝐩𝐞𝐧𝐬𝐢𝐯𝐞: for every dollar in disputed transactions, an additional $1.50 is spent on fees and expenses.

The diagram below shows why. 👇 Image
/3 🔹 Steps 1-3: The cardholder Bob raises a dispute with the card issuer. Details are reviewed by the issuing bank. In cases of legitimate disputes, the issuing bank submits a chargeback request to the card network. Image
Read 9 tweets
Jan 17
1/ 𝐖𝐡𝐚𝐭 𝐢𝐬 𝐭𝐡𝐞 𝐩𝐫𝐨𝐜𝐞𝐬𝐬 𝐟𝐨𝐫 𝐝𝐞𝐩𝐥𝐨𝐲𝐢𝐧𝐠 𝐜𝐡𝐚𝐧𝐠𝐞𝐬 𝐭𝐨 𝐩𝐫𝐨𝐝𝐮𝐜𝐭𝐢𝐨𝐧?

The diagram below shows several common 𝐝𝐞𝐩𝐥𝐨𝐲𝐦𝐞𝐧𝐭 𝐬𝐭𝐫𝐚𝐭𝐞𝐠𝐢𝐞𝐬.
2/ 𝐁𝐢𝐠 𝐁𝐚𝐧𝐠 𝐃𝐞𝐩𝐥𝐨𝐲𝐦𝐞𝐧𝐭

Big Bang Deployment is quite straightforward, where we roll out a new version in one go with service downtime. We roll back to the previous version if the deployment fails.

💡 No downtime ❌
💡 Targeted users ❌
3/ 𝐑𝐨𝐥𝐥𝐢𝐧𝐠 𝐃𝐞𝐩𝐥𝐨𝐲𝐦𝐞𝐧𝐭

Rolling Deployment applies phased deployment compared with big bang deployment. The whole plant is upgraded one by one over a period of time.

💡 No downtime ✅
💡 Targeted users ❌
Read 9 tweets
Jan 16
1/ How do we design a 𝐜𝐡𝐚𝐭 𝐚𝐩𝐩𝐥𝐢𝐜𝐚𝐭𝐢𝐨𝐧 like WhatsApp, Facebook Messenger or Discord?

The diagram below shows a design for a simplified 1 to 1 chat application.
2/ 𝐔𝐬𝐞𝐫 𝐋𝐨𝐠𝐢𝐧 𝐅𝐥𝐨𝐰

🔹Step 1: Alice logs in to the chat application and establishes a web socket connection with the server side.

🔹Steps 2-4: The presence service receives Alice's notification, updates her presence, and notifies Alice's friends about her presence.
3/ 𝐌𝐞𝐬𝐬𝐚𝐠𝐢𝐧𝐠 𝐅𝐥𝐨𝐰

🔹Steps 1-2: Alice sends a chat message to Bob. The chat message is routed to Chat Service A.

🔹Steps 3-4: The chat message is sent to the sequencing service which generates a unique ID, and is persisted in the message store.
Read 9 tweets
Jan 12
1/ Is it possible to run C, C++, or Rust on a web browser? Image
2/ What is 𝐰𝐞𝐛 𝐚𝐬𝐬𝐞𝐦𝐛𝐥𝐲 (WASM)? Why does it attract so much attention?

The diagram shows how we can run native C/C++/Rust code inside a web browser with WASM. Image
3/ Traditionally, we can only work with Javascript in the web browser, and the performance cannot compare with native code like C/C++ because it is interpreted.
Read 7 tweets
Jan 9
/1 𝐈𝐬 𝐦𝐢𝐜𝐫𝐨𝐬𝐞𝐫𝐯𝐢𝐜𝐞 𝐚𝐫𝐜𝐡𝐢𝐭𝐞𝐜𝐭𝐮𝐫𝐞 𝐭𝐡𝐞 𝐬𝐢𝐥𝐯𝐞𝐫 𝐛𝐮𝐥𝐥𝐞𝐭?

The diagram below shows why 𝐫𝐞𝐚𝐥-𝐭𝐢𝐦𝐞 𝐠𝐚𝐦𝐢𝐧𝐠 and 𝐥𝐨𝐰-𝐥𝐚𝐭𝐞𝐧𝐜𝐲 𝐭𝐫𝐚𝐝𝐢𝐧𝐠 applications should not use microservice architecture.
/2 There are some common features of these applications, which make them choose monolithic architecture:
/3 🔹These applications are very 𝐥𝐚𝐭𝐞𝐧𝐜𝐲-𝐬𝐞𝐧𝐬𝐢𝐭𝐢𝐯𝐞. For real-time gaming, the latency should be at the milli-second level; for low-latency trading, the latency should be at the micro-second level.
Read 11 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(