<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Nebiyu Elias Talefe</title>
    <description>The latest articles on DEV Community by Nebiyu Elias Talefe (@nebiyuelias1).</description>
    <link>https://dev.to/nebiyuelias1</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1070619%2F6ca35250-f32a-4a8f-8e36-87d1dca632e9.jpeg</url>
      <title>DEV Community: Nebiyu Elias Talefe</title>
      <link>https://dev.to/nebiyuelias1</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nebiyuelias1"/>
    <language>en</language>
    <item>
      <title>My Top 10 VS Code Shortcuts for Productivity</title>
      <dc:creator>Nebiyu Elias Talefe</dc:creator>
      <pubDate>Fri, 17 Nov 2023 13:33:50 +0000</pubDate>
      <link>https://dev.to/nebiyuelias1/my-top-10-vs-code-shortcuts-for-productivity-5cde</link>
      <guid>https://dev.to/nebiyuelias1/my-top-10-vs-code-shortcuts-for-productivity-5cde</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zfoUrhWq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/12000/0%2AaKyvvJiA_cNRldmb" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zfoUrhWq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/12000/0%2AaKyvvJiA_cNRldmb" alt="Photo by [Godfrey Nyangechi](https://unsplash.com/@atimagodie?utm_source=medium&amp;amp;utm_medium=referral) on [Unsplash](https://unsplash.com?utm_source=medium&amp;amp;utm_medium=referral)" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;VS Code is without a shadow of a doubt one of the most popular IDEs loved by developers. Its lightweight nature and many extensions make it one of my favorite editors. I have been using VS Code for a while and I wanted to share some of my favorite shortcuts that I regularly use for productivity.&lt;/p&gt;

&lt;p&gt;Some people argue that you shouldn’t even use the mouse while coding. That’s the ultimate goal and if you’re interested in doing that you should probably use something like &lt;a href="https://neovim.io/"&gt;neovim&lt;/a&gt;. In fact, the neovim people think VS Code is for newbies. I haven’t tried neovim yet and it’s something I would like to try but I think VS Code can be a productive tool if used properly.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ff6ydkgZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/1%2AOM4dTujf8PMSw9-e-UbWpQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ff6ydkgZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/1%2AOM4dTujf8PMSw9-e-UbWpQ.png" alt="neovim vs vscode" width="800" height="887"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I will list my top 10 VS Code shortcuts I’ve come to use in my day-to-day life.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Navigate to the left/right tabs on the editor
&lt;/h2&gt;

&lt;p&gt;When you have so many editor tabs open it becomes handy to navigate left/right without using your mouse.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;macOS&lt;/strong&gt;: ⌘ ⌥ ← / ⌘ ⌥ →&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Linux&lt;/strong&gt;: Ctrl + [PgUp/PgDn]&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Windows&lt;/strong&gt;: Ctrl + [PgUp/PgDn]&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nzFee5Xl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://cdn-images-1.medium.com/max/3840/1%2AxJTLdHCUJk4bUkoBspCEGw.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nzFee5Xl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://cdn-images-1.medium.com/max/3840/1%2AxJTLdHCUJk4bUkoBspCEGw.gif" alt="Navigate to the left/right tabs" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Show Integrated Terminal
&lt;/h2&gt;

&lt;p&gt;This is a very simple but effective shortcut you can use to easily open or close the integrated IDE of the terminal. It is handy when you want to open your terminal and execute some commands quickly.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;macOS&lt;/strong&gt;: ⌃`&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Linux&lt;/strong&gt;: Ctrl + `&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Windows&lt;/strong&gt;: Ctrl + `&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--p2mntvlb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://cdn-images-1.medium.com/max/3840/1%2AC82k8W4HO0j8WmoHy9NVRA.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--p2mntvlb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://cdn-images-1.medium.com/max/3840/1%2AC82k8W4HO0j8WmoHy9NVRA.gif" alt="Show/hide terminal" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Bracket Matching
&lt;/h2&gt;

&lt;p&gt;Brackets come in pairs and we often want to know where one bracket starts and where it ends. You can use this shortcut to see the opening and closing brackets. Just make sure your cursor is near either the opening or closing bracket.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;macOS&lt;/strong&gt;: ⇧⌘\&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Linux&lt;/strong&gt;: Ctrl + Shift + \&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Windows&lt;/strong&gt;: Ctrl + Shift + \&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZsHE9t1h--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://cdn-images-1.medium.com/max/3840/1%2AoMri1MI6DNPNtUA40L5qjQ.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZsHE9t1h--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://cdn-images-1.medium.com/max/3840/1%2AoMri1MI6DNPNtUA40L5qjQ.gif" alt="Matching brackets will be highlighted as soon as the cursor is near one of them" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Navigate Back To Your Previous Position
&lt;/h2&gt;

&lt;p&gt;When working on a file with hundreds of lines of code, we often jump from one position to another to understand something. Say, for example, from line 900 to 500. After looking at the code, you often want to return to your previous position. Instead of wasting time scrolling the file with your mouse, use this shortcut instead.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;macOS&lt;/strong&gt;: ⌃-&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Linux&lt;/strong&gt;: Ctrl + Alt + -&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Windows&lt;/strong&gt;: Alt+ ←&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yrYhWt9i--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://cdn-images-1.medium.com/max/3840/1%2A-02uh9oIZxh-lZjEdLZFdw.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yrYhWt9i--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://cdn-images-1.medium.com/max/3840/1%2A-02uh9oIZxh-lZjEdLZFdw.gif" alt="Go back" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Navigate To The Start/End of Current Word
&lt;/h2&gt;

&lt;p&gt;You can use this simple shortcut to move your cursor to either the left or right of the current word.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;macOS&lt;/strong&gt;: ⌥ + [← / →]&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Linux&lt;/strong&gt;: Ctrl + c&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Windows&lt;/strong&gt;: Ctrl + [← / →]&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--JZ-TyHf9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://cdn-images-1.medium.com/max/3840/1%2AiXkSFV_1BCeIZfL3-G84dw.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JZ-TyHf9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://cdn-images-1.medium.com/max/3840/1%2AiXkSFV_1BCeIZfL3-G84dw.gif" alt="Navigate to the start/end of the current word" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Select Multiple Occurrences Of The Same Word
&lt;/h2&gt;

&lt;p&gt;Let’s say you have some variable called &lt;em&gt;count&lt;/em&gt; and you want to select all the occurrences of the word one by one. You can use this shortcut to select all the occurrences one by one.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;macOS&lt;/strong&gt;: ⌘D&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Linux&lt;/strong&gt;: Ctrl + D&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Windows&lt;/strong&gt;: Ctrl + D&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xf15adEP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://cdn-images-1.medium.com/max/3840/1%2AjiRsjm1GJEQzwftZqxLRng.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xf15adEP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://cdn-images-1.medium.com/max/3840/1%2AjiRsjm1GJEQzwftZqxLRng.gif" alt="Select all cents variables" width="" height=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Move Line Up/Down
&lt;/h2&gt;

&lt;p&gt;You can use this shortcut to move an entire line of code up/down without using cut and paste.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;macOS&lt;/strong&gt;: ⌥↓ / ⌥↑&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Linux&lt;/strong&gt;: Alt + [↑ / ↓]&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Windows&lt;/strong&gt;: Alt + [↑ / ↓]&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wL_-Dkbx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://cdn-images-1.medium.com/max/3840/1%2AasjhbpreG_j-LztoucZERg.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wL_-Dkbx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://cdn-images-1.medium.com/max/3840/1%2AasjhbpreG_j-LztoucZERg.gif" alt="Move a line of code up/down" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  8. Show Search
&lt;/h2&gt;

&lt;p&gt;VS Code is very good at indexing the files inside a directory when you open an entire workspace. As a result, it can do a very good job of searching for words across many different files. I often use this shortcut when I’m looking for some word and I don’t know which file has this word. You can simply open the search explorer using this shortcut.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;macOS&lt;/strong&gt;: ⇧⌘F&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Linux&lt;/strong&gt;: Ctrl + Shift + F&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Windows&lt;/strong&gt;: Ctrl + Shift + F&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--oHozcuTT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://cdn-images-1.medium.com/max/3840/1%2Aztq4tyuZl4OhPSJFfP5i6g.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oHozcuTT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://cdn-images-1.medium.com/max/3840/1%2Aztq4tyuZl4OhPSJFfP5i6g.gif" alt="Show search explorer" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  9. Toggle line comment
&lt;/h2&gt;

&lt;p&gt;This is also another simple but very good shortcut. We often want to quickly comment and uncomment a line of code inside a file.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;macOS&lt;/strong&gt;: ⌘/&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Linux&lt;/strong&gt;: Ctrl + /&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Windows&lt;/strong&gt;: Ctrl + /&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--A0qp0dP8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://cdn-images-1.medium.com/max/3840/1%2AbBf2ltNjAVIzX_s00gBJAw.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--A0qp0dP8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://cdn-images-1.medium.com/max/3840/1%2AbBf2ltNjAVIzX_s00gBJAw.gif" alt="Toggle comment" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  10. Close Editor Window
&lt;/h2&gt;

&lt;p&gt;Let’s say you are done working with the current open editor tab and you want to close it. Then you can use this very simple but very simple shortcut to close the open editor tab.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;macOS&lt;/strong&gt;: ⌘W&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Linux&lt;/strong&gt;: Ctrl + W&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Windows&lt;/strong&gt;: Ctrl + W&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3aijuFt1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://cdn-images-1.medium.com/max/3840/1%2A9aojvwZuYLChNaFAK_3MOA.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3aijuFt1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://cdn-images-1.medium.com/max/3840/1%2A9aojvwZuYLChNaFAK_3MOA.gif" alt="Close editor tab" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;I hope you’ve learned something new from this article. Let me know your favorite shortcuts in the comment section. Here’s an official cheat sheet of vs code shortcuts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Windows: &lt;a href="https://code.visualstudio.com/shortcuts/keyboard-shortcuts-windows.pdf"&gt;https://code.visualstudio.com/shortcuts/keyboard-shortcuts-windows.pdf&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;macOS: &lt;a href="https://code.visualstudio.com/shortcuts/keyboard-shortcuts-macos.pdf"&gt;https://code.visualstudio.com/shortcuts/keyboard-shortcuts-macos.pdf&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Linux: &lt;a href="https://code.visualstudio.com/shortcuts/keyboard-shortcuts-linux.pdf"&gt;https://code.visualstudio.com/shortcuts/keyboard-shortcuts-linux.pdf&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>Scaling Databases in the Tech World: Best Practices Unveiled</title>
      <dc:creator>Nebiyu Elias Talefe</dc:creator>
      <pubDate>Sun, 05 Nov 2023 16:13:14 +0000</pubDate>
      <link>https://dev.to/nebiyuelias1/scaling-databases-in-the-tech-world-best-practices-unveiled-5c3n</link>
      <guid>https://dev.to/nebiyuelias1/scaling-databases-in-the-tech-world-best-practices-unveiled-5c3n</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;To build a successful digital product, you need to store lots and lots of data. Databases have become significantly better over the years to be able to store massive amounts of data. But when your product becomes so popular it means the workload on your database is going to grow. If your database is performing poorly then it can be a bottleneck for your application. You need to start thinking about strategies to help you deal with this growing demand.&lt;/p&gt;

&lt;p&gt;In this article, we will look at how popular platforms we use daily scale their database to an ever-increasing demand. As users of these popular platforms, we take things for granted and don't bother about the kind of things they have to do to ensure the availability of their service. It's no easy feat and requires a lot of ingenuity.&lt;/p&gt;

&lt;h2&gt;
  
  
  Database Scaling Strategies
&lt;/h2&gt;

&lt;p&gt;Whenever I think about scaling systems I like to use an analogy. Think of the road network in big cities around the world. As more and more people move into big cities to find better jobs and opportunities, the roads are going to become heavily crowded. You need to scale the transportation system, to deal with this growing demand. &lt;/p&gt;

&lt;p&gt;One strategy you can use is to make more roads, but this could be more costly. Another strategy you can use is to make the roads wider by extending the already existing ones. This approach is going to be a lot cheaper but you can’t keep adding more lanes to an already existing road network. You will be limited.&lt;/p&gt;

&lt;p&gt;There are different database scaling strategies, each with its advantages and disadvantages. The kind of approach you will choose will depend on your current situation and there is no one size fits all solution for everyone. But here are the popular strategies used to scale a database:&lt;/p&gt;

&lt;h3&gt;
  
  
  Vertical Scaling (Scaling Up)
&lt;/h3&gt;

&lt;p&gt;Vertical scaling involves increasing the resources (CPU, RAM, Storage) of a single server to handle growing demands. This is probably the easiest approach you can choose when you first encounter performance issues with your database. But you can’t simply keep adding more CPU or RAM to a single server, there is going to be a limit. It’s also worth mentioning that your expenses will go up as you keep adding more resources.&lt;/p&gt;

&lt;p&gt;In the case of the road scaling example mentioned earlier, this would be equivalent to making already existing roads wider by extension. &lt;/p&gt;

&lt;h3&gt;
  
  
  Replication
&lt;/h3&gt;

&lt;p&gt;To do this, you make replicas (duplicates) of your database. You might have one main database and multiple read replicas, as opposed to just one main database handling all reads and updates. The primary database is the first place you write data whenever you need to, followed by all of the read replicas. Any of the read replicas can be used to read data when necessary. &lt;/p&gt;

&lt;p&gt;This facilitates the scalability of programs in which users read a greater amount of data than they write (this is common in many applications, where users will read significantly more than they write). There are different approaches to implementing replication:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Asynchronous replication&lt;/strong&gt;: Whenever there is an update request from clients, the main database does not wait until the data is replicated on all the other read replicas. It simply acknowledges to the client that the update was successful and another process would do the replication in the background later.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Synchronous replication&lt;/strong&gt;: Whenever there is an update request from clients, the main database waits until the data is replicated on all the other read replicas. The update will not be complete until the replication is done.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Sharding
&lt;/h3&gt;

&lt;p&gt;Imagine having a gigantic table with thousands of rows. Things are going to become relatively difficult when dealing with such a table. With sharding, you partition the table rows into smaller chunks, called logical shards. Sharding is a horizontal scaling technique (oftentimes called scaling out) that allows you to distribute your data across multiple database nodes. The following diagram illustrates how one big table can be partitioned into smaller shards (chunks).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Ri0vV9C8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/91730bzmqrmo24n2vf87.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ri0vV9C8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/91730bzmqrmo24n2vf87.png" alt="Image description" width="800" height="1263"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Sharding Techniques
&lt;/h4&gt;

&lt;p&gt;There are different ways of partitioning your data horizontally, let’s look at some common techniques:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Key-based partitioning&lt;/strong&gt;: For this, you need a hash function, which is just a function that takes an input and produces a discrete set of outputs based on the input you’ve given to it. The hash function should produce the same output if the same input is used in the future. With key-based partitioning, you would use one of the columns of your table (something like user id) and give that to the hash function. This column is usually called a shard key. The hash function decides which partition this shard key should go to. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FyOaAAR5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6m6ov6sdeb8hre6y8sgi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FyOaAAR5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6m6ov6sdeb8hre6y8sgi.png" alt="Image description" width="800" height="581"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Range-Based Sharding&lt;/strong&gt;:  For this, you need to select a column that you can use to categorize your data. For example, if you have a table that stores items in a supermarket, you can use the price column to categorize the data. You can create categories such as &amp;lt; $50, &amp;lt; $100, and ≥ $100. Then your data could be partitioned based on the value it has for the price column. The items that have a price of less than $50 would go to one shard, the items that have a price greater than $50 but less than $100 would go to another shard, and so forth. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9Spnyqmv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/za3ce8etb3onc51h5xor.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9Spnyqmv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/za3ce8etb3onc51h5xor.png" alt="Image description" width="800" height="506"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Lookup Table-Based Sharding&lt;/strong&gt;: This technique is also called directory-based sharding. You need to have a directory (lookup table) that stores information about which shard to use for each shard key. For each shard key, you can randomly assign the shard it should go to. But you need to remember in the future which shard it is located in. That’s why we have the lookup table. It’s like a phone directory.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--AzLg7QE0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vah6o5l8k32rf1ykrfzm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--AzLg7QE0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vah6o5l8k32rf1ykrfzm.png" alt="Image description" width="800" height="688"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How Did Popular Platforms Handle Scalability Issues?
&lt;/h2&gt;

&lt;p&gt;Now let’s look at how engineers use their ingenuity to solve database performance problems.&lt;/p&gt;

&lt;h3&gt;
  
  
  Notion
&lt;/h3&gt;

&lt;p&gt;Notion, a popular note-taking app, hit 1 million users in 2019. That’s a significant milestone for any startup. But people started complaining about the slow performance of the app on X (FKA Twitter).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--k3pFChOH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/su2oaj6i0pio8arw5c8z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--k3pFChOH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/su2oaj6i0pio8arw5c8z.png" alt="Image description" width="427" height="539"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Before hitting 1 million users, Notion was using a PostgreSQL monolith. Notion engineers decided to use sharding their monolith into multiple distributed database nodes to improve the performance of their app.&lt;/p&gt;

&lt;p&gt;The breaking point came when a PostgreSQL process called &lt;a href="https://www.postgresql.org/docs/9.5/sql-vacuum.html"&gt;VACUUM&lt;/a&gt; started to stall. In PostgreSQL when you perform an update, the old record is not simply removed but saved on disk. This is because it’s not safe to directly modify existing data, as other transactions could be reading it. At a later point, you can run the VACUUM process to delete the old, outdated data and reclaim disk space. But in the case of Notion, this process started to become extremely slow. That’s when they decided to shard their database.&lt;/p&gt;

&lt;p&gt;However, after the sharding, they had to move data from their old database to their distributed database nodes. As you can imagine this is not easy because you don’t want to shut down your app while you have users who will be using it. So this is what they did to ensure they did the database migration while the app was functioning:&lt;br&gt;
    1. &lt;strong&gt;Double-write:&lt;/strong&gt; Incoming writes are applied to both the old and new databases.&lt;br&gt;
    2. &lt;strong&gt;Backfill:&lt;/strong&gt; Migrate the old data to the new database.&lt;br&gt;
    3. &lt;strong&gt;Verification:&lt;/strong&gt; Ensure the integrity of data in the new database.&lt;br&gt;
    4. &lt;strong&gt;Switch-over:&lt;/strong&gt; Actually switch to the new database. This can be done incrementally, e.g. double-reads, then migrate all reads.&lt;/p&gt;

&lt;p&gt;As a result of their work, people started noticing the performance improvement of the app. It’s always nice to see people appreciate your hard work.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6bi7JcZl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qz0f3n4fv58uumh0z1rj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6bi7JcZl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qz0f3n4fv58uumh0z1rj.png" alt="Image description" width="428" height="280"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Quora
&lt;/h3&gt;

&lt;p&gt;Quora is a social platform where users can post and answer questions on anything. The website receives more than 600 million visits per month.&lt;/p&gt;

&lt;p&gt;Quora is using MySQL for their database needs and they initially used read replicas to handle the large requests they were getting. But as the site became more popular, it was not enough. Data size stored in MySQL is of the order of tens of TB without counting replicas. Their queries per second (QPS) are in the order of hundreds of thousands.&lt;/p&gt;

&lt;p&gt;Here are some of the ways the Quora engineers tried to handle the increasing demand:&lt;/p&gt;

&lt;h4&gt;
  
  
  Vertical Sharding
&lt;/h4&gt;

&lt;p&gt;They were able to partition their database by moving some tables to a different MySQL host.&lt;br&gt;
If a certain table was getting very large or had lots of traffic, they created a new partition for that table. Each partition consists of a master node and replica nodes.&lt;/p&gt;

&lt;p&gt;The mapping from a partition to the list of tables in that partition is stored in &lt;a href="https://en.wikipedia.org/wiki/Apache_ZooKeeper"&gt;ZooKeeper&lt;/a&gt;.&lt;br&gt;
Vertical sharding enabled them to scale out, rather than always needing to scale up as our data size and QPS increased. There are some disadvantages to this approach.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When trying to move large tables from one partition to another, there is a replication lag for the slaves of the destination partition.&lt;/li&gt;
&lt;li&gt;It was impossible to do a join of tables that live in different partitions. Joins inside MySQL were strongly discouraged in the codebase&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Horizontal Sharding
&lt;/h4&gt;

&lt;p&gt;Vertical sharding was a good first step to scale the usage of MySQL, but individual tables can still grow very large. The engineers also decided to use horizontal sharding.&lt;/p&gt;

&lt;p&gt;Vertical sharding was a good first step to scale the usage of MySQL, but individual tables can still grow very large. The engineers also decided to use horizontal sharding.&lt;/p&gt;

&lt;p&gt;Horizontal sharding involves splitting a logical table into multiple physical tables, which are then referred to as shards of the table.&lt;/p&gt;

&lt;p&gt;When implementing sharding, engineers at Quora had to make quite a few decisions: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Build vs. Buy&lt;/strong&gt;: Quora decided to build an in-house solution rather than use a third-party MySQL sharding solution (Vitess for example).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Range-based sharding vs. Hash-based sharding&lt;/strong&gt;: Quora makes frequent use of range queries so they decided to use range-based sharding. Hash-based sharding performs poorly for range queries.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  GitHub
&lt;/h3&gt;

&lt;p&gt;Until recently, GitHub was built around one MySQL database cluster that housed a large portion of the data used for repositories, issues, pull requests, user profiles, etc. This MySQL cluster was called &lt;em&gt;mysql1&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;In 2019, GitHub set up a plan to improve their ability to partition their relational databases. Here are the steps they used to achieve this:&lt;/p&gt;

&lt;h4&gt;
  
  
  Virtual Partitions
&lt;/h4&gt;

&lt;p&gt;Before database tables are physically partitioned, they need to be virtually partitioned in the application layer. You can’t have SQL queries that span partitioned (or soon to be partitioned) database tables.&lt;/p&gt;

&lt;p&gt;In order to implement Virtual Partitioning, GitHub first created schema domains, where a schema domain describes a tightly coupled set of database tables that are frequently used together in queries.&lt;/p&gt;

&lt;p&gt;An example of a schema domain is the &lt;em&gt;gists&lt;/em&gt; schema domain, which consists of the tables &lt;em&gt;gists&lt;/em&gt;, &lt;em&gt;gist_comments&lt;/em&gt;, and &lt;em&gt;starred_gists&lt;/em&gt;. These tables would remain together after a partition.&lt;/p&gt;

&lt;p&gt;GitHub stored a list of all the schema domains in a YAML configuration file. Here’s an example of a YAML file with the gists, repositories and users schema domains and their respective tables.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5AZvpr9x--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rgfcu3nc1vadslzqghbw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5AZvpr9x--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rgfcu3nc1vadslzqghbw.png" alt="Image description" width="774" height="431"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, GitHub needed to enforce these schema domains. They want to make sure that application code doesn’t have SQL queries or transactions that span schema domains. They enforce this with SQL Linters.&lt;/p&gt;

&lt;h4&gt;
  
  
  Moving Data without Downtime
&lt;/h4&gt;

&lt;p&gt;Now that GitHub has virtually isolated schema domains, they can physically move their schema domains to separate database clusters.&lt;/p&gt;

&lt;p&gt;To do this on the fly, GitHub uses Vitess. Vitess is an open-source database clustering system for MySQL that was originally developed at YouTube.&lt;/p&gt;

&lt;p&gt;GitHub uses Vitess’ vertical sharding feature to move sets of tables together in production without downtime. To do that, GitHub uses Vitess’ VTGate proxies as the endpoint for applications to connect to instead of direct connections to MySQL. Vitess handles the rest.&lt;/p&gt;

&lt;p&gt;Since implementing these changes, GitHub has seen a significant decrease in load on the main database cluster.&lt;/p&gt;

&lt;p&gt;In 2019, &lt;em&gt;mysql1&lt;/em&gt; answered 950,000 queries per second on average, 900,000 queries per second on replicas, and 50,000 queries per second on the primary.&lt;/p&gt;

&lt;p&gt;In 2021, the same database tables were partitioned over several database clusters. The average load on each host &lt;em&gt;halved&lt;/em&gt; despite the total queries per second &lt;em&gt;increasing&lt;/em&gt; to 1,200,000 queries per second.&lt;/p&gt;

&lt;p&gt;For more details, you can read the full blog post &lt;a href="https://github.blog/2021-09-27-partitioning-githubs-relational-databases-scale/"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;It’s truly a big achievement to get adoption by users for your app. But once you start having lots of users, you will start to have performance issues. But one thing that is common among the popular platforms is that they started small and then once they started growing and noticed performance issues, they started to address it. So you should always keep that in mind. So you should always follow the KISS (Keep it simple stupid) principle and start to address performance issues when you notice them. Trying to optimize everything from the start is a form of overthinking. Don’t waste engineering resources in the earlier stage of your startup.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Premature optimization is the root of all evil” - Donald Kuth&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>database</category>
      <category>mysql</category>
      <category>postgres</category>
      <category>scaling</category>
    </item>
  </channel>
</rss>
