<?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: Tech Vision</title>
    <description>The latest articles on DEV Community by Tech Vision (@techvision).</description>
    <link>https://dev.to/techvision</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%2F1029365%2F773f554d-314c-4453-961e-7e2b08cb1cc0.png</url>
      <title>DEV Community: Tech Vision</title>
      <link>https://dev.to/techvision</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/techvision"/>
    <language>en</language>
    <item>
      <title>5 NodeJS Features You Probably Missed</title>
      <dc:creator>Tech Vision</dc:creator>
      <pubDate>Tue, 25 Jun 2024 17:01:30 +0000</pubDate>
      <link>https://dev.to/techvision/5-nodejs-features-you-probably-missed-1i5o</link>
      <guid>https://dev.to/techvision/5-nodejs-features-you-probably-missed-1i5o</guid>
      <description>&lt;p&gt;Are you wasting time installing unnecessary libraries and debugging your NodeJS applications the wrong way? Here are five built-in NodeJS features that can make your life easier and reduce your project's dependencies.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If you prefer the video version, here is the link 😉&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/FfmTkL2sMqE?start=86"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Dotenv Replacement
&lt;/h2&gt;

&lt;p&gt;Typically, we use the &lt;code&gt;dotenv&lt;/code&gt; library to manage environment variables. However, NodeJS now offers native support for this.&lt;/p&gt;

&lt;p&gt;Using --env-file Option:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;node &lt;span class="nt"&gt;--env-file&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;.env app.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using process.loadEnvFile (NodeJS v21+):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// server.js&lt;/span&gt;
&lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;loadEnvFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.env&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These methods eliminate the need for the &lt;code&gt;dotenv&lt;/code&gt; library, streamlining your development process.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Nodemon Replacement
&lt;/h2&gt;

&lt;p&gt;Instead of installing &lt;code&gt;nodemon&lt;/code&gt; to automatically restart your app on changes, use NodeJS's built-in watch mode.&lt;/p&gt;

&lt;p&gt;Run with --watch Option:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;node &lt;span class="nt"&gt;--watch&lt;/span&gt; app.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This built-in feature provides the same functionality as &lt;code&gt;nodemon&lt;/code&gt; without additional dependencies.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Built-in Test Runner
&lt;/h2&gt;

&lt;p&gt;Writing tests can be tedious, especially for side projects. NodeJS now includes a built-in test runner, removing the need for external libraries.&lt;/p&gt;

&lt;p&gt;Example Test File:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;assert&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;node:test&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;simple test&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;t&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;assert&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;strictEqual&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run Tests:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;node &lt;span class="nt"&gt;--test&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No more excuses for skipping tests!&lt;/p&gt;

&lt;h2&gt;
  
  
  4. UUID Generation
&lt;/h2&gt;

&lt;p&gt;Generating unique values is common in many projects. Instead of using the &lt;code&gt;uuid&lt;/code&gt; package, leverage NodeJS's crypto module.&lt;/p&gt;

&lt;p&gt;Generate UUID:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;randomUUID&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;crypto&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;randomUUID&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  5. Built-in Debugger
&lt;/h2&gt;

&lt;p&gt;Many developers still use console.log for debugging, which is inefficient. NodeJS offers a powerful built-in debugger.&lt;/p&gt;

&lt;p&gt;Run in Inspect Mode:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;node &lt;span class="nt"&gt;--inspect&lt;/span&gt; app.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using Chrome DevTools:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open Chrome and go to DevTools.&lt;/li&gt;
&lt;li&gt;Click the NodeJS icon.&lt;/li&gt;
&lt;li&gt;Use breakpoints and inspect objects efficiently.&lt;/li&gt;
&lt;/ol&gt;

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

&lt;p&gt;Happy Coding 👋! &lt;br&gt;
Thank you for reading the entire article; hope that's helpful to you.  &lt;/p&gt;

</description>
    </item>
    <item>
      <title>Using AI to Learn Programming?</title>
      <dc:creator>Tech Vision</dc:creator>
      <pubDate>Tue, 19 Mar 2024 17:06:37 +0000</pubDate>
      <link>https://dev.to/techvision/using-ai-to-learn-programming-52m0</link>
      <guid>https://dev.to/techvision/using-ai-to-learn-programming-52m0</guid>
      <description>&lt;p&gt;There are many ways to learn programming; in this post, I'll evaluate whether AI is a valid option. I've identified some shortcomings and some use cases where AI was beneficial. If you've used AI as part of your studies, let me know your experience and tips and tricks when using AI as a coding instructor.&lt;/p&gt;

&lt;p&gt;I have a video on this topic, and in the video, I asked chatGPT if it could teach me to code. &lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/mmT6MDD9tws"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  What is learning?
&lt;/h2&gt;

&lt;p&gt;A calculator wouldn't be beneficial when a kid is learning to add and subtract. Learning is about trying to come up with the answer by yourself. If you get into the habit of immediately reaching out to chatGPT for help, you are not learning. You have the illusion of learning, but you are not building a solid foundation. &lt;/p&gt;

&lt;p&gt;But there is also something specific about learning to code. Programming is a combination of problem-solving and translation. You must translate your thoughts and requirements into a sequence of instructions that a machine understands. Problem-solving and writing accurate machine instructions are skills that are acquired through practice. A question-answer interaction on chatGPT or generating code with a code assistant does not encourage you to develop the skills you need to become good at programming. Programming is challenging and complex, and every developer struggles at times. And it's by overcoming the challenges that you build durable skills. &lt;/p&gt;

&lt;h2&gt;
  
  
  AI Teacher Limitations
&lt;/h2&gt;

&lt;p&gt;It's easy to be amazed at what AI can do. But AI has limitations you should be aware of. Under the ChatGPT prompt, you will see the following warning message.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;ChatGPT can make mistakes. Consider checking important information.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9zcq3f2rnu16slxgwtog.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9zcq3f2rnu16slxgwtog.png" alt="ChatGPT Prompt Warnings" width="704" height="133"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Of course, the responses are pretty good and helpful most of the time. Otherwise, no one would use AI. But what if I told you, "I will lie to you at some point in this post?"  Naturally, you would become suspicious. From that point, you'll pay close attention to everything you're reading to see if I'm lying.&lt;/p&gt;

&lt;p&gt;That's my whole point: If someone is teaching you something, they should be fact-checking you, not the other way around. For example, if you don't know how AI works or what programming is and ask chatGPT, "Can you teach me programming?" how will you judge if the answer is accurate?&lt;/p&gt;

&lt;h2&gt;
  
  
  Can I still use AI despite its limitations?
&lt;/h2&gt;

&lt;p&gt;Despite the limitations, I think AI can still be used as a tool for learning. If you are still stuck after putting in the effort to try to understand a complex concept or solve a challenging coding problem, there is nothing wrong with asking an AI to help. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Firs6tz0relzlsznqzxfs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Firs6tz0relzlsznqzxfs.png" alt="ChatGPT Promt: Can you explain server caching as if I was a 10 years old" width="759" height="482"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But when the AI gives you the answer, don't stop there. Does the answer make sense to you? Can you test it? Does it work? Do you understand why it works? Remember, AI is not 100% accurate, so always stay on your guard.&lt;/p&gt;

&lt;p&gt;In my opinion, AI  shouldn't be your principal or your only studying resource; instead, it should complement another type of material. Material that you can trust and that is compatible with your learning style. &lt;/p&gt;

&lt;p&gt;I believe the ideal situation to get the best out of AI as part of your learning is to have prior knowledge before reaching out to the AI. I think of AI as a study partner rather than a teacher—a study partner who is super intelligent but who can still make mistakes. &lt;/p&gt;

&lt;h2&gt;
  
  
   My favourite use cases
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Road map and study plans
&lt;/h3&gt;

&lt;p&gt;Something that I do before I start tackling a complex or vast study topic is ask chatGPT for a summary of the topic. Then, when I dive into the subject in detail, I know how the different parts relate to the bigger picture. &lt;/p&gt;

&lt;h3&gt;
  
  
  Summary and high-level view of a topic
&lt;/h3&gt;

&lt;p&gt;When I need a shallow understanding of an area, I feel quite confident asking ChatGPT about a high-level explainer. Especially if it's a topic that is well documented. I have found it much faster and more efficient than a google search.&lt;/p&gt;

&lt;h3&gt;
  
  
  Generating quiz questions
&lt;/h3&gt;

&lt;p&gt;After I finish a course or a book, I ask ChatGPT to quiz me on the topic I just studied. Even if the questions are not always great, at least I have some level of testing. &lt;/p&gt;




&lt;p&gt;I have mostly talked about ChatGPT and not so much about code assistant. You might disagree with me, but check out this this &lt;a href="https://youtu.be/9IzjrOnYrkA?si=H4XMR014KOy3kQW7" rel="noopener noreferrer"&gt;video&lt;/a&gt; to know what I think about using them in your workflow. &lt;/p&gt;

</description>
      <category>ai</category>
      <category>discuss</category>
      <category>chatgpt</category>
      <category>learning</category>
    </item>
    <item>
      <title>Stop Using AI, Use These Proven Coding Practices instead</title>
      <dc:creator>Tech Vision</dc:creator>
      <pubDate>Mon, 11 Mar 2024 17:40:54 +0000</pubDate>
      <link>https://dev.to/techvision/stop-using-ai-use-these-proven-coding-practices-instead-59op</link>
      <guid>https://dev.to/techvision/stop-using-ai-use-these-proven-coding-practices-instead-59op</guid>
      <description>&lt;p&gt;Using an AI code assistant isn't like having an expert programmer do all the hard work for you. After a year of using it, I've come to see its limitations. In this post, I'll show you how relying too much on AI can slow down your progress and pose risks. Instead, I suggest three underappreciated practices that can help any developer improve.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If you prefer the video version, here is the link 😉&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/9IzjrOnYrkA"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  AI Slows you down
&lt;/h2&gt;

&lt;p&gt;To learn how to cycle, you simply jump on a bike and give it a try. The same principle applies to learning to code or use a new library or technology. You'll make mistakes, but you'll learn from them. Ultimately, by doing the hard work, you'll acquire new skills in a lasting way.&lt;br&gt;
However, using an AI code assistant may deprive you of this crucial element of the learning process. It can slow your progression because it eliminates the opportunity for growth through trial and error.&lt;/p&gt;

&lt;h2&gt;
  
  
  You can't trust AI
&lt;/h2&gt;

&lt;p&gt;Yes, AI is great at giving you quick answers. But a quick answer doesn't necessarily mean correct. AI models are trained on real-world data samples that may contain incorrect information. The answers provided are more or less the average answer obtained from the available data and are not specifically tailored to your needs.&lt;/p&gt;

&lt;p&gt;AI code assistants have another limitation that prevents them from coming up with the correct answer every time. The code assistant works with a limited context. Sometimes, the context is limited to the source file you are working with. But even if the model takes the entire source code as context, something will always be missing.&lt;/p&gt;

&lt;p&gt;An AI code assistant doesn't know the initial requirement, the project history, or the end user's behaviour. When you code,  you translate an intention, an expected behaviour, into machine instructions. And that can be very subtle because those intentions and requirements come from humans. Humans don't give clear instructions. Sometimes, they don't even know what they want. Your job as a developer is to convert fuzzy, unclear requirements into a set of precise machine instructions.&lt;/p&gt;

&lt;p&gt;That's my second main issue with AI: You can't fully trust the accuracy of the answers it gives you. Please do not fall into the trap of thinking that an AI code assistant is an expert developer; it simply can't be because it takes more than writing code to be an expert. It has to be very clear in your mind that an AI code assistant is just that, an assistant.&lt;/p&gt;

&lt;h2&gt;
  
  
  AI won't take responsibility
&lt;/h2&gt;

&lt;p&gt;AI code assistants usually generate correct answers, but what happens when they don't? Who's responsible if AI-generated code leads to bugs?&lt;/p&gt;

&lt;p&gt;You are still the one responsible for the code you publish, even if you didn't write it yourself. If you decide to use code you don't understand just because it seems to work; you still need to maintain it. What happens when you need to make changes or debug the generated code?&lt;/p&gt;

&lt;p&gt;The third reason why I  discourage AI code assistants is if you put the AI assistant in charge. Not only that's a not professional attitude, but it can also lead to real-world consequences for the product you're building and your career. What if you join a company where AI is not allowed? So make sure you stay the one in control.&lt;/p&gt;

&lt;p&gt;Ok, you want to stay in charge; you want to put in the hard work yourself because, ultimately, that will make you a better programmer. But everyone gets stuck at some point and needs help. Before jumping straight to chatGPT, I will give you three alternatives that can be much more beneficial for you, especially if you care about your career progression.&lt;/p&gt;

&lt;h2&gt;
  
  
  Read Documentation
&lt;/h2&gt;

&lt;p&gt;Coding requires knowledge of programming languages, libraries, and frameworks, as well as building, running, and deploying code. And that's a lot. Fortunately, the creators of these tools provide instructions to help. There is genuinely fantastic documentation out there. I'm not suggesting you go out there and read all of it or start reading programming language specifications. &lt;/p&gt;

&lt;p&gt;Here is what I recommend you do. If you use a library, open the documentation and read the titles. Go quickly through the different chapters; if there are some diagrams, images, highlighted sections, or summaries, read that as well. When you do that, you become aware of what's available and what's not. &lt;/p&gt;

&lt;p&gt;If you've used ChatGPT, you know that it's very eager to give you an answer no matter what. If you ask for a feature that doesn't exist, it might hallucinate and give you misleading answers.&lt;/p&gt;

&lt;p&gt;My first recommendation is to skim-read documentation. You'll gain more awareness of what's possible, and next time you're stuck, you'll know where to find the answer. And you'll know you can trust that answer. &lt;/p&gt;

&lt;h2&gt;
  
  
  Use a good old Google search
&lt;/h2&gt;

&lt;p&gt;However, you can't always find answers in the documentation. Sometimes, you just don't know where to find the solution. This may be slightly controversial, but I recommend a good old Google search. &lt;/p&gt;

&lt;p&gt;When you get a result from Google, you know the source and the context in which this information is produced. For example, on our beloved StackOverflow, you can see how old posts and answers are. Not only that, you can also see the back and forth in the comments and different versions of an answer.&lt;/p&gt;

&lt;p&gt;Yes, of course, an AI can give you an answer, but if you are not actively asking for alternative solutions or nuances, you most likely won't get them from an AI-generated answer. It is undoubtedly the most challenging and slowest, but it leads you further.   &lt;/p&gt;

&lt;h2&gt;
  
  
  Helping Others
&lt;/h2&gt;

&lt;p&gt;I'm sure that has already happened to you, but sometimes you get asked a question, Google it, and give the answer. Then you appear to be smart when, in reality, you just google it. Surely, the person asking the question could have done the same. That shows that knowing how to search and where to find the relevant information is a skill in itself.&lt;/p&gt;

&lt;p&gt;And that brings me to something that I only realised recently. It's something that we all tend to do naturally. But turning it into a habit can transform how others see you. And that's simply helping others. When you struggle with a piece of code and finally make it work, when you spend hours on a complex concept and it finally clicks, consider sharing. One very powerful way of consolidating that new skill or piece of knowledge is to teach it. &lt;/p&gt;

&lt;p&gt;But there are other ways you can help: write documentation, do pair programming, and review code. When you focus some of your attention on solving other people's problems, good things happen. You feel good, and people want to work with you. People around you will value your opinion and give you more responsibilities.&lt;/p&gt;

&lt;p&gt;But it all starts by putting in the effort, doing the work yourself, and not taking shortcuts. &lt;/p&gt;




&lt;p&gt;Let's be clear: I'm not against using AI as part of your workflow. AI code assistants will become an unavoidable tool for every developer as they improve. But just like every tool, it's good to understand when to use it. &lt;/p&gt;

</description>
      <category>ai</category>
      <category>productivity</category>
      <category>tooling</category>
      <category>chatgpt</category>
    </item>
    <item>
      <title>You need a Proxy Server to proctect you 🛡️🐞</title>
      <dc:creator>Tech Vision</dc:creator>
      <pubDate>Wed, 21 Feb 2024 21:35:31 +0000</pubDate>
      <link>https://dev.to/techvision/you-need-a-proxy-server-to-proctect-you-b5k</link>
      <guid>https://dev.to/techvision/you-need-a-proxy-server-to-proctect-you-b5k</guid>
      <description>&lt;p&gt;The Internet is an essential tool in our lives, but at the same time, it poses significant risks. Governments and companies actively fight against cyber threats and try to protect their users and assets, and you should do the same.&lt;/p&gt;

&lt;p&gt;If you prefer the video version, here is the link 😉:&lt;br&gt;
&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/oy1I02V4JKs"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  What's a proxy server?
&lt;/h2&gt;

&lt;p&gt;Using a Proxy Server is one way to make the Internet safer for users. In networking terms, a client sends a request to a server. For example, when you type a URL in your browser, your browser is the client, and the server is the web server that hosts the website you want to visit. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvrpu070u6trh70xnyt04.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvrpu070u6trh70xnyt04.gif" alt="Client Server communication flow animation" width="1280" height="720"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A proxy server acts as a middleman between the client and the server. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It forwards the request from the client to the web server and sends the response back to the client via the proxy server.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmtwv97r7o2laxvrwt5xf.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmtwv97r7o2laxvrwt5xf.gif" alt="Client Server communication through Proxy flow animation" width="1280" height="720"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How does a proxy server protect you?
&lt;/h2&gt;

&lt;p&gt;A proxy server can be configured to filter the network traffic. For example, it can detect malicious content and block it. It can also block access to certain websites or categories of websites that are deemed malicious or inappropriate. A proxy server used to protect the client is called a &lt;strong&gt;forward proxy&lt;/strong&gt;. You'll see later that there is another type of proxy server. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk64qe630feoq0tinpstq.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk64qe630feoq0tinpstq.gif" alt="Forward proxy animation flow" width="1280" height="720"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On top of that, it would be hard for an attacker to target you personally. As far as the external network is concerned, you don't exist. Only the proxy is visible. The proxy server gives you an additional layer of security and privacy. &lt;/p&gt;

&lt;p&gt;Moreover, the proxy server can even increase the speed of your requests. It can &lt;a href="https://dev.to/techvision/make-your-app-faster-use-caching-2f6d"&gt;cache&lt;/a&gt; the responses from the server and serve them directly to the client. Your request doesn't have to go all the way to the server and back.&lt;/p&gt;

&lt;h2&gt;
  
  
  Does a proxy server give you freedom?
&lt;/h2&gt;

&lt;p&gt;But you could be in a context where you feel like some content is unfairly restricted or censored. In that case, you could use a proxy server to bypass the censorship. Instead of sending the request directly to the server, you send it to the proxy server, which forwards it to the server. As long as the proxy server itself is not blocked, you can access the restricted content.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdcokp5x9tpz6uynl4nif.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdcokp5x9tpz6uynl4nif.gif" alt="Bypass Restriction through proxy server animation" width="1280" height="720"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A proxy server can bypass restrictions, but it can also monitor and log user activity. Activity logs can be collected for compliance, auditing, analytics, security monitoring, etc. The critical point is that if you go through a proxy, ensure it's trustworthy and understand how your data is used.&lt;/p&gt;

&lt;p&gt;A forward proxy server protects internal clients from external threats, but what about the other way around? What if you want to protect your server from external clients?&lt;/p&gt;

&lt;h2&gt;
  
  
  Do proxy servers only protect clients?
&lt;/h2&gt;

&lt;p&gt;Indeed, you can apply the same principle. You would have a Proxy server that sits between the server and the client. This time, the proxy server is called a &lt;strong&gt;reverse proxy&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frnyph68gett92kefjx55.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frnyph68gett92kefjx55.png" alt="Reverse Proxy" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Since the reverse proxy server is the only one visible from the outside, that's where you can put your security measures to protect the servers in the internal network. The reverse proxy server can be used to block malicious content and detect/prevent cyber attacks like DDoS. NGINX and Cloudflare are examples of providers of reverse proxy servers that are very popular and provide such features.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reverse proxies are  not just about security
&lt;/h2&gt;

&lt;p&gt;But on top of security, reverse proxy servers can also improve system performance. They can cache the responses from the internal servers and serve them directly to the client. However, the reverse proxy server cannot cache all types of responses. In those situations where you can't rely on caching, you could use more than one server to handle the load. Guess what? A reverse proxy can route the requests to the different servers and act as a load balancer.&lt;/p&gt;




&lt;p&gt;Proxy servers are incredibly versatile and can enhance the client's and server's security and performance. They are essential in any network. Understanding this concept is fundamental because it forms the basis of many other concepts, such as CDN, load balancer, microservices gateway services, and many more. &lt;/p&gt;

</description>
      <category>systemdesign</category>
      <category>performance</category>
      <category>architecture</category>
      <category>security</category>
    </item>
    <item>
      <title>Make your website faster - Use a CDN 💨⚡️</title>
      <dc:creator>Tech Vision</dc:creator>
      <pubDate>Wed, 21 Feb 2024 18:25:16 +0000</pubDate>
      <link>https://dev.to/techvision/make-your-website-faster-use-a-cdn-3h3c</link>
      <guid>https://dev.to/techvision/make-your-website-faster-use-a-cdn-3h3c</guid>
      <description>&lt;p&gt;If your website is hosted in Cape Town, South Africa, and your users are located all over the globe, the time it takes to load for a user in New York is much longer than for a user in Johannesburg. The data has to travel a longer distance to reach the user in New York. It would be great if you could move your website closer to your users. Be at multiple places at once. That is precisely what A Content Delivery Network (CDN) does.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If you prefer the video version, here is the link 😉&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/gMifT7d-7Z8"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Data propagation
&lt;/h2&gt;

&lt;p&gt;When you use a CDN, you deploy your website file on the &lt;strong&gt;Origin Server&lt;/strong&gt;. The Origin server hosts the most up-to-date version of the website. Your website files must be copied from the origin server and transferred to the Edge Servers. The &lt;strong&gt;edge servers&lt;/strong&gt; are located at very strategic points around the globe. Usually on principal data routes, at the intersection of the main internet backbones, and closer to Internet Service Provider infrastructure. &lt;/p&gt;

&lt;h3&gt;
  
  
  Push CDN
&lt;/h3&gt;

&lt;p&gt;Two approaches exist to copy the files from the Origin Server to the Edge Servers. In the first approach, you (or the origin server) send the new website files to the edge servers. That option is the &lt;strong&gt;push&lt;/strong&gt; approach. The push approach is more flexible but not ideal for data that changes often. Netflix uses this approach in their Open Connect CDN to push new content to the Edge Servers during low network traffic hours.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fal1prirxx1wa1osw1a4g.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fal1prirxx1wa1osw1a4g.gif" alt="Push CDN Caching animation" width="1280" height="720"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Pull CDN
&lt;/h3&gt;

&lt;p&gt;The second option is the &lt;strong&gt;pull&lt;/strong&gt; approach. The Edge Servers pull the data from the Origin Server. This is the most common method. Usually, this can be done automatically and needs configuration with the CDN provider. The data pull happens at regular intervals or when the file is requested for the first time. The pool approach is suitable for data that changes often. For example, a news website can use this method to pull the latest news articles from the Origin Server.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feorayvlgx7kv7wemg35v.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feorayvlgx7kv7wemg35v.gif" alt="Pull CDN Caching animation" width="1280" height="720"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The data cached on the edge server can have a &lt;strong&gt;Time To Live&lt;/strong&gt; (TTL) value. This is the time the data is considered valid. After this time, the data is considered stale, and the Edge Server will pull a fresh copy from the Origin Server. TTL value can be a few seconds or days, depending on the use case.&lt;/p&gt;

&lt;p&gt;Once the data is on the Edge Servers, the end users should be able to access the data from those servers and get a faster response time.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frr96g5c9wehgbo4n2mg6.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frr96g5c9wehgbo4n2mg6.gif" alt="CDN client accessing edge server" width="1280" height="720"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But how does the user's browser know it should get the data from the Edge Server, not the Origin Server? &lt;/p&gt;

&lt;h2&gt;
  
  
  DNS Resolution
&lt;/h2&gt;

&lt;p&gt;Without a CDN, when a user wants to access your website, the user's browser sends a DNS request to the DNS server. The DNS server returns the IP address of the Origin Server. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F97c5yup740zshbzbybe0.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F97c5yup740zshbzbybe0.gif" alt="Single IP DNS resolution animation" width="1280" height="720"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With a CDN, your website now has multiple IP addresses—one for each Edge Server. When the user's browser sends a DNS request, the DNS server returns the Edge Server's IP address closest to the user. The user's browser sends an HTTP request to the Edge Server and gets the data.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb9f3shl580okxub7yaic.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb9f3shl580okxub7yaic.gif" alt="Multi IP DNS resolution animation" width="1280" height="720"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That explanation is a massively simplified version of what happens. In reality, A CDN network can have multiple layers. For example, the CDN network can be organised into a hierarchy with a main Regional Server on top of the hierarchy and then a set of Edge Servers closer to the end users. Load balancers might be involved. Routing can be done via Anycast, a routing technique that sends data to the nearest server with the same IP address. &lt;/p&gt;

&lt;p&gt;The critical point is that the "N" in CDN stands for Network, and the servers work together to deliver the content to the user most efficiently. The fact that it's a network makes it so powerful and enables more than just faster load times.&lt;/p&gt;

&lt;h2&gt;
  
  
  Power of the Network
&lt;/h2&gt;

&lt;p&gt;A CDN  does more than deliver content. It can also protect your website from &lt;a href="https://en.wikipedia.org/wiki/Denial-of-service_attack#Distributed_DoS_attack" rel="noopener noreferrer"&gt;DDoS&lt;/a&gt; attacks. The CDN network can detect this and block the malicious traffic before it reaches the Origin Server. Usually, CDN providers have measures in place to detect and mitigate DDoS attacks. However, the mere fact that there are multiple servers around the globe makes it harder for an attacker to take down your website.&lt;/p&gt;

&lt;p&gt;And, of course, because you now have a network of servers working together, the overall traffic load is distributed across the Network. This means that the Origin Server is not overwhelmed with requests and can focus on other tasks. And if a given Edge Server is overwhelmed, the traffic can be rerouted to another Edge Server. By using a CDN, you can make your website more resilient and scalable.&lt;/p&gt;

&lt;p&gt;We've taken a website as an example, but a CDN can be used for various content types. You could use a CDN only for your media content and leave the rest of the website on the Origin Server. Some CDN providers offer data transformation services. For example, they deliver images in different formats and sizes depending on the user's device. Traditionally, CDNs are used for static content but can also be used for dynamic content. For example, a CDN can cache the result of an API call and serve it to the user.&lt;/p&gt;




&lt;p&gt;Even if things can get quite complex, the main idea is simple;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;You put copies of your data across multiple strategic locations around the globe in Edge Servers. An edge server is simply a &lt;a href="https://www.youtube.com/watch?v=oy1I02V4JKs" rel="noopener noreferrer"&gt;proxy server&lt;/a&gt; with a &lt;a href="https://www.youtube.com/watch?v=DbSuaxPxqXo" rel="noopener noreferrer"&gt;cache&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Users get the data from the closest location, which is faster.&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;As a bonus, here are some links to some of the most popular CDN providers&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.akamai.com/solutions/content-delivery-network" rel="noopener noreferrer"&gt;Akamai&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.cloudflare.com/application-services/products/cdn/" rel="noopener noreferrer"&gt;Cloudflare&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/cloudfront/" rel="noopener noreferrer"&gt;Amazon CloudFront&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://cloud.google.com/cdn?hl=en#how-it-works" rel="noopener noreferrer"&gt;Google Cloud CDN&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webdev</category>
      <category>performance</category>
      <category>systemdesign</category>
      <category>architecture</category>
    </item>
    <item>
      <title>Make your app faster - Use Caching 💨⚡️</title>
      <dc:creator>Tech Vision</dc:creator>
      <pubDate>Sat, 17 Feb 2024 10:45:23 +0000</pubDate>
      <link>https://dev.to/techvision/make-your-app-faster-use-caching-2f6d</link>
      <guid>https://dev.to/techvision/make-your-app-faster-use-caching-2f6d</guid>
      <description>&lt;p&gt;Speed is currency. Fast, responsive applications not only retain users but also boost revenue. One way to improve performance is through caching. Let's see what caching is and how it enhances performance. We'll also see how caching goes beyond performance and has other benefits.&lt;/p&gt;

&lt;p&gt;If you prefer the video version here is the link 😉:&lt;br&gt;
&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/DbSuaxPxqXo?start=1"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  What's caching?
&lt;/h2&gt;

&lt;p&gt;Any interaction between two entities involves computation time and data transport time. To increase the interaction speed, we need to reduce those two factors. In a network interaction, we might want to reduce the transport time, while in the case of an application querying a database, we might want to optimise the query computation.&lt;/p&gt;

&lt;p&gt;Caching is a technique that aims to reduce response time by taking a shortcut instead of going through the whole interaction. The idea is to store the result of an expensive computation or the result of a previous interaction and reuse it when the same computation or interaction is needed again.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl3q6co74gm0wbjlo1bra.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl3q6co74gm0wbjlo1bra.gif" alt="Caching overview animation" width="1280" height="720"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Caching everywhere
&lt;/h2&gt;

&lt;p&gt;Let's take your browser as an example. When you visit a website, your browser stores the files that make up the website on your hard drive. The next time you visit the website, your browser will load the files from your hard drive instead of downloading them again from the server.&lt;/p&gt;

&lt;p&gt;Caching is not limited to the browser. A CDN server could be sending you a cached version of the website you are visiting. A server could send a cached response instead of generating a new response for each request or querying fresh data from a database. Databases themselves have a cache. They might cache frequent queries and save on lookup time. Caching goes all the way to the hardware. CPUs have a sophisticated caching mechanism that optimises computation time and reduces access to slow hard drive memory.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6em1oyjrfgomsl3ay1mo.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6em1oyjrfgomsl3ay1mo.gif" alt="Caching of network call at different stages" width="1280" height="720"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see, caching happens at different levels and places. No matter when and where it happens, the principle is the same: we want to move the data closer to the consumer and potentially use more performant storage.&lt;/p&gt;

&lt;h2&gt;
  
  
  Dealing with stale data
&lt;/h2&gt;

&lt;p&gt;If the data at the source changes, the cached data is considered stale. A common approach to deal with stale data is to set a time to live (TTL) for the cached data. When data has passed its TTL he data is considered stale, and the next time the data is requested, the cache will fetch the data from the source and store it again. Other strategies involve invalidating the cache when the source data changes, either by pushing the change to the cache or by having the cache check the source for changes.&lt;/p&gt;

&lt;p&gt;Cache storage is limited in size and requires &lt;strong&gt;cache eviction&lt;/strong&gt; when the capacity is reached. Strategies for cache eviction include removing the least recently used, least frequently used, or most expensive data. The chosen strategy depends on the use case and caching implementation.&lt;/p&gt;

&lt;p&gt;Caching adds complexity to your system. You should only add caching when you have identified a performance problem and measured that caching will solve it. &lt;/p&gt;

&lt;p&gt;Even if performance is not a primary concern, there are other reasons you might want to use caching.&lt;/p&gt;

&lt;h2&gt;
  
  
  Hidden benefits
&lt;/h2&gt;

&lt;p&gt;You could have a server that receives a high volume of requests. For each request, your server sends a query to your database. Your server could handle the load, but your database might not. If you have a cache in front of the database, you can reduce the load and improve the overall system performance.&lt;/p&gt;

&lt;p&gt;Every query sent to your database requires computation resources. Additionally, if your database is not part of your server, each query may require a network call. Remember that network traffic and computation time are not free. You could make substantial savings on your cloud or infrastructure bill if your server caches query results.&lt;/p&gt;




&lt;p&gt;Caching is a powerful technique to improve performance. It's not only about reducing response time; it's also about reducing the load on the source and the network. Caching adds complexity to your system, so use it when you have identified a performance issue worth solving.&lt;/p&gt;

&lt;p&gt;Caching is a fundamental concept to understand. Understanding caching will help you understand other concepts such as CDN, Load Balancer, &lt;a href="https://www.youtube.com/watch?v=oy1I02V4JKs" rel="noopener noreferrer"&gt;Proxy server&lt;/a&gt;, etc.&lt;/p&gt;

</description>
      <category>systemdesign</category>
      <category>database</category>
      <category>performance</category>
    </item>
    <item>
      <title>Microservices Architecture - A Beginner-friendly overview</title>
      <dc:creator>Tech Vision</dc:creator>
      <pubDate>Wed, 07 Feb 2024 17:41:36 +0000</pubDate>
      <link>https://dev.to/techvision/microservices-architecture-a-beginner-friendly-overview-45oi</link>
      <guid>https://dev.to/techvision/microservices-architecture-a-beginner-friendly-overview-45oi</guid>
      <description>&lt;p&gt;In a Microservices Architecture, several services constitute the whole application. Each service can run on different machines or in a different process. A service provides some functionality and can expose some information.&lt;/p&gt;

&lt;p&gt;If you prefer the video version here is the link 😉:&lt;br&gt;
&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/1zDR-ffD0jI"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Solving the Monolith Architecture
&lt;/h2&gt;

&lt;p&gt;In the Monolith architecture, everything in an app is bundled together, usually within the same codebase. This allows easy code sharing and simple internal communication via function calls. And can enable simple tracing and debugging.&lt;/p&gt;

&lt;p&gt;However, the monolith architecture has its limitations. All teams must use the same technology stack. Migrating to a new technology can be difficult, risky and costly. Teams must coordinate before releasing changes. Minor changes, even fixing a typo, require redeploying the whole application. On top of that, there is no easy way to give more resources (CPU, memory) to specific parts of the application. The whole application must be scaled, even if only a single part needs more resources.&lt;/p&gt;

&lt;p&gt;The Microservices architecture is an alternative to the Monolithic architecture. It tries to overcome these limitations by dividing the application into smaller, independent services that can be developed, deployed and scaled independently. However, this approach introduces new challenges. Tracing requests across multiple services can be challenging, and failure in one service can cascade to other services. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjycfdedm3lf62fl9tgay.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjycfdedm3lf62fl9tgay.gif" alt="Microservices cascading failure animation"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;However, there are patterns and best practices that can help build a reliable system.&lt;/p&gt;

&lt;h2&gt;
  
  
  Implementing Microservices the Right Way
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Independent deployability&lt;/strong&gt; is a simple concept but takes a lot of discipline and deliberate effort to achieve. Services need to be loosely coupled. To achieve loose coupling, the system is split into services based on business capabilities or business domains. For example, a video streaming application can have a user service, a video service, a recommendation service, and so on. &lt;/p&gt;

&lt;p&gt;Another critical aspect is ensuring the services &lt;strong&gt;hide internal implementation and internal information&lt;/strong&gt;. As a result, each service will have its own database or at least its own database area. Services will expose their capabilities through an API.&lt;/p&gt;

&lt;p&gt;Services can send requests to each other using Inter-Process Communication (IPC) technologies. There are several options, but REST, gRPC, and message brokers are the most popular. REST has a wide adoption and can be easier for interoperability. gRPC is more performant and provides a clear API schema. Message brokers are great for asynchronous communication and can allow even more decoupling. It's also quite common to have a gateway service that acts as an interface between the internal domain services and external applications. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fndg1e122eahmfzbtg5uo.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fndg1e122eahmfzbtg5uo.gif" alt="Microservices Internal and external communication flow animation"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;By splitting services by business domain and hiding internal information,  changes to one service should not require modifications to another service, and there is a better chance of achieving independent deployability. But why so much emphasis on independent deployability?&lt;/p&gt;

&lt;h2&gt;
  
  
  The power of Microservices
&lt;/h2&gt;

&lt;p&gt;The idea is that focusing on independent deployability capabilities unlocks other benefits. Because the services have clear boundaries and are loosely coupled, it makes it possible to build teams that can work independently. Each team will be responsible for one or a group of services.&lt;/p&gt;

&lt;p&gt;Teams can choose the technology stack that best fits their needs. They can make changes to their services and deploy without coordinating with other teams. Or at least with minimal coordination. Not to mention that each service can scale independently. This is where the Microservices Architecture shines; it gives teams flexibility.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;With great power comes great responsibility.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It takes a lot of work to build a reliable distributed system. In an attempt to reduce complexity, It's not uncommon for organisations to impose some restrictions on the technology stack or the approach to use. For example, teams may deploy their services as docker containers managed by Kubernetes in the cloud. This is a fairly common infrastructure setup. And more often than not, organisations rely on cloud providers such as AWS, Azure, or Google Cloud to provide the infrastructure. The same goes for other services such as databases, message brokers, etc.  &lt;/p&gt;




&lt;p&gt;Using Microservices Architecture has broad implications, and &lt;a href="https://youtu.be/bbsARIDyBf8" rel="noopener noreferrer"&gt;it's not a silver bullet&lt;/a&gt;. It's a complex architecture that requires technical expertise and implies organisational changes and consideration of how the teams are structured. But when applied correctly, it can be very powerful and allow teams to build large, scalable and reliable applications. And it provides a high degree of flexibility.&lt;/p&gt;

</description>
      <category>microservices</category>
      <category>systemdesign</category>
      <category>architecture</category>
      <category>backend</category>
    </item>
    <item>
      <title>MongoDB - Animated, beginner overview</title>
      <dc:creator>Tech Vision</dc:creator>
      <pubDate>Sun, 04 Feb 2024 11:50:52 +0000</pubDate>
      <link>https://dev.to/techvision/mongodb-animated-beginner-overview-1m70</link>
      <guid>https://dev.to/techvision/mongodb-animated-beginner-overview-1m70</guid>
      <description>&lt;p&gt;I love MongoDB, and I'm not the only one. I will tell you why I and so many other developers love it. Of course, other options exist on the market, so we will also see what makes document stores, particularly MongoDB, so different.&lt;/p&gt;

&lt;p&gt;If you prefer watching videos here is a link 😉&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/rLDc7sQrXlM?start=1"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  How easy is it?
&lt;/h2&gt;

&lt;p&gt;To start with, MongoDB is free and open-source. The setup is straightforward; you can install and run it on your computer in a few minutes. You can use command lines or a programming language to interact with the database. They've got support for the most popular programming languages through drivers. For example, you can use JavaScript or Python.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F62xkmvrijfpolmb2hg70.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F62xkmvrijfpolmb2hg70.gif" alt="MongoDB Key value pair,JSON format and document collection animation" width="542" height="304"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;MongoDB is a document store. So, what's a document? Picture a Restaurant bill. For each item you've ordered, there is the name of the item and the price. A document is very similar. It's a series of what we call key value Pairs. Documents representing the same type of data, like Restaurant bills, will be grouped in a collection. &lt;/p&gt;

&lt;p&gt;The good thing about documents in MongoDB is that they can be represented as JSON. JSON is a very popular data format. It's everywhere on the web, and many APIs expose their data in that format. When developers work with MongoDB, it feels natural and familiar. In short, MongoDB is very easy to pick up.&lt;/p&gt;

&lt;h2&gt;
  
  
  What makes it different?
&lt;/h2&gt;

&lt;p&gt;One key feature of MongoDB is that it's schema-less. You don't have to define the structure of your data before you start using it. You can start adding data to your database, and your data structure can evolve over time. This is great for developers because it means they can be very flexible and iterate quickly.&lt;/p&gt;

&lt;p&gt;And, of course, MongoDB has all the features you would expect from a robust database, including indexing and advanced querying capabilities through its aggregation framework. It also offers unique features like geospatial queries, time series data management, change streams, and many more.&lt;/p&gt;

&lt;p&gt;Ease of use and flexibility are great, but more is needed to convince entire teams and organizations to switch to a new technology. Modern applications tend to be data-intensive. So, how does MongoDB solve the scaling problem? &lt;/p&gt;

&lt;h2&gt;
  
  
  How does it scale?
&lt;/h2&gt;

&lt;p&gt;A popular Mantra in MongoDB world is. "data that is accessed together should be stored together". This means that a document needs to be a self-contained unit of data. If you have an application that displays students and the classes they attend, you can store in the student document the student information of course and the classes they attend. &lt;/p&gt;

&lt;p&gt;In other databases, known as relational databases, strict data separation by type is heavily encouraged. Students, classes and the link between them would be stored separately. When the application needs to display students,  student and class data must be put back together. However, if you have everything stored in the same document, it makes it faster to query that data.&lt;br&gt;
Because a document is a self-contained unit of data, it's easy to make copies of the same document across multiple servers. And if you have a lot of people trying to access your application, you can spread the load across those servers. That is called replication. &lt;/p&gt;

&lt;p&gt;Another option is to take French students and put them on one server, and take your English students and put them on another server. That is called sharding.&lt;/p&gt;

&lt;p&gt;But you have another option: you could do both replication and sharding. If you have your French student on one server, you could still make copies of those French students across multiple other servers. This way of making copies of the same data across multiple servers is called horizontal scaling or scaling out.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9j3n2bvwswurl2qr3hr2.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9j3n2bvwswurl2qr3hr2.gif" alt="Database sharding and replication animation" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
   Does it scale better than other databases?
&lt;/h2&gt;

&lt;p&gt;MongoDB and document stores generally are very good at scaling horizontally. MongoDB is designed to be distributed and has built-in concepts like replication and sharding. In other databases, especially relational databases, scaling up by acquiring more powerful and larger-capacity machines is more common. However, vertical scaling comes with exponentially increasing costs. Doubling the performance doesn't mean doubling the price; it often quadruples it.&lt;/p&gt;

&lt;p&gt;In contrast, horizontal scaling, where you add more servers, has a linear cost structure. You only pay for each extra server. On top of that, there is a physical limit on how big a single machine can get. On the other hand, with horizontal scaling, there is virtually no limit on how many servers you can get. Or at least the only limit is how much you can afford.&lt;/p&gt;




&lt;p&gt;In conclusion if you have to remember anything from this post. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;MongoDB is &lt;strong&gt;easy to use&lt;/strong&gt;, &lt;/li&gt;
&lt;li&gt;It's very &lt;strong&gt;flexible&lt;/strong&gt; &lt;/li&gt;
&lt;li&gt;It's &lt;strong&gt;scalable&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>mongodb</category>
      <category>database</category>
    </item>
  </channel>
</rss>
