<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Loyd Ngei on Medium]]></title>
        <description><![CDATA[Stories by Loyd Ngei on Medium]]></description>
        <link>https://medium.com/@loydngei?source=rss-fbce245109be------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*0mhJwx_kof-E5sFx9EJstQ.jpeg</url>
            <title>Stories by Loyd Ngei on Medium</title>
            <link>https://medium.com/@loydngei?source=rss-fbce245109be------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 17:56:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@loydngei/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Getting Started with Apache Airflow on AWS EC2: A Beginner’s Guide]]></title>
            <link>https://medium.com/@loydngei/getting-started-with-apache-airflow-on-aws-ec2-a-beginners-guide-4e056bfbd550?source=rss-fbce245109be------2</link>
            <guid isPermaLink="false">https://medium.com/p/4e056bfbd550</guid>
            <category><![CDATA[apache]]></category>
            <category><![CDATA[apache-airflow]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-ec2]]></category>
            <dc:creator><![CDATA[Loyd Ngei]]></dc:creator>
            <pubDate>Sat, 18 Jan 2025 05:45:39 GMT</pubDate>
            <atom:updated>2025-01-18T05:45:39.794Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Apache Airflow</strong> is a powerful platform for orchestrating complex data pipelines. This guide provides a step-by-step walkthrough for setting up Airflow on an AWS EC2 instance, perfect for beginners looking to explore this essential data engineering tool.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/829/1*2qbJ5a61hkuxbkubjzsKqA.png" /></figure><p><strong>Prerequisites</strong><br>1. An active AWS account.<br>2. Basic familiarity with the AWS Management Console and EC2 instances.<br>3. SSH client for connecting to your EC2 instance.</p><p><strong>How to quickly set up an EC2 Instance</strong></p><p>1. <strong>Launch an EC2 Instance:</strong> In the AWS Management Console, navigate to EC2 and launch a new instance. Choose an appropriate Amazon Machine Image (AMI) (e.g., Amazon Linux 2 or Ubuntu). Select an instance type suitable for your needs (a t2.micro is sufficient for initial exploration).</p><p>2. <strong>Configure Security Group:</strong> Ensure your security group allows SSH access (port 22) from your IP address. You’ll also need to open port 8080 for accessing the Airflow web UI.</p><p>3. <strong>Connect to the Instance:</strong> Use SSH to connect to your EC2 instance:</p><pre>ssh -i your_key.pem ec2-user@your_ec2_public_ip</pre><p><strong>How to install Airflow</strong></p><ol><li><strong>Create a Virtual Environment: </strong>Create a virtual environment to isolate Airflow’s dependencies:</li></ol><pre>python3 -m venv airflow-venv<br>source airflow-venv/bin/activate</pre><p><strong>2</strong>. <strong>Upgrade pip:</strong> Ensure you have the latest version of pip:</p><pre>pip install - upgrade pip</pre><p><strong>3.</strong> <strong>Install Airflow:</strong> Install Airflow with necessary extras. For basic functionality and encryption support, use:</p><pre>pip install apache-airflow[crypto]</pre><p>For more common integrations (Celery, Postgres, MySQL, S3, etc.), use:</p><pre>pip install apache-airflow[celery,postgres,mysql,jdbc,ssh,http,hive,s3,google,crypto]</pre><p><strong>4.</strong> <strong>Configuring Airflow</strong><br>Set AIRFLOW_HOME: Define the Airflow home directory:</p><pre>export AIRFLOW_HOME=~/airflow<br>mkdir -p $AIRFLOW_HOME</pre><p><strong>5. Initialize the Database:</strong> Initialize the Airflow metadata database (SQLite by default):</p><pre>airflow db migrate</pre><p><strong>6. Generate and Set Fernet Key:</strong> Generate a Fernet key for encrypting connections and variables:</p><pre>from cryptography.fernet import Fernet<br>fernet_key = Fernet.generate_key()<br>print(fernet_key.decode())</pre><p>Copy the output. Then, add the following lines to your <strong><em>~/.bashrc</em></strong> (or <strong><em>.bash_profile</em></strong>, <strong><em>.zshrc</em></strong>):</p><pre>export AIRFLOW_HOME=~/airflow<br>export AIRFLOW__CORE__FERNET_KEY=&quot;YOUR_GENERATED_KEY_HERE&quot; #Replace with the actual key</pre><p><strong>7.</strong> <strong>Source the file:</strong></p><pre>source ~/.bashrc</pre><p><strong>8.</strong> <strong>Starting Airflow</strong><br>Start Airflow in standalone mode:</p><pre>airflow standalone</pre><p><strong>9.</strong> <strong>Accessing the Airflow Web UI</strong><br>Open your web browser and navigate to <strong>http://&lt;your_ec2_public_ip&gt;:8080</strong>. You should now see the Airflow web UI.</p><p><strong>NOTE</strong><br>You might see warnings about triggerer threads being blocked. These are often due to the example DAGs and can be safely ignored while you’re learning the basics. Focus on creating your own DAGs and optimize triggers when needed.</p><p><strong>Conclusion</strong><br>This guide provides a quick and easy way to get started with Apache Airflow on AWS EC2. Now you can begin exploring Airflow’s features, creating your own data pipelines, and leveraging its powerful orchestration capabilities.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4e056bfbd550" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HNG Cohort 11: Solving a Backend Challenge (Docker, PHP, and Nginx), and why I am at HNG internship]]></title>
            <link>https://medium.com/@loydngei/hng-cohort-11-solving-a-backend-challenge-docker-php-and-nginx-and-why-i-am-at-hng-internship-a65864afb9dd?source=rss-fbce245109be------2</link>
            <guid isPermaLink="false">https://medium.com/p/a65864afb9dd</guid>
            <dc:creator><![CDATA[Loyd Ngei]]></dc:creator>
            <pubDate>Sat, 29 Jun 2024 16:05:46 GMT</pubDate>
            <atom:updated>2024-06-29T16:05:46.661Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>INTRODUCTION</strong></p><p>Since I wrote my first “Hello World” program in Python, challenges and bugs have been my daily cup of coffee. These obstacles have become the building blocks of my software development journey, each one honing my skills and pushing me to become a better developer.</p><p>Recently, while working on a Dockerized PHP application with Nginx, I faced a challenge that tested my skills. Considering this was my first encounter with docker it was not a walk in the park</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*q_JdA1wngpKpr86mnP5ZIw.jpeg" /></figure><p><strong>THE PROBLEM:<em> Docker Container Connectivity Issues</em></strong></p><p>The containers wouldn’t communicate properly. Specifically, the Nginx container couldn’t connect to the PHP-FPM container, leading to <em>502 Bad Gateway errors</em></p><p><strong>SOLUTION: <em>Step-by-Step</em></strong></p><p><strong>STEP 1: <em>Indentifying the issue</em></strong></p><p>I started by looking at the Docker logs for both the Nginx and PHP-FPM containers. The Nginx logs showed repeated 502 errors, indicating that Nginx was unable to reach the upstream server(PHP-FPM)</p><pre>docker logs nginx-container</pre><p><strong>STEP 2:<em> Checking Docker Network Configuration</em></strong></p><p>Next, I checked the Docker network configuration to ensure containers were on the same network.</p><pre>services:<br>  nginx:<br>    image: nginx:latest<br>    ports:<br>      - &quot;8080:80&quot;<br>    depends_on:<br>      - php<br>    networks:<br>      - app-network<br><br>  php:<br>    image: php:fpm<br>    networks:<br>      - app-network<br><br>networks:<br>  app-network:</pre><p><strong>STEP 3: <em>Verifying Container Configuration</em></strong></p><p>I checked the <em>nginx.conf </em>file to ensure it was correctly set up to pass requests to PHP-FPM</p><pre>server {<br>    listen 80;<br>    server_name localhost;<br><br>    root /var/www/html/public;<br>    index index.php index.html index.htm;<br><br>    location / {<br>        try_files $uri $uri/ /index.php?$query_string;<br>    }<br><br>    location ~ \.php$ {<br>        fastcgi_pass php:9000;<br>        fastcgi_index index.php;<br>        include fastcgi_params;<br>        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;<br>    }<br>}</pre><p><strong>STEP 4: <em>Testing Connectivity inside the Containers</em></strong></p><p>I utilized Docker’s exec command to open a shell inside the Nginx container and test connectivity to the PHP-FPM container. The curl command failing to connect confirmed that the issue was with the container networking</p><pre>docker exec -it nginx-container /bin/bash<br>curl php:9000</pre><p><strong>STEP 5: <em>Resolving DNS and Network Issues</em></strong></p><p>I resolved this by adding necessary network configuration and ensured that the PHP-FPM container was properly exposed. This included checking that the PHP-FPM service was listening on the correct port and that the service names matched between Docker compose and the Nginx configuration</p><pre>php:<br>  image: php:fpm<br>  expose:<br>    - &quot;9000&quot;</pre><p><strong>STEP 6: <em>Restarting the Containers</em></strong></p><p>I restarted the containers to apply the changes</p><pre>docker-compose down<br>docker-compose up -d</pre><p><strong>STEP 7: <em>Challenge solved</em></strong></p><p>After making these changes, the Nginx container was able to connect to the PHP-FPM container and the application started working as expected. I continued developing my application in a smooth, containerized environment.</p><p><strong>JOINING THE HNG INTERNSHIP PROGRAM</strong></p><p>Last year, a friend told me about the HNG Internship. Unfortunately, I had too much on my plate to join the cohort at that time. Now, the program has come around at just the right moment, and I’m excited to finally hop on board.</p><p>As I embark on this journey with the HNG program, I am very excited. HNG program offers me a great opportunity to work on real-world projects, collaborate with other talented developers, and learn from experienced mentors. The skills and experience that I will gain here will be invaluable as I continue to grow as a backend developer.</p><p>If you are interested in learning more about the HNG internship check out their webiste <a href="https://hng.tech/internship">https://hng.tech/internship</a> or <a href="https://hng.tech/premium">https://hng.tech/premium</a></p><p><strong>CONCLUSION</strong></p><p>Solving complex backend problems is a challenging but rewarding part of being a developer. The experience of resolving Docker container connectivity issues has reinforced my problem-solving skills and deepened my understanding of Docker, PHP, and Nginx. I look forward to applying these skills in future projects and during my time with the HNG Internship program.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a65864afb9dd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Demystifying Hashing Algorithms: The Silent Guardian of Your Digital Life]]></title>
            <link>https://systemweakness.com/demystifying-hashing-algorithms-the-silent-guardian-of-your-digital-life-cb9717299dc2?source=rss-fbce245109be------2</link>
            <guid isPermaLink="false">https://medium.com/p/cb9717299dc2</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[hashing-algorithm]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[backend]]></category>
            <dc:creator><![CDATA[Loyd Ngei]]></dc:creator>
            <pubDate>Fri, 19 Apr 2024 12:48:56 GMT</pubDate>
            <atom:updated>2024-04-23T17:21:54.665Z</atom:updated>
            <content:encoded><![CDATA[<p>In today’s digital world, strong passwords are our first line of defense. But how do websites store them securely? Enter hashing, a cryptographic magic trick that transforms your password into a unique, uncrackable code. This article dives into the world of hashing algorithms, exploring what they are, why they matter, and how they safeguard your data. We’ll uncover the key features of real-world hashing functions, their diverse purposes, and delve into some of the most common algorithms keeping your information secure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*Uhfr40vGRf8XyWYdO2oUqQ.png" /></figure><p><strong>What is hashing?</strong></p><p>Hashing is the process of converting data(text, numbers, files etc) to a fixed-length string of letters and numbers.</p><p><strong>How do hashing algorithms work?</strong></p><p><strong>A hashing algorithm</strong> is a mathematical function that takes an input (or “message”) and produces a fixed-size string of bytes. The output is typically a sequence of characters that represents the input data in a condensed and unique form. Here’s how it generally works:</p><p><strong>Input:</strong> The hashing algorithm takes an input, which could be of any length. This input could be a password, a file, a piece of text, or any other data.</p><p><strong>Processing:</strong> The algorithm processes the input data through a series of mathematical operations. These operations transform the input into a fixed-size output, regardless of the input’s length.</p><p><strong>Output:</strong> The output of the hashing algorithm is called a “hash value” or “hash code.” This hash value is typically a hexadecimal number or a sequence of characters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DIiZTIV1KVqGFGs7pt1I3g.png" /><figcaption>A demo of hashing a string “Hello” using the sha256 Algorithm</figcaption></figure><p><strong>KEY REQUIREMENTS FOR A REAL-WORLD HASHING ALGORITHM</strong></p><p>1. <strong>Deterministic:</strong> a hashing algorithm must produce the same hash value for the same input every time it’s executed. This property ensures consistency and predictability in applications that rely on hashing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/845/1*XlpSkW8KYkZX6t9CEyiRGw.png" /></figure><p><strong>2. Uniformity:</strong> Ideally, a good hashing algorithm should evenly distribute hash values across its output space. This means that each possible hash value should have an equal probability of being generated, minimizing the likelihood of collisions.</p><p><strong>3. Collision Resistance:</strong> Collisions occur when two different inputs produce the same hash value. While it’s theoretically impossible to completely eliminate collisions due to the <strong><em>pigeonhole principle</em></strong> (wherein there are more possible inputs than there are distinct hash values), a good hashing algorithm should make collisions computationally infeasible to find. This property is crucial for maintaining the integrity and security of hashed data.</p><p><strong>4. Irreversibility:</strong> A hashing algorithm should make it computationally infeasible to reverse the process and obtain the original input from its hash value. In other words, given a hash value, it should be extremely difficult to find any input that would produce that hash value. This property ensures the security of sensitive information, such as passwords stored in hashed form.</p><p><strong>5. Avalanche Effect:</strong> A small change in the input should result in a significant change in the hash value. This means that even a minor alteration in the input data should produce an entirely different hash value. The avalanche effect ensures that similar inputs produce drastically different hash values, enhancing the security and unpredictability of the hashing process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*k_l_LQsPmhCuzA_kgJ_LBg.png" /></figure><p><strong>6. Efficiency:</strong> While security is paramount, efficiency is also important, especially in applications where hashing is performed frequently or on large datasets. A good hashing algorithm should be computationally efficient, meaning it should require minimal time and computational resources to produce hash values.</p><p><strong>7. Resistance to Attacks:</strong> A hashing algorithm should be resistant to various cryptographic attacks, including brute-force attacks, collision attacks, and pre-image attacks. This requires thorough analysis and testing to identify and address potential vulnerabilities in the algorithm’s design.</p><p><strong>8. Standardization:</strong> For widespread adoption and interoperability, hashing algorithms should be standardized and well-documented. This ensures that implementations across different systems and platforms produce consistent results and can communicate effectively.</p><p><strong>PURPOSE OF HASHING</strong></p><ol><li><strong>Data Integrity:</strong> Hashing is commonly used to ensure the integrity of data during transmission or storage. By calculating the hash value of a piece of data (such as a file or message) before and after transmission or storage, one can compare the two hash values to verify that the data has not been altered or corrupted.</li><li><strong>Password Storage: </strong>Hashing is widely used to securely store passwords in databases. Instead of storing passwords in plaintext, which poses a security risk if the database is compromised, systems typically store hashed versions of passwords. When a user attempts to log in, their password is hashed and compared to the stored hash value. This way, even if the database is breached, attackers cannot easily retrieve the original passwords.</li><li><strong>Digital Signatures:</strong> Hash functions are used in digital signature schemes to verify the authenticity and integrity of digital documents or messages. A sender can hash a document, encrypt the hash value with their private key, and attach it to the document. The recipient can then verify the signature by decrypting the hash value with the sender’s public key and comparing it to the hash value calculated from the received document.</li><li><strong>Data Indexing and Retrieval:</strong> Hashing is used in data structures like hash tables to efficiently index and retrieve data. Hash functions map data keys to indexes in an array, allowing for fast lookup and retrieval of values associated with those keys.</li><li><strong>Cryptographic Applications:</strong> Hash functions are essential building blocks in various cryptographic protocols and algorithms, such as digital certificates, message authentication codes (MACs), and key derivation functions (KDFs).</li></ol><p><strong>COMMON HASHING ALGORITHMS</strong></p><ol><li><strong>MD5 (Message Digest 5):</strong></li></ol><p>MD5 was a widely used hashing algorithm in the early days, designed to create a unique fingerprint for a piece of data.</p><p>However, it’s no longer considered secure for several reasons:<br><strong><em>Collision vulnerabilities:</em></strong> It’s become possible to generate two different inputs that result in the same MD5 hash. This can be exploited to forge messages or bypass security checks.<br><strong><em>Limited output size:</em></strong> MD5 generates a 128-bit hash, which isn’t considered strong enough for modern security needs. With increased computing power, brute-forcing hashes becomes more feasible.</p><p><strong>2. SHA (Secure Hash Algorithm) Family:</strong></p><p>The SHA family is a set of cryptographic hashing algorithms developed by the National Institute of Standards and Technology (NIST). These are designed to be more secure than MD5 and offer different hash output sizes for various needs. Here’s a breakdown of some common members:</p><p><strong>(i) SHA-1 :</strong> This was a significant improvement over MD5, offering a 160-bit hash. However, vulnerabilities have been discovered, and SHA-1 is no longer considered secure for many applications.</p><p><strong>(ii) SHA-2 :</strong> This is a family of more secure algorithms including SHA-256, SHA-384, and SHA-512. These offer 256-bit, 384-bit, and 512-bit hash outputs respectively, providing a significant improvement in security over SHA-1 and MD5. SHA-256 is widely used for various security applications like digital signatures and password storage.</p><p><strong>(iii) SHA-3 :</strong> SHA-3 is the latest addition to the SHA family. It was designed from the ground up to address security concerns identified in SHA-2. SHA-3 offers similar hash output sizes as SHA-2 but is considered more resistant to potential attacks.</p><p><strong>OTHER COMMON HASHING ALGORITHMS</strong><br><strong>1. bcrypt:</strong><br>bcrypt is a password hashing function designed to be slow and computationally intensive, making it resistant to brute-force attacks.<br>It’s commonly used for securely storing passwords.<br><strong>2. Argon2:</strong><br>Argon2 is another password hashing function, designed to be memory-hard and resistant to GPU and ASIC(Application-Specific Integrated Circuit) attacks.<br>It’s the winner of the Password Hashing Competition.<br><strong>3</strong>. <strong>Whirlpool:</strong><br>Whirlpool is a cryptographic hash function that produces a hash value of 512 bits.<br>It offers a high level of security and is suitable for various cryptographic applications.</p><p><strong>CHOOSING THE RIGHT HASHING ALGORITHM</strong></p><p>The choice of hashing algorithm depends on the specific security needs of the application. Here are some factors to consider:</p><p><strong><em>Security level required:</em></strong> For high-security applications, SHA-2 or SHA-3 are preferred.<br><strong><em>Processing speed:</em></strong> SHA-3 might be slower than SHA-2 on some systems.<br><strong><em>Output size:</em></strong> The required hash output size will depend on the application.</p><p><strong>CONCLUSION</strong></p><p>Hashing algorithms may seem like a complex technical concept, but their impact is undeniable. They operate silently behind the scenes, ensuring the integrity and security of your data across countless applications. From protecting passwords to verifying file downloads, hashing forms a vital foundation for cybersecurity. As technology evolves, so too will hashing algorithms, continuously adapting to stay ahead of security threats. By understanding this essential tool, you gain valuable insight into the inner workings of online security and can make informed decisions about protecting your digital identity.</p><p>Happy coding Engineers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cb9717299dc2" width="1" height="1" alt=""><hr><p><a href="https://systemweakness.com/demystifying-hashing-algorithms-the-silent-guardian-of-your-digital-life-cb9717299dc2">Demystifying Hashing Algorithms: The Silent Guardian of Your Digital Life</a> was originally published in <a href="https://systemweakness.com/">System Weakness</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A GUIDE TO MASTERING CACHING]]></title>
            <link>https://medium.com/@loydngei/a-guide-to-mastering-caching-14b18e4298f6?source=rss-fbce245109be------2</link>
            <guid isPermaLink="false">https://medium.com/p/14b18e4298f6</guid>
            <category><![CDATA[caching]]></category>
            <category><![CDATA[system-design-interview]]></category>
            <category><![CDATA[backend]]></category>
            <dc:creator><![CDATA[Loyd Ngei]]></dc:creator>
            <pubDate>Mon, 01 Apr 2024 10:10:54 GMT</pubDate>
            <atom:updated>2024-04-15T09:33:11.742Z</atom:updated>
            <content:encoded><![CDATA[<p>Imagine you’re browsing the web, eager to find information. Suddenly, the loading icon spins endlessly, frustration mounting with each passing second. This could be a thing of the past with the power of caching!</p><p><strong>FUN FACT</strong><br><em> “There are only two hard things in Computer Science: cache invalidation and naming things.” — Phil Karlton</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fd0lOawdZXq2GFUIL6v8Lg.jpeg" /></figure><p><strong>WHAT IS CACHING?</strong><br>Caching is a technique that revolutionizes the way data is handled and accessed by storing frequently used data in a super-fast memory, akin to having a personal assistant readily available with the information you need most.<br><strong> WHY CACHE?</strong></p><ol><li><strong><em>Latency Reduction:</em></strong> By fetching data from a cache rather than a distant data source, latency is significantly reduced, leading to faster response times.</li><li><strong><em>Database Load Reduction:</em></strong> Caching lessens the strain on database systems by serving frequently accessed data locally, minimizing the need for repeated database queries.</li><li><strong><em>Network Cost Optimization:</em></strong> Accessing data from a cache eliminates the need for traversing long network routes, resulting in reduced network costs.</li><li><strong><em>Enhanced Fault Tolerance:</em></strong> Caching plays a pivotal role in maintaining system resilience by ensuring data availability even in the event of system failures.</li></ol><p>We will break down caching to 3 different categories:<br>- <strong><em>Caching levels<br>- Caching strategies<br>- Caching designs</em></strong></p><p><strong>CACHING BY LEVELS:</strong></p><p>1. <strong><em>CDN (</em>Content Delivery Network<em>):</em></strong><br>Think of a CDN as a network of data warehouses strategically located around the world. When a user requests content, the CDN serves it from the closest location, significantly reducing latency. This is commonly used for efficiently delivering web content to users globally.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*QP-WQWq7YYLgDgp0mi__9Q.png" /></figure><p><strong>An example of CDN:</strong></p><p><strong><em>Cloudflare:</em></strong><br>Cloudflare is one of the most widely used CDNs, offering a suite of services including content delivery, DDoS protection, and security features.<br>Setting up Cloudflare involves signing up for an account, adding your website to Cloudflare, updating your DNS settings to point to Cloudflare’s servers, and configuring caching and security settings through Cloudflare’s dashboard.</p><p><strong>More examples of CDNs:</strong> <em>Akamai, Amazon CloudFront, Fastly</em></p><p><strong>2. CLIENT-SIDE CACHING</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/833/1*n45jQhJqBjJ8fLtZSiaOng.png" /></figure><p>Your trusty web browser is a caching champion in disguise! It utilizes various techniques to store website assets like images, scripts, and style sheets directly on your device. This secret stash comes in handy when you revisit a website. Instead of downloading everything again, the browser can retrieve cached content from its local storage, leading to significantly faster page loads.</p><p>Here are the key tools in the client-side caching arsenal:</p><ul><li><strong>HTTP Caching Headers:</strong> These are special instructions sent by the server to the browser, dictating how long the browser should store specific content. Common headers include Cache-Control and Expires, allowing the server to control the caching behavior.</li><li><strong>Browser Storage APIs:</strong> Modern browsers offer more sophisticated storage options beyond basic caching. LocalStorage and IndexedDB provide mechanisms for web applications to store data persistently on the user’s device, enabling features like remembering login credentials or application state.</li></ul><p><strong>3. SERVER-SIDE CACHING</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZHnMl4M7QgFYSXdRA2tH8A.jpeg" /></figure><p>At its essence, server-side caching operates as a strategic layer between incoming requests and backend processes, meticulously intercepting and optimizing data flows to accelerate response times and ease server strain. When a request traverses the server’s domain, whether for dynamic content or resource-intensive computations, the server adeptly discerns the need for caching, selectively storing pertinent data in its cache.</p><p>Upon subsequent requests for the same data, the server elegantly circumvents redundant processing cycles, retrieving cached content with alacrity and finesse. This judicious caching mechanism obviates the need for resource-intensive computations or database queries, propelling application performance to unparalleled heights.</p><p><strong>Key Strategies and Techniques:</strong></p><p>Server-side caching encompasses a diverse array of strategies and techniques, each tailored to address specific use cases and optimization objectives:</p><ul><li><strong><em>Application-Level Caching:</em></strong> Within the application’s domain, caching frameworks and libraries facilitate the caching of computed or aggregated data, sparing applications from repetitive computations and database interactions.</li><li><strong><em>Proxy and Reverse Proxy Caching:</em></strong> By interposing intermediary servers between clients and backend systems, proxy caching and reverse proxy caching intercept incoming requests, serving cached content directly to clients and alleviating the burden on origin servers.</li><li><strong><em>Database Query Caching:</em></strong> In read-heavy applications characterized by frequent database queries, caching query results becomes paramount. In-memory caching systems like <em>Redis</em> or<em> Memcached</em> excel in caching query results, minimizing database load and enhancing application responsiveness.</li></ul><p><strong>Transformative Benefits:</strong></p><ol><li><em>Expedited Response Times: </em>By serving cached content expeditiously, server-side caching drastically reduces response times, engendering a frictionless and immersive user experience.</li><li><em>Mitigated Server Strain:</em> Server-side caching alleviates the burden on backend systems by circumventing resource-intensive computations and database queries, thus optimizing server resource utilization and scalability.</li><li><em>Enhanced Fault Tolerance:</em> Through the strategic caching of critical data, servers fortify applications against transient failures or performance fluctuations, ensuring consistent and reliable service delivery.</li></ol><p><strong>Database Caching:</strong></p><p>For database-heavy applications, caching query results or frequently accessed data can be a game-changer. In-memory caching systems like <em>Redis</em> or <em>Memcached</em> can significantly improve application performance by serving cached data instead of constantly querying the database.</p><p><strong>Application Caching:</strong></p><p>Applications themselves can leverage caching to store computed or aggregated data. This can include caching templates, objects, or even entire pages, leading to faster application response times by reducing the need for expensive computations or data fetching operations.</p><p><strong>CACHING STRATEGIES:</strong></p><p>Further broken to read and write strategies:</p><p><strong>Read strategies:</strong> <em>Cache aside and read through</em></p><p><strong>Write strategies:</strong> <em>write around, write back and write through</em></p><ol><li><strong>Cache-Aside (Lazy loading):</strong></li></ol><p>This strategy shines in read-heavy applications where maintaining perfect data consistency isn’t essential. It prioritizes data availability by first checking the cache. If the data is there (cache hit), it’s delivered quickly. However, if it’s missing (cache miss), the application retrieves it from the database, stores it in the cache for future use, and then returns it. While this offers resilience against cache outages, there’s a chance of inconsistency if the database is updated without reflecting in the cache. Additionally, the first request for any data will always be a cache miss, potentially impacting performance for the initial user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*kaAvu9SYmAkMbOiTvpAt3Q.png" /></figure><p><strong>2. Read-Through Cache:</strong></p><p>Similar to Cache-Aside, Read-Through Cache is well-suited for read-heavy applications. It simplifies data fetching by offloading that responsibility to the cache library. The process follows the same cache hit/miss logic. On a cache miss, the cache library itself takes the initiative to fetch the data from the database, store it in the cache, and then return it to the application. This approach shares the resilience benefits of Cache-Aside but also inherits the risk of data inconsistency and the inevitable cache miss for the first data read.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*ah5OYLiYB5keCB0O7Borxg.png" /><figcaption>Read through demo</figcaption></figure><p><strong>3. Write-Around Cache:</strong></p><p>This strategy prioritizes write performance over data consistency, making it ideal for write-heavy applications where temporary inconsistencies might be acceptable (like adding items to a shopping cart before checkout). Here, data is written directly to the database, bypassing the cache altogether. This eliminates the possibility of cache inconsistency but comes at the cost of sacrificing some performance. Every data read will be a cache miss until the data is eventually accessed again.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/874/1*5l1k71ktv_bjt7sJ87W6NA.png" /></figure><p><strong>4. Write-Through Cache:</strong></p><p>If maintaining data consistency between the cache and database is paramount, Write-Through Cache is your go-to strategy. Here, data is written to the cache first, and then the cache propagates the write operation to the database synchronously. The application only receives confirmation once the database acknowledges successful write completion. This ensures strong consistency but can introduce latency due to the synchronous write to the database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/812/1*mPsJYNhqem6D5Mp8kTVGVw.png" /></figure><p><strong>5. Write-Back (or Behind) Cache:</strong></p><p>This strategy is a champion for write-heavy applications where optimizing write performance is crucial, and eventual consistency is acceptable. Data is written to the cache first, and then asynchronously written to the database in the background. This significantly improves write operation latency compared to synchronous writes. Additionally, the high cache hit rate for subsequent reads translates to better performance. However, there’s a risk of data loss if the cache fails or data isn’t written to the database before eviction. Write-Back Cache also introduces eventual consistency, meaning there might be a temporary lag between the updated data in the cache and the database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/812/1*jPcTanjFNKPn4sPpG2Tiaw.png" /></figure><p><strong>CACHING BY DESIGN</strong></p><p><strong>1.</strong> <strong>Global Cache:</strong><br>Imagine a central information hub accessible by everyone. A global cache stores data that can be shared across multiple servers in an application, ensuring everyone has the latest information. This is particularly useful for distributed systems where commonly accessed data needs to be readily available</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/318/1*Nh2yldEbvRtjXV5zM_2kkQ.png" /></figure><p><strong>2. Distributed Cache:</strong><br>Picture a team effort! A distributed cache spreads the caching load across multiple servers, each responsible for a portion of the data. This approach improves scalability and fault tolerance, as data redundancy is distributed across the network.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*3RvIQsCwymiPMg3RcVbSoA.jpeg" /></figure><p><strong>CONCLUSION</strong><br>Caching stands as a cornerstone in modern computing, revolutionizing data access, reducing latency, and enhancing system performance. By understanding the intricacies of caching mechanisms and strategies, developers can unlock the full potential of their applications in an ever evolving digital landscape.</p><p><em>Embrace caching, and witness your applications soar to new heights.</em></p><p>Happy coding Engineers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=14b18e4298f6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HTTP: The Backbone of Web Communication]]></title>
            <link>https://medium.com/@loydngei/http-the-backbone-of-web-communication-c5c5d1449e28?source=rss-fbce245109be------2</link>
            <guid isPermaLink="false">https://medium.com/p/c5c5d1449e28</guid>
            <category><![CDATA[internet]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[https]]></category>
            <category><![CDATA[fundamentals]]></category>
            <dc:creator><![CDATA[Loyd Ngei]]></dc:creator>
            <pubDate>Sun, 17 Mar 2024 08:32:44 GMT</pubDate>
            <atom:updated>2024-03-17T08:34:21.403Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>INTRODUCTION:</strong><br><strong><em>HTTP (Hypertext Transfer Protocol)</em></strong> is the cornerstone of communication on the World Wide Web. It defines the rules for how data is exchanged between web browsers (clients) and web servers, enabling the seamless transfer of information across the internet.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*uY91sNX0YXCBq8Tumc5kcw.jpeg" /></figure><p>Let’s break down HTTP main components:</p><ol><li><strong>CLIENT-SERVER MODEL: A Conversation Between Two</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/451/1*eR0AiyzHKykAoEu1qkybUw.png" /></figure><p>HTTP operates on a client-server model, establishing a structured conversation between two entities. When a user accesses a website, their web browser acts as the client, initiating a request to the web server where the site is hosted. The server, in turn, processes the request, retrieves the necessary resources, and sends a response back to the client. This back-and-forth interaction forms the basis of web communication, allowing for the dynamic display of web pages and the execution of web-based applications.</p><p><strong>2. STATELESSNESS: Short-Term Memory</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/689/1*Jg6I2lTEbVxmRmCLf81JKw.png" /></figure><p>One of the defining characteristics of HTTP is its statelessness, meaning each request from the client is treated as an independent event. Unlike traditional client-server interactions, where the server retains information about the client’s state, HTTP requires mechanisms like cookies and sessions to simulate state and maintain continuity across user interactions.</p><p><strong>Cookies and Sessions:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/695/1*OtSIRHIELD3vUDLErVZDzA.png" /></figure><p>Cookies are small pieces of data stored on the client’s machine that the server can access in subsequent requests. They play a crucial role in maintaining user sessions, tracking user preferences, and personalizing the browsing experience. Sessions, on the other hand, are server-side mechanisms that store user data for a limited time. By associating a session ID with each client, servers can retrieve relevant user information and maintain state across multiple requests.</p><p><strong>3. APPLICATION LAYER PLAYER: Building on a Strong Foundation</strong></p><p>HTTP operates at the application layer of the Internet protocol suite, leveraging the reliable transport provided by the underlying TCP/IP protocol. This positioning allows HTTP to focus on the application-specific aspects of web communication, such as requesting web pages, transferring files, and submitting form data, while relying on TCP to ensure the reliable delivery of data packets.</p><p><strong>4. CLIENT ACTIONS: A Rich Toolkit (GET, POST, DELETE, etc.)</strong></p><p>Clients use HTTP methods, also known as verbs, to specify the type of action they want to perform on the server. These methods provide a flexible toolkit for interacting with web resources, including:</p><p><strong><em>GET:</em></strong> Retrieves information from a server, typically used for requesting web pages or downloading files.<br><strong><em>POST:</em></strong> Submits data to a server, commonly used for sending form data or uploading files.<br><strong><em>PUT:</em> </strong>Updates an existing resource on the server with the provided data.<br><strong><em>DELETE:</em></strong> Removes a specified resource from the server.<br><strong><em>PATCH:</em></strong> Applies partial modifications to a resource.<br>By leveraging these methods, clients can perform a wide range of operations, from retrieving data to modifying server resources, thereby enabling dynamic and interactive web experiences.</p><p><strong>5. SERVER STATUS CODES: Understanding the Response</strong></p><p>When a server responds to a client’s request, it includes an HTTP status code that indicates the outcome of the request. These status codes provide valuable insights into the success or failure of the interaction, allowing clients to respond accordingly. Common status codes include:</p><p><strong><em>200 OK:</em></strong> The request was successful, and the requested information is in the response body.<br><strong><em>301 Moved Permanently</em>:</strong> The requested resource has been permanently moved to a new location.<br><strong><em>404 Not Found:</em></strong> The requested resource could not be found on the server.<br><strong><em>500 Internal Server Error:</em></strong> An unexpected error occurred on the server, preventing it from fulfilling the request.</p><p>By understanding these codes, developers and users can interpret the server’s response and take appropriate actions to resolve any issues that may arise.</p><p><strong>6. HTTP HEADERS: The Hidden Conversation</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/504/1*Vmob2ujIcy_bs3_5U6Wz8g.png" /></figure><p><strong><em>Host:</em></strong> Specifies the hostname of the requested resource.<br><strong><em>Content-Type:</em></strong> Indicates the format of the data being sent (e.g., text/html, application/json).<br><strong><em>Content-Length:</em></strong> Specifies the size of the data in the message body.<br><strong><em>Cookie:</em></strong> Contains cookie data sent by the client or set by the server.<br><strong><em>Location:</em></strong> Used in redirect responses to indicate the new location of the resource.</p><p>By exchanging these headers, clients and servers can coordinate their actions, negotiate content formats, and ensure the smooth transmission of data across the web.</p><p><strong>CONCLUSION:</strong></p><p>HTTP forms the essential language that powers web communication, enabling the seamless exchange of data between clients and servers. From its client-server model to the exchange of messages with methods, status codes, and headers, HTTP provides the foundation for the dynamic and interactive web experiences we enjoy today. By understanding its core aspects, developers and users alike can navigate the complexities of web communication with confidence and efficiency.</p><p>Happy Coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c5c5d1449e28" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MASTERING API DESIGN: A COMPREHENSIVE GUIDE TO ARCHITECTURAL STYLES]]></title>
            <link>https://medium.com/@loydngei/mastering-api-design-a-comprehensive-guide-to-architectural-styles-1ddd0d9c9e2f?source=rss-fbce245109be------2</link>
            <guid isPermaLink="false">https://medium.com/p/1ddd0d9c9e2f</guid>
            <dc:creator><![CDATA[Loyd Ngei]]></dc:creator>
            <pubDate>Fri, 08 Mar 2024 15:35:13 GMT</pubDate>
            <atom:updated>2024-03-08T15:35:13.172Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/909/1*lJuJoqx-8o_JDsRS89R7rQ.jpeg" /></figure><p><strong>What is an API?</strong></p><p><strong><em>An Application Programming Interface(API)</em> </strong>is a set of rules that allows software applications communicate with each other to exchange data, features and functionality. Let’s think of a practical example: A weather bureau’s software system contains daily weather data. The weather app on your phone “communicates” to this system via APIs and shows you daily weather updates on your phone.</p><p><strong>POPULAR API ARCHITECTURE STYLES</strong></p><ol><li><strong>REST APIs</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5b9URi8HKSr9A9f-jvmxCQ.png" /></figure><p><strong><em>REST stands for Representational State Transfer.</em></strong> In REST, clients exchange data with the server using the HTTP protocol (POST, GET, PUT, DELETE, etc). This is by far the most popular API architecture and the simplest to implement. Most of the web services we interact with on daily basis for example Twitter are powered by REST.</p><p><strong><em>The main feature in REST APIs is statelessness</em></strong>. This means that servers don’t save client data between requests and the response from the server is plain data, without the typical graphical rendering of a web page. Let’s further our understanding of statelessness using the example below:</p><p><em>Imagine you’re playing catch with a friend. Each time you throw the ball (request) to your friend (server), you have to tell them everything about how you want to play and what you want them to do. They can’t remember anything from the last time you played. Then, when your friend throws the ball back (response), they don’t add anything fancy like stickers or drawings to the ball. It’s just a plain ball with no extra stuff on it. That’s what it means when we say playing catch with your friend is “stateless.”</em></p><p>REST use case example using JavaScript (ExpressJS):</p><pre>const express = require(&#39;express&#39;);<br>const app = express();<br><br>// Dummy data (could be fetched from a database)<br>let books = [<br>    { id: 1, title: &quot;Harry Potter&quot;, author: &quot;J.K. Rowling&quot; },<br>    { id: 2, title: &quot;The Hobbit&quot;, author: &quot;J.R.R. Tolkien&quot; }<br>];<br><br>app.use(express.json());<br><br>// GET request to fetch all books<br>app.get(&#39;/books&#39;, (req, res) =&gt; {<br>    res.json(books);<br>});<br><br>// POST request to add a new book<br>app.post(&#39;/books&#39;, (req, res) =&gt; {<br>    const newBook = req.body;<br>    books.push(newBook);<br>    res.status(201).json(newBook);<br>});<br><br>const PORT = process.env.PORT || 3000;<br>app.listen(PORT, () =&gt; console.log(`Server running on port ${PORT}`));</pre><p><strong>2. GraphQL</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0OZBXKRjgf-HZ543eEtD5w.png" /></figure><p>GraphQL is a query language for APIs developed by Facebook. GraphQL standout feature is <strong><em>‘no over-fetching or under-fetching of data’.</em></strong> Clients ask for specific data they need. Unlike the REST architecture, GraphQL enables Front-end developers query multiple databases, microservices, and APIs with a single GraphQL endpoint. The purpose of GraphQL was to make APIs fast, flexible and developer friendly.</p><p>Facebook use GraphQL to deliver efficient and precise data to it’s billions of users. It is also adapted by Shopify and Github</p><p><strong>GraphQL use case example:</strong></p><pre>const { graphql, buildSchema } = require(&#39;graphql&#39;);<br>const express = require(&#39;express&#39;);<br>const app = express();<br><br>// Define a schema<br>const schema = buildSchema(`<br>  type Query {<br>    hello: String<br>  }<br>`);<br><br>// Define resolvers<br>const root = {<br>  hello: () =&gt; &#39;Hello, world!&#39;<br>};<br><br>// Endpoint for GraphQL queries<br>app.use(&#39;/graphql&#39;, express.json(), (req, res) =&gt; {<br>  graphql(schema, req.body.query, root)<br>    .then(result =&gt; {<br>      res.json(result);<br>    })<br>    .catch(err =&gt; {<br>      res.status(500).json({ error: err.message });<br>    });<br>});<br><br>const PORT = process.env.PORT || 3000;<br>app.listen(PORT, () =&gt; console.log(`Server running on port ${PORT}`));<br></pre><p>You can test this GraphQL server by sending a POST request to http://localhost:3000/graphql with a JSON body containing your GraphQL query. For example:</p><pre>// POST request<br>{<br>  &quot;query&quot;: &quot;{ hello }&quot;<br>}<br><br>// Response<br><br>{<br>  &quot;data&quot;: {<br>    &quot;hello&quot;: &quot;Hello, world!&quot;<br>  }<br>}</pre><p><strong>3. WebSockets</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/617/1*fB-R8AqISp8WM6GCkuOb5A.png" /></figure><p>Websockets API is a technology that makes it possible to open a two way interactive communication session between user’s browser and a server. This architecture is particularly suitable for applications like live-chat platforms and real-time gaming, where low-latency data exchange is paramount for user experience.</p><p>Here is an implementation of Websockets using JS(ExpressJS framework)</p><pre>const express = require(&#39;express&#39;);<br>const http = require(&#39;http&#39;);<br>const WebSocket = require(&#39;ws&#39;);<br><br>const app = express();<br>const server = http.createServer(app);<br>const webSocketServer = new WebSocket.Server({ server });<br><br>webSocketServer.on(&#39;connection&#39;, function connection(webSocket) {<br>  // Event listener for incoming messages<br>  webSocket.on(&#39;message&#39;, function incoming(message) {<br>    // Echo the received message back to the client<br>    webSocket.send(message);<br>  });<br>});<br><br>server.listen(3000, function() {<br>  console.log(&#39;WebSocket server is listening on port 3000&#39;);<br>});</pre><p><strong>4. SOAP</strong></p><p>SOAP (Simple Object Access Protocol) is a protocol for exchanging structured information in the implementation of web services. It is based on XML (eXtensible Markup Language), which is a markup language that defines a set of rules for encoding documents in a format that is both human-readable and machine-readable. SOAP is widely employed in industries such as finance and payment gateways, prioritizing security and reliability. However, its complexity and verbosity pose challenges, particularly for lightweight mobile applications. Despite its robust security features, SOAP’s intricate structure can result in larger message sizes and increased communication overhead. As a result, while SOAP remains a stalwart in secure data transmission, its suitability for resource-constrained environments, such as mobile platforms, is limited due to its heavyweight nature.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/922/1*zcB0gXrCh_G9MzRR6sxuqA.png" /></figure><p><strong>CONCLUSION</strong></p><p>In conclusion, understanding the diverse landscape of API architecture styles is essential for designing and developing robust and efficient software solutions. From REST APIs, with their simplicity, to GraphQL, offering precise data retrieval and flexibility, each architecture serves distinct purposes and caters to varying requirements. Meanwhile, WebSockets enable real-time, bidirectional communication enhancing user experience through low-latency data exchange. Additionally, SOAP remains a stalwart in secure data transmission, particularly in industries prioritizing security and reliability. By selecting the appropriate API architecture style, developers can optimize performance, scalability, and user satisfaction, ensuring the success of their applications in today’s dynamic digital landscape.</p><p>Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1ddd0d9c9e2f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Securing Your Node.js and MongoDB Application: A Comprehensive Guide to Database Encryption]]></title>
            <link>https://medium.com/@loydngei/securing-your-node-js-and-mongodb-application-a-comprehensive-guide-to-database-encryption-8b38d13e55d9?source=rss-fbce245109be------2</link>
            <guid isPermaLink="false">https://medium.com/p/8b38d13e55d9</guid>
            <category><![CDATA[backend]]></category>
            <category><![CDATA[mongodb]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[database]]></category>
            <dc:creator><![CDATA[Loyd Ngei]]></dc:creator>
            <pubDate>Fri, 24 Nov 2023 20:03:06 GMT</pubDate>
            <atom:updated>2023-11-24T20:03:06.846Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j3YhzxdAI2oEN4DQUq26ww.png" /></figure><p>In today’s digital landscape, data security is paramount. As a developer building applications with Node.js, Express.js, and MongoDB, it’s crucial to implement robust encryption measures to protect sensitive information. In this guide, we’ll explore various encryption techniques and best practices to secure your database and ensure the confidentiality of your users’ data.</p><h3>1. Node.js Libraries for Encryption</h3><h4>Leveraging Node.js Crypto Module for Encryption</h4><p>Node.js provides a built-in crypto module that can be used for various cryptographic operations. You can use it to encrypt and decrypt data within your Node.js application before it is stored in the database.</p><pre>const crypto = require(&#39;crypto&#39;);<br><br>const algorithm = &#39;aes-256-cbc&#39;;<br>const key = &#39;your-secret-key&#39;;<br>const iv = crypto.randomBytes(16);<br><br>function encrypt(text) {<br>  const cipher = crypto.createCipheriv(algorithm, Buffer.from(key), iv);<br>  let encrypted = cipher.update(text, &#39;utf-8&#39;, &#39;hex&#39;);<br>  encrypted += cipher.final(&#39;hex&#39;);<br>  return { iv: iv.toString(&#39;hex&#39;), encryptedData: encrypted };<br>}<br><br>function decrypt(encryptedData, inputIV) {<br>  const decipher = crypto.createDecipheriv(algorithm, Buffer.from(key), Buffer.from(inputIV, &#39;hex&#39;));<br>  let decrypted = decipher.update(encryptedData, &#39;hex&#39;, &#39;utf-8&#39;);<br>  decrypted += decipher.final(&#39;utf-8&#39;);<br>  return decrypted;<br>}<br><br>// Example usage<br>const originalText = &#39;Hello, encrypted world!&#39;;<br>const encryptedData = encrypt(originalText);<br>console.log(&#39;Encrypted:&#39;, encryptedData);<br><br>const decryptedText = decrypt(encryptedData.encryptedData, encryptedData.iv);<br>console.log(&#39;Decrypted:&#39;, decryptedText);</pre><p>Replace the example key with a secure method of key management, such as using environment variables or a key management service.</p><h3>2. Encryption at Rest with MongoDB WiredTiger Encryption</h3><h4>What is Encryption at Rest?</h4><p>Encryption at rest is a data security measure that involves encrypting the data stored on disk. Even if an unauthorized party gains access to the physical storage, they won’t be able to make sense of the encrypted data without the appropriate decryption key.</p><h4>Implementing Encryption at Rest with MongoDB WiredTiger Encryption</h4><p>MongoDB WiredTiger is the default storage engine starting in MongoDB 3.2. It is well-suited for most workloads and is recommended for new deployments. WiredTiger provides a document-level concurrency model, checkpointing, and compression, among other features. MongoDB provides built-in support for encryption at rest through the WiredTiger storage engine. By enabling WiredTiger encryption, you add an additional layer of protection to your data files on disk.</p><p>To enable WiredTiger encryption, include the following configuration in your MongoDB server:</p><pre>storage:<br>  encryption:<br>    dbEncryptionKeyFile: /path/to/keyfile</pre><p>Make sure to replace /path/to/keyfile with the actual path to your encryption key file. Properly manage and secure the key file, as it&#39;s crucial for decrypting the data.</p><h3>3. SSL/TLS Encryption for Transit</h3><h4>What is SSL/TLS Encryption for Transit?</h4><p>SSL (Secure Sockets Layer) and its successor, TLS (Transport Layer Security), provide encryption for data transmitted between your Node.js application and the MongoDB server. This ensures that even if someone intercepts the communication, they won’t be able to decipher the information.</p><h4>Implementing SSL/TLS Encryption for Transit</h4><p>To enable SSL/TLS encryption for MongoDB, configure your MongoDB server to use SSL. Also, make sure your Node.js application is set up to connect to MongoDB using the mongodb+srv URI scheme with the ssl option:</p><pre>const MongoClient = require(&#39;mongodb&#39;).MongoClient;<br><br>const uri = &#39;mongodb+srv://&lt;username&gt;:&lt;password&gt;@cluster0.mongodb.net/test?ssl=true&amp;sslValidate=true&amp;sslCA=&lt;path_to_ca_file&gt;&#39;;<br>const client = new MongoClient(uri, { useNewUrlParser: true });<br><br>client.connect(err =&gt; {<br>  // handle connection<br>  client.close();<br>});</pre><p>Replace &lt;username&gt;, &lt;password&gt;, and &lt;path_to_ca_file&gt; with your MongoDB credentials and the path to the Certificate Authority (CA) file, respectively.</p><h3>4. Field-Level Encryption with MongoDB Field-Level Encryption</h3><h4>What is Field-Level Encryption?</h4><p>Field-level encryption is the process of encrypting specific fields within your MongoDB documents. This provides an additional layer of security, especially for highly sensitive information like credit card numbers or personal identification details.</p><h4>Implementing Field-Level Encryption with MongoDB</h4><p>MongoDB’s Field-Level Encryption allows you to define which fields in your documents should be encrypted and decrypted. This is achieved through the use of a JSON schema specifying the encryption details.</p><p>Here’s an example schema for a collection that includes field-level encryption</p><pre>{<br>  &quot;bsonType&quot;: &quot;object&quot;,<br>  &quot;properties&quot;: {<br>    &quot;name&quot;: {<br>      &quot;encrypt&quot;: {<br>        &quot;keyId&quot;: &quot;/path/to/keyfile&quot;,<br>        &quot;algorithm&quot;: &quot;AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic&quot;<br>      }<br>    },<br>    // Morefields...<br>  }<br>}</pre><p>Replace /path/to/keyfile with the actual path to your encryption key file.</p><h3>5. Key Management</h3><h4>The Importance of Key Management</h4><p>Proper key management is critical to the success of any encryption strategy. Encryption keys should be stored securely and managed in a way that ensures their confidentiality and integrity.</p><h4>Best Practices for Key Management</h4><ul><li>Use a dedicated key management service to generate, store, and rotate encryption keys.</li><li>Restrict access to encryption keys to only those individuals who need them.</li><li>Regularly rotate encryption keys to limit the potential impact of a compromised key.</li></ul><h4><strong>CONCLUSION</strong></h4><p>Security is a multilayered approach, where each layer adds an additional level of protection. These encryption measures are key to ensuring sensitive data is safely stored. MongoDB, with the assistance of MongoDB Atlas and the MongoDB Compass GUI, streamlines the implementation of many of these measures, reducing the need for manual handling. Leveraging these tools empowers developers to focus on building robust applications while maintaining a high level of data security.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8b38d13e55d9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Basic Authentication and Session Authentication]]></title>
            <link>https://medium.com/@loydngei/understanding-basic-authentication-and-session-authentication-ff17ec692d27?source=rss-fbce245109be------2</link>
            <guid isPermaLink="false">https://medium.com/p/ff17ec692d27</guid>
            <dc:creator><![CDATA[Loyd Ngei]]></dc:creator>
            <pubDate>Sun, 13 Aug 2023 20:33:04 GMT</pubDate>
            <atom:updated>2023-08-14T07:59:48.638Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/389/1*cmZ_HBvR3-oo7d2RZ5y_xg.jpeg" /></figure><p>In today’s world security is of paramount importance. The ability to verify the identity of users accessing a system is essential to protect sensitive data. Authentication methods play a crucial role in achieving this goal. In this article, we’ll delve into two common authentication methods: Basic Authentication and Session Authentication. We’ll explore how each method works, when to use which and their pros and cons.</p><h3>BASIC AUTHENTICATION</h3><p>This is a simple and straightforward method of authentication. It involves sending the user’s credentials (username and password) with each request to the server. The server then verifies these credentials before granting access to the requested resource. While Basic Authentication is easy to understand and implement, it raises security concerns due to the transmission of credentials in plain text.</p><h4><strong>HOW BASIC AUTHENTICATION WORKS</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rCBoECru63YQBkGpjVDKOw.jpeg" /></figure><p><strong>Client Initiation: </strong>The client (user agent, application, etc.) initiates a request to access a protected resource on the server. The server responds with a 401 Unauthorized HTTP status code, indicating that the request requires authentication.</p><p><strong>Credentials Preparation:</strong> The client prepares the user’s credentials by combining the username and password separated by a colon (e.g., “username:password”). This string is then base64-encoded to create a single string of characters. The resulting encoded string is sent to the server as part of the request header.</p><p><strong>Header Creation:</strong> The client creates an “Authorization” header in the format: “Basic &lt;base64-encoded-credentials&gt;”. The base64-encoded credentials string from the previous step is inserted after the word “Basic” with a space separating them. This header is included in the HTTP request sent to the server.</p><p><strong>Request Transmission:</strong> The client sends the HTTP request to the server, including the “Authorization” header. The request can be made using various HTTP methods like GET, POST, PUT, etc., depending on the type of action being performed on the resource.</p><p><strong>Server Validation:</strong> Upon receiving the request, the server recognizes the “Authorization” header and extracts the base64-encoded credentials.</p><p><strong>Decoding Credentials: </strong>The server decodes the base64-encoded credentials to retrieve the original username and password. It then verifies these credentials against its authentication database or mechanism.</p><p><strong>Authentication Outcome:</strong> If the credentials are valid, the server allows access to the requested resource and responds with the appropriate data along with a 200 OK status code. If the credentials are invalid, the server sends a 401 Unauthorized status code again, signaling to the client that the provided credentials are not authorized to access the resource.</p><p><strong>Continued Communication:</strong> If the client receives a 401 Unauthorized response, it typically prompts the user to provide valid credentials and repeats the process from step 2. This continues until valid credentials are provided or the client decides to abort the request.</p><h4><strong>PROS &amp; CONS OF BASIC AUTHENTICATION</strong></h4><p><strong>PROS</strong></p><ul><li>Simplicity in scenarios where rapid implementation is necessary, such as internal APIs or proof -of-concepts projects.</li><li>The stateless nature makes it suitable for APIs.</li></ul><p><strong>CONS</strong></p><ul><li>Inherent security risks due to transmitting credentials in plain text.</li><li>This method lacks flexibility for more advanced authentication scenarios.</li></ul><h3><strong>SESSION AUTHENTICATION</strong></h3><p>Session Authentication revolves around the concept of a user session, where a user logs in once, and the server maintains their authenticated state throughout their interaction with the application. Instead of sending credentials with each request, the server assigns a unique session identifier to the user after a successful login.</p><h4><strong>HOW SESSION AUTHENTICATION WORKS</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/783/1*C0plma3Ajwpqe9tTFHob9A.png" /></figure><p><strong>USING COOKIES FOR SESSION MANAGEMENT</strong></p><p><strong>Session Creation:</strong></p><p>When a user logs into a web application, the server generates a unique <strong><em>session identifier (session ID)</em></strong> for that user’s session. This identifier is typically a random string.</p><p>The server stores relevant session data (user information, preferences, etc.) associated with the session ID on the server-side memory or in a database.</p><p>The server sends the session ID to the client’s browser as a <strong><em>cookie</em></strong> in the HTTP response header. The cookie is then stored on the client’s machine.</p><p><strong>Session Management:</strong></p><p>With each subsequent request, the client’s browser automatically includes the session ID cookie in the <strong><em>HTTP request header.</em></strong></p><p>The server extracts the session ID from the request header, uses it to retrieve the corresponding session data from its storage, and processes the request in the context of that user’s session.</p><p>This allows the server to provide personalized content and maintain user state across different requests.</p><p><strong>Session Termination:</strong></p><p>Sessions can be terminated by the user explicitly logging out or by the server if the session becomes inactive for a specified period (session timeout).</p><p>When a session is terminated, the server removes the associated session data from its storage, and the session ID stored in the client’s cookie becomes invalid.</p><h4>PROS &amp; CONS OF SESSION AUTHENTICATION</h4><p><strong>PROS:</strong><br>- Improved security due to not sending credentials with each request.<br>- Flexibility for implementing features like “Remember Me” and user logout.</p><p><strong>CONS:</strong><br>- Requires server-side session management, which can be complex.<br>- Vulnerable to session hijacking and fixation if not implemented securely.</p><h4><strong>WHEN TO USE WHICH?</strong></h4><p>The decision between Basic and Session Authentication depends on the project’s requirements. Basic Authentication may be appropriate for internal APIs or situations where security is not a primary concern. However, for applications dealing with sensitive data or facing potential security threats, Session Authentication is the preferred choice. Developers should consider the application’s nature, security needs, and user experience when making this decision.</p><h4>CONCLUSION</h4><p>In the realm of authentication, Basic Authentication and Session Authentication are two distinct approaches with unique benefits and trade-offs. Basic Authentication is simple but lacks the security standards necessary for modern web applications. Session Authentication offers enhanced security but demands more sophisticated implementation. As developers, understanding these methods empowers us to make informed decisions, balancing security with user experience in the quest for robust authentication mechanisms.</p><p>Happy coding :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ff17ec692d27" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[NoSQL Databases: Unleashing the power of flexibility]]></title>
            <link>https://medium.com/@loydngei/nosql-databases-unleashing-the-power-of-flexibility-1567cd9f1752?source=rss-fbce245109be------2</link>
            <guid isPermaLink="false">https://medium.com/p/1567cd9f1752</guid>
            <category><![CDATA[nosql]]></category>
            <dc:creator><![CDATA[Loyd Ngei]]></dc:creator>
            <pubDate>Sun, 23 Jul 2023 16:02:24 GMT</pubDate>
            <atom:updated>2023-07-23T16:18:06.701Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/760/1*aft5e_gFeDW4DQ8tayEsrA.png" /></figure><p>In today’s data-driven world, the demand for efficient and scalable database solutions has skyrocketed. While traditional SQL databases have been the go-to choice for decades, a new breed of databases known as NoSQL databases has emerged, revolutionizing the way we store and manage data. In this article, we will explore the fascinating world of NoSQL databases, understand their key characteristics, contrast them with SQL databases, explore their use cases, and dive into examples of common NoSQL databases. We’ll also take a hands-on approach and show you how to get started with MongoDB, a popular NoSQL database.</p><h4><strong>What is a NoSQL Database?</strong></h4><p>A NoSQL database, short for “Not Only SQL,” is a database system that provides a flexible and scalable approach to storing and retrieving data. Unlike traditional SQL databases, which use rigid tabular structures, NoSQL databases operate on a more flexible data model. They are designed to handle vast amounts of unstructured or semi-structured data, making them ideal for use cases involving rapid data growth and dynamic schemas.</p><h4><strong>Contrasting NoSQL with SQL Databases</strong></h4><p>One of the fundamental differences between NoSQL and SQL databases lies in their data model. SQL databases rely on a relational system, organizing data into tables, columns, rows, and schemas. In contrast, NoSQL databases ditch the rigid structure and embrace various data models, such as key-value stores, document stores, wide-column stores, and graph stores.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/920/1*FZgklciTGPsyl7q__4WCTw.png" /></figure><h4><strong>NoSQL Models and when to use each:</strong></h4><p>When considering whether to use a NoSQL database, it’s essential to understand the different types or categories of NoSQL databases, each of which excels in specific scenarios.</p><ol><li><strong>Key-Value Stores: </strong>These databases excel in scenarios requiring high-speed read and write operations of non-transactional data. They are perfect for caching, session data, and managing user preferences.</li><li><strong>Document Stores:</strong> Document stores, such as MongoDB, store self-describing documents like JSON, XML, or BSON. They work well for use cases involving complex and hierarchical data structures, making them suitable for content management systems and social media applications.</li><li><strong>Wide-Column Stores:</strong> These databases store data in tables with rows and columns, but the names and formats of columns can vary from row to row. They are ideal for scenarios involving time series data and analyzing large datasets.</li><li><strong>Graph Stores:</strong> Graph databases use graph structures to store and query relationships between data entities. They excel in use cases like social networks, recommendation systems, and fraud detection.</li></ol><h4><strong>Pros and Cons of Using NoSQL Databases:</strong></h4><p>While NoSQL databases offer many advantages, they also come with some trade-offs.</p><h4><strong>Pros:</strong></h4><ul><li><strong><em>Scalability:</em></strong> NoSQL databases use a horizontal scale-out approach, allowing them to handle massive amounts of data and traffic efficiently.</li><li><strong><em>High Performance:</em></strong> The flexible data models and distributed architecture of NoSQL databases contribute to high performance and low latency.</li><li><strong><em>High Availability:</em></strong> NoSQL databases are designed to maintain high availability, ensuring data accessibility even during failures.</li><li><strong><em>Flexible Data Modeling:</em></strong> The ability to handle unstructured or semi-structured data makes NoSQL databases highly adaptable to evolving data requirements.</li></ul><h4><strong>Cons:</strong></h4><ul><li><strong><em>Lack of ACID Transactions:</em></strong> NoSQL databases may trade some ACID properties (Atomicity, Consistency, Isolation, Durability) for scalability and performance.</li><li><strong><em>Learning Curve:</em></strong> NoSQL databases introduce new data models and query languages, which may require developers to learn and adapt to new paradigms.</li><li><strong><em>Limited Joins:</em></strong> In some NoSQL databases, performing complex joins and relational queries can be challenging, requiring careful data modeling.</li></ul><h4><strong>Examples of Common NoSQL Databases:</strong></h4><ul><li><strong>MongoDB:</strong> A popular document-oriented database that stores documents in BSON format, making it a versatile choice for a wide range of applications.</li><li><strong>Cassandra:</strong> A distributed wide-column store, perfect for time-series data and real-time big data workloads.</li><li><strong>Redis:</strong> A key-value store known for its lightning-fast in-memory data storage, making it ideal for caching and real-time applications.</li><li><strong>Neo4j:</strong> A graph database that specializes in storing and querying data relationships. Data is stored just like you might sketch ideas on a whiteboard.</li></ul><h4><strong>Conclusion</strong></h4><p>In conclusion, NoSQL databases have transformed the landscape of data storage and retrieval, making them a vital asset in the modern tech ecosystem. Whether you are building a high-traffic web application, managing big data, or dealing with rapidly evolving data models, NoSQL databases offer the versatility and scalability to meet your needs. As you embark on your journey with NoSQL, keep exploring, experimenting, and embracing the vast possibilities these databases offer.</p><p>Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1567cd9f1752" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[INDEXING IN MySQL]]></title>
            <link>https://medium.com/@loydngei/indexing-in-mysql-71babc2bda49?source=rss-fbce245109be------2</link>
            <guid isPermaLink="false">https://medium.com/p/71babc2bda49</guid>
            <dc:creator><![CDATA[Loyd Ngei]]></dc:creator>
            <pubDate>Fri, 14 Jul 2023 11:04:24 GMT</pubDate>
            <atom:updated>2023-07-14T11:04:24.193Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wr1vYspX_CpjGEjiqn6W5A.jpeg" /></figure><p>Have you ever thought if textbooks didn’t have index pages how time consuming it would be looking for a specific topic in a book? That is how MySQL indexing literally works. The difference is instead of page numbers within a book, MySQL uses row numbers within related tables. Large organizations handle vast datasets consisting of millions of rows and columns of data. In such scenarios, efficient retrieval of specific results becomes crucial.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*BiaBNrSiI91rRbDUFD4PjQ.jpeg" /><figcaption>Book indexing</figcaption></figure><blockquote><strong><em>What is Indexing in MySQL?</em></strong></blockquote><p>Indexing in MySQL is a technique used to improve the performance of Database queries by creating data structures that allow faster data retrieval. An index is a separate data structure that contains a copy of selected columns from a table, along with a reference to the actual data in the table. This additional data structure enables the database engine to locate and retrieve the desired data more efficiently<br>When you create an index on one or more columns of a table, MySQL builds an index tree based on the values in those columns. This tree structure allows the database engine to perform faster lookup operations, reducing the need to scan the entire table for each query</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/1*ozOsEdDt6J1dxz0P59dxLA.png" /><figcaption>How B-tree indexing works in MySQL</figcaption></figure><h4>BENEFITS OF INDEXING IN MySQL</h4><ul><li><strong>Improved query performance</strong>. Instead of scanning the entire table, the engine can use the index to narrow down the search space and retrieve the required data more efficiently.</li><li><strong>Reduced disk I/O</strong>. Indexes store a subset of the table’s data which means accessing the index requires reading fewer disk blocks. This reduces disk I/O operations required to fetch the data, resulting in improved overall performance.</li><li><strong>Order and sorting optimizations</strong>. When querying data with an ‘ORDER BY’ clause, an appropriate index can facilitate the sorting process, avoiding need for a costly full table sort.</li><li><strong>Constraint enforcement</strong>. Indexes can be used to enforce unique constraints and primary key constraints, ensuring data integrity within the database.</li></ul><h4><strong>TRADE-OFFS OF INDEXING</strong></h4><ul><li>Additional overheads as data in the table is modified(Inserts, updates, deletes) and maintained.</li><li>Indexes consume disk space</li></ul><h4>HOW TO INDEX</h4><ol><li><strong>LISTING/SHOWING INDEXES</strong></li></ol><p>Listing indexes help you to manage multiple indexes in the table. Below is the syntax for viewing an index</p><pre>SHOW INDEX FROM tableName; </pre><p><strong>2. CREATING INDEXES</strong></p><p>Indexes can be created during table’s creation or added later on after table creation. We will go through all methods.</p><p><strong>(i) Create a table with a standard Index:</strong></p><p>This example creates a table consisting of ID, FirstName and LastName column with an index that uses column name ID as the Key:</p><pre>CREATE TABLE tableName<br>  ID int<br>  FirstName varchar(255)<br>  LastName varchar(255)<br>  INDEX (ID)</pre><p><strong>(ii) Create a Table with unique Index and Primary Key:</strong></p><p>This example creates a table consisting of ID, FirstName and LastName column with an index that uses column name ID as the index Key with both PRIMARY KEY and UNIQUE constraints enabled.</p><pre>CREATE TABLE tableName<br>  ID int<br>  FirstName varchar(255)<br>  LastName varchar(255)<br>  PRIMARY KEY (ID)<br>  UNIQUE INDEX (ID)</pre><p><strong>(iii) Add index to an existing table:</strong></p><p>This example creates an index named <em>indexName </em>on table named <em>tableName</em> with columns ID, FirstName and LastName as the concatenated index key</p><pre> CREATE INDEX indexName ON tableName (ID, FirstName, LastName);</pre><p><strong>(iv) Add an index to existing table with Primary key:</strong></p><p>This example creates a UNIQUE index named <em>indexName</em> on the table named <em>tableName</em> with columns ID, FirstName and LastName as the concatenated index key. This constrains the table/index to have no duplicates.</p><pre>CREATE UNIQUE INDEX indexName ON tableName (ID, FirstName, LastName);</pre><p><strong>(v) Run the actual query with indexes:</strong></p><p>It is time to retrieve data from our dataset within milliseconds depending on your task at hand. Works like magic.</p><p>The below SQL query performs a count of the number of rows in the table <em>tableName </em>that satisfy specific conditions on the columns <em>FirstName </em>and <em>LastName.</em></p><pre>SELECT COUNT(*) FROM tableName WHERE FirstName = &#39;x&#39; AND LastName = &#39;y&#39;;</pre><h4><strong>Caution:</strong></h4><p>Creating too many indexes can degrade the server performance rather than improve it. Extensive indexes may also require adjusting the MySQL configuration to increase the size of index related buffers.<br> <br><strong> 3. DELETING INDEXES</strong></p><p>This syntax deletes the index named <em>indexName </em>from the table named <em>tableName</em></p><pre>DROP INDEX indexName ON tableName;</pre><blockquote>CONCLUSION</blockquote><p>In conclusion, indexing in MySQL is a powerful technique to improve the performance of database queries by creating data structures that allow for faster data retrieval. It provides several benefits such as improved query performance, reduced disk I/O, order and sorting optimizations, and constraint enforcement.</p><p>However, there are trade-offs to consider when using indexing. Indexes consume disk space and incur additional overheads when modifying and maintaining data in the table. Creating too many indexes can also degrade server performance, so it’s important to strike a balance and carefully choose which columns to index based on query patterns and data modification frequency.</p><p>By properly utilizing indexes, you can significantly enhance the efficiency and speed of your database queries.</p><p>I hope you enjoyed this post.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=71babc2bda49" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>