<?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 Ahmad Farag on Medium]]></title>
        <description><![CDATA[Stories by Ahmad Farag on Medium]]></description>
        <link>https://medium.com/@ahmadfarag?source=rss-2ff04be71f9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*tikz7DrPoopDuNjWRvbH_A.jpeg</url>
            <title>Stories by Ahmad Farag on Medium</title>
            <link>https://medium.com/@ahmadfarag?source=rss-2ff04be71f9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 21:29:08 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ahmadfarag/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[Nine principles to a Healthy Software Engineering Culture]]></title>
            <link>https://medium.com/@ahmadfarag/nine-principles-to-a-healthy-software-engineering-culture-2c44664f2d10?source=rss-2ff04be71f9------2</link>
            <guid isPermaLink="false">https://medium.com/p/2c44664f2d10</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[engineering-mangement]]></category>
            <category><![CDATA[tech]]></category>
            <dc:creator><![CDATA[Ahmad Farag]]></dc:creator>
            <pubDate>Thu, 01 Apr 2021 07:54:57 GMT</pubDate>
            <atom:updated>2021-04-01T07:57:34.956Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Nine principles to a Healthy Software Engineering Culture</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*S2oGmZHHWNB4oF8q" /><figcaption>Photo by <a href="https://unsplash.com/@wocintechchat?utm_source=medium&amp;utm_medium=referral">Christina @ wocintechchat.com</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4><strong>1- Ask for Feedback</strong></h4><p>Feedback helps you see the dark areas that won’t be visible for you but visible for others as they communicate and work with you daily, so always search for a trusted and experienced colleague or manager to give you feedback.</p><blockquote>“Feedback is the breakfast of champions.” — Ken Blanchard.</blockquote><h4><strong>2- Provide feedback</strong></h4><p>Giving feedback helps others to grow, but there is art about how to provide feedback,</p><p>It’s better to start mentioning bad things first as it ends up talking with a person who takes a defense mood against you, then you waste time-fighting back.</p><p>The excellent approach you should start telling him the good things he has,</p><p>then carefully choose a good way to mention something that he needs to change or improve.</p><blockquote>“We all need people who will give us feedback. That’s how we improve.” Bill Gates</blockquote><h4>3- Invest some time documents your code</h4><p>A Software engineer sees writing documentation as a waste of time, but it saves other’s time; thinks about it as you are working as part of a big team. How will the new joiner be able to understand your code?</p><p>you may think that “great software engineers will be able to understand any code by running it. “ <br>it is partially true, but you should start thinking about saving such time for your team to enhance and develop a new feature.</p><blockquote>“Alone we can do so little, together we can do so much.” — Helen Keller</blockquote><h4>4- Eliminate a single point of failure.</h4><p>As engineers, we love to develop services and solutions as it makes our adrenaline rush.</p><p>During that, you will have one person who knows everything about particular domains while others start treating his work as a black box !!</p><p>Drawing a data flow diagram or high-level architecture with involvement between team members may bring many cases that may be invisible to you.</p><blockquote>“Alone we can do so little, together we can do so much.” <em>— Helen Keller</em>.</blockquote><h4>5- Don’t reinvent the wheel.</h4><p>Today we have multiple solutions, which others built. Invest a time reading and doing some R&amp;D about the thing you will make. Otherwise, you will end up reinventing the wheel.</p><h4>6- Search for a mentor</h4><p>A path you just started many people went through, so finding a mentor will accelerate your progress and guide you to the right track.</p><blockquote>“Tell me, and I forget, teach me, and I may remember, involve me and I learn.” ― Benjamin Franklin.</blockquote><h4>7- Be a good team player</h4><p>A good team player leads to a healthy environment where the team is more focused, productive, and energized.</p><blockquote>“try not to be a rotten egg inside your team basket. “</blockquote><h4>8- No Hire is Better Than a Bad Hire</h4><p>Bad hire wastes your team’s time and slows them down, so be careful while hiring new resources as it could be a nightmare that won’t allow you or your team to grow; instead of that, try to be cautious while hiring by having a proper process.</p><blockquote><em>“ I’d rather interview 50 people and not hire anyone than hire the wrong person.” Jeff Bezos</em></blockquote><h3>9- Never stop learning</h3><p>Be curious and passionate about expanding your knowledge, so keep it a daily habit to learn new things and share what you know with others — these are the keys that accelerate your learning and growth.</p><p>“Learning is a Lifelong Process” <em>– Peter Drucker</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2c44664f2d10" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MongoDB — Redis Queries Logging]]></title>
            <link>https://medium.com/@ahmadfarag/mongodb-redis-queries-logging-cd9affda0c4a?source=rss-2ff04be71f9------2</link>
            <guid isPermaLink="false">https://medium.com/p/cd9affda0c4a</guid>
            <category><![CDATA[redis]]></category>
            <category><![CDATA[mongodb]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[logging]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Ahmad Farag]]></dc:creator>
            <pubDate>Mon, 28 Jan 2019 14:16:52 GMT</pubDate>
            <atom:updated>2019-01-28T20:45:36.780Z</atom:updated>
            <content:encoded><![CDATA[<h3>MongoDB-Redis Queries Logging</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HmZ_UMgshvfWfe4D" /><figcaption>Photo by <a href="https://unsplash.com/@casparrubin?utm_source=medium&amp;utm_medium=referral">Caspar Camille Rubin</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><blockquote>Assume you have an Application and you have to keep an eye on MongoDB’s queries or you want to track all Redis operations in order to optimize your application performance, the question which will jump to your mind how can i do that ?</blockquote><blockquote>following this article you will be able to do that.</blockquote><h4>1- MongoDB Logging using <a href="https://github.com/mrsarm/mongotail">Mongotail</a></h4><p>I am going to use <a href="https://github.com/mrsarm/mongotail"><strong>mongotail</strong></a> which is command line tool to outputs any operation from a Mongo database in the standard output</p><p><strong>Install</strong></p><pre><strong>pip install mongotail</strong></pre><p><strong>Get started</strong></p><p>I built a small NodeJs app to <strong>insert,</strong> <strong>query </strong>and<strong> drop </strong>this JSON data</p><pre>{&quot;name&quot;:&quot;test&quot;,&quot;location&quot;:&quot;dubai&quot;,&quot;subject&quot;:&quot;demo&quot;}</pre><p><strong>First</strong>, we have to set log level to<strong> 2 </strong>to list all the operations [<strong>Enable Logging</strong>]</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e9269744bcecbb599b52726cb9c62df1/href">https://medium.com/media/e9269744bcecbb599b52726cb9c62df1/href</a></iframe><p><strong>Second</strong>, tail the logs so we can see all queries [<strong>List All the operations</strong>]</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4f5895e9d35e06740c3ace3ae171ceef/href">https://medium.com/media/4f5895e9d35e06740c3ace3ae171ceef/href</a></iframe><p><strong>The results will be</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/926/1*68HNSrkzvgWiiXQkAEyfUg.png" /><figcaption>insert &amp; query &amp; remove operations</figcaption></figure><h4>2- Redis Logging using <a href="https://redis.io/commands/MONITOR">Monitor</a></h4><p>Debugging command that streams back every command processed by the Redis server.</p><p><strong>Example</strong></p><p>Assume we have some <strong>set</strong> and <strong>get </strong>operations on Redis server</p><p>Now run [then do any operations on Redis]</p><pre><strong>redis-cli  monitor</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1xROC0-ZGXAtgxZRowZ0eA.png" /><figcaption>it streams all the operations</figcaption></figure><h4>Filtering only <strong>set</strong> and <strong>get</strong></h4><pre><strong>redis-cli  monitor | grep -E &#39;get|set&#39;</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dThNzIbmuNtiLgIK3kpowA.png" /><figcaption>now we have only set and get operations</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cd9affda0c4a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Journey TO DNS - Part 2]]></title>
            <link>https://medium.com/@ahmadfarag/journey-to-dns-part-2-1f48716638fd?source=rss-2ff04be71f9------2</link>
            <guid isPermaLink="false">https://medium.com/p/1f48716638fd</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[dns]]></category>
            <dc:creator><![CDATA[Ahmad Farag]]></dc:creator>
            <pubDate>Thu, 09 Aug 2018 14:21:29 GMT</pubDate>
            <atom:updated>2018-08-14T10:46:08.551Z</atom:updated>
            <content:encoded><![CDATA[<p>The Domain Name System</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_NioSyzfRakMwFZq" /><figcaption>“A meshwork of green ropes against a red background” by <a href="https://unsplash.com/@clintadair?utm_source=medium&amp;utm_medium=referral">Clint Adair</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>In <a href="https://medium.com/tech-tajawal/journey-to-dns-part-1-96348198a2be">Part 1</a> We talked about :-</h4><ul><li><strong>What is DNS?</strong></li><li><strong>The History Of DNS</strong></li><li><strong>Why DNS is important?</strong></li><li><strong>DNS Hierarchy</strong></li><li><strong>How does DNS work?</strong></li></ul><h4>The main points for this part are:-</h4><ol><li><a href="#863c"><strong>Domain Delegation</strong></a></li><li><a href="#1151"><strong>Resource Record (RRs)</strong></a></li><li><a href="http://93ef/"><strong>DNS Query</strong></a></li><li><a href="#6cb0"><strong>DNS Message</strong></a></li><li><a href="#ab79"><strong>DNS zones</strong></a></li><li><a href="#a56e"><strong>DNS Resolvers</strong></a></li></ol><h4>Domain Delegation</h4><p>Domain delegation gives an organization authority for a domain. Having authority for a domain means that the organization’s network administrator is responsible for maintaining the DNS database of hostname and address information for that domain, example <a href="https://www.iana.org/domains/root/db/dev.html">Google is repressible for managing .DEV</a></p><h4>Resource Record (RRs)</h4><p>DNS resource records describe the characteristics of a zone (or domain) and have a binary or wire-format, which is used in queries and responses, and a text format used in zone files and <a href="http://www.zytrax.com/books/dns/ch8/">you can find more details here</a>.</p><h4>DNS Query</h4><p>The DNS QUERY operation consists of a query and an answer. A query contains a request for an RR (or several RRs) from the DNS database.</p><h4>DNS Message</h4><p>The DNS protocol uses a common message format for all exchanges between client and server or between servers. The DNS messages are encapsulated over <strong>UDP</strong> or <strong>TCP</strong> using port 53.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/983/1*Sp--KelFEcj8PNf7RCvaEA.png" /></figure><blockquote>DNS uses UDP for message smaller than 512 bytes (common requests and responses).</blockquote><p><strong>DNS Message Structure</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/589/1*4D2pKSrfDFwz3ZEjOzkarw.png" /></figure><ol><li><strong>Identification: </strong>field is used to match up replies and requests.</li><li><strong>Questions: </strong>what is the IP of this Domain Name or it could be what is Domain Name of this IP</li><li><strong>Answers: </strong>here is the IP Address or The Domain name which you asked for.</li><li><strong>Authority:</strong> pointing to an authority.</li><li><strong>Additional Information</strong>: holding additional information.</li></ol><h4>DNS Resolvers</h4><p>Resolvers are client half of DNS’s client-server system which take application’s requests for data and <strong>translate</strong> them into DNS Query then <strong>wait the response</strong> and <strong>unmarshals</strong> it into a data structure that it <strong>passes back to application</strong>.</p><h4>DNS Zones</h4><ul><li><strong>Forward lookup zone: </strong>you have a host name and you want IP Address of this Host.</li><li><strong>Reverse lookup zone: </strong>you have IP Address and you need to get Host name for example when email server wants to verify emails which should come from a valid domain name.</li></ul><h4>References:</h4><ul><li><a href="http://www-inf.int-evry.fr/~hennequi/CoursDNS/NOTES-COURS_eng/msg.html">http://www-inf.int-evry.fr/~hennequi/CoursDNS/NOTES-COURS_eng/msg.html</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1f48716638fd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ansible In Action]]></title>
            <link>https://medium.com/@ahmadfarag/ansible-in-action-f2f17706931?source=rss-2ff04be71f9------2</link>
            <guid isPermaLink="false">https://medium.com/p/f2f17706931</guid>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[ansible]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Ahmad Farag]]></dc:creator>
            <pubDate>Wed, 01 Aug 2018 13:54:27 GMT</pubDate>
            <atom:updated>2018-08-14T08:22:28.399Z</atom:updated>
            <content:encoded><![CDATA[<p>Ansible + Real World App</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kNJ69PsKPZfd26jh" /><figcaption>“Colorful software or web code on a computer monitor” by <a href="https://unsplash.com/@markusspiske?utm_source=medium&amp;utm_medium=referral">Markus Spiske</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>What Is Ansible?</h3><p>is an open source software that automates software provisioning, configuration management, and application deployment.</p><h3>The Keys Features of Ansible</h3><h4>Agentless</h4><p>There is no software or agent to be installed on the client that communicates back to the server.</p><h4><a href="https://medium.com/@ahmadfarag/idempotency-764f7bb6e4e2">Idempotent</a></h4><p>No matter how many times you call the operation, the result will be the same.</p><h4>Simple and extensible</h4><p>Ansible is written in Python and uses YAML for playbook language, both of which are considered relatively easy to learn.</p><h3>Get Started</h3><h4>Installing and Running Ansible</h4><pre># ubuntu <br>sudo apt-get install ansible<br>#mac-OS<br>brew install ansible</pre><p>For other OS check this <a href="https://docs.ansible.com/ansible/2.5/installation_guide/intro_installation.html">link</a></p><h3>Ansible Architecture</h3><h4>Modules</h4><p>small programs that do some work on the server, so for example instead of running this command</p><pre>sudo apt-get install htop</pre><p>we can use apt module and install htop</p><pre>- name: Install htop<br>  apt: name=htop</pre><p>Using module give you the ability to know if it’s installed or not.</p><h4>Plugins</h4><p>Plugins are pieces of code that augment Ansible’s core functionality. Ansible ships with a number of handy plugins, and you can easily write your own.</p><h4>Host inventories</h4><p>To provide a list of hosts, we need to provide an inventory list. This is in the form of a hosts file.</p><p>In its simplest form, our hosts file could contain a single line:</p><pre>35.178.45.231  ansible_ssh_user=ubuntu</pre><h4>Playbooks</h4><p>Ansible playbooks are a way to send commands to remote computers in a scripted way. Instead of using Ansible commands individually to remotely configure computers from the command line, you can configure entire complex environments by passing a script to one or more systems.</p><h4>group_vars</h4><p>file contains set of variables for example db username and password.</p><h4>roles</h4><p>Roles are a way to group multiple tasks together into one container to do the automation in very effective manner with clean directory structures</p><h4>handlers</h4><p>Handlers are lists of tasks, not really any different from regular tasks, that are referenced by a globally unique name, and are notified by notifiers. If nothing notifies a handler, it will not run. Regardless of how many tasks notify a handler, it will run only once, after all of the tasks complete in a particular play.</p><h4>Tags</h4><p>If you have a large playbook it may become useful to be able to run a specific part of the configuration without running the whole playbook.</p><h3><a href="https://github.com/ahmedfaragmostafa/ansible-4-laravel">Demo “Real World App”</a></h3><p>The goal of this demo to install Laravel App in VPS, in this demo i am going to use <a href="https://aws.amazon.com/lightsail/">lightsail</a>.</p><h4>The steps to make Laravel APP up and Running are :-</h4><ol><li><a href="#b6ec">Creating ubuntu Lightsail instance</a></li><li><a href="#25cf">Installing Ansible prerequisites on our VPS</a></li><li><a href="#1d20">Building our hosts and ansible.cfg</a></li><li><a href="#ba05">Adding instance ssh-key to git access keys</a></li><li><a href="#0aa0">Define a Role in Ansible</a></li><li><a href="#37d4">Define a Handler in Ansible</a></li><li><a href="#4519">Installing PHP Modules</a></li><li><a href="#fd52">Installing Nginx</a></li><li><a href="#3388">Adding Nginx default config file</a></li><li><a href="#3459">Adding vars to manage db credentials, host, github origin url and .env variables</a>.</li><li><a href="#4cad">Creating MySql DB, UserName and Password</a></li><li><a href="#b575">Using Ansible-vault</a></li><li><a href="#c5b6">Clone code base to our VPS</a></li><li><a href="#5f8b">Generating </a><a href="#5f8b">.env</a></li><li><a href="#459f">Creating our playbook.</a></li></ol><h4><strong>Creating ubuntu Lightsail instance</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BJsuHjjOv8l-iWyK_HCimg.png" /><figcaption>Go to Lightsail Dashboard and click <strong>create Instance</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RyjXMXMvPNTju05QD8hK1Q.png" /><figcaption>Choose your favourite OS</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/958/1*szDeGFIuFnXMJAx9ri6ANg.png" /><figcaption>Choose Add launch script which run once you created your instance , Don’t forget to get ssh-key</figcaption></figure><p><strong>Installing Ansible prerequisites on our VPS</strong></p><pre><em>sudo </em>add-apt-repository ppa:deadsnakes/ppa -y<br><em>sudo </em>apt-get update<br><em>sudo </em>apt-get install -y python2.7 python3 python-pip</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mv8hONZPT7zZjG0-bJ2XGQ.png" /><figcaption>Add this sh commands to install Ansible requirements</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SFEcu-pqfMrQSkBT0BKBEQ.png" /><figcaption>Now you have your lighsail image up and running</figcaption></figure><p>Now we have our instance up and running lets start build our Ansible Project.</p><h4>Adding instance ssh-key to git access keys</h4><p>you have to add your server <strong>id_rsa.pub</strong> to your github <strong>ssh keys</strong> by login to your instance</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/df52b8581a1992ac07eb3aee50451e94/href">https://medium.com/media/df52b8581a1992ac07eb3aee50451e94/href</a></iframe><h4><strong>Building our hosts and ansible.cfg</strong></h4><p><strong>hosts.ini</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f21ddf1af34169d91a16d56f8f47aa48/href">https://medium.com/media/f21ddf1af34169d91a16d56f8f47aa48/href</a></iframe><p><strong>ansible.cfg</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d33823d7e1cef8fd6c7ef9af10946f9a/href">https://medium.com/media/d33823d7e1cef8fd6c7ef9af10946f9a/href</a></iframe><p><strong>Define a Role in Ansible</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7cfb381d6660f432c42a853e6bc0e350/href">https://medium.com/media/7cfb381d6660f432c42a853e6bc0e350/href</a></iframe><p><strong>Define a Handler</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a1f3e00b6f686bc5976327b1ef8ce464/href">https://medium.com/media/a1f3e00b6f686bc5976327b1ef8ce464/href</a></iframe><h4>Installing PHP Modules</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7265014ab5b50885d07a471cbd29e349/href">https://medium.com/media/7265014ab5b50885d07a471cbd29e349/href</a></iframe><h4>Installing Nginx</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1fdb61294b823e35c6680e039140e0b8/href">https://medium.com/media/1fdb61294b823e35c6680e039140e0b8/href</a></iframe><h4>Adding Nginx default config file</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d205d1110ee33822690ea76a7f1fc9dd/href">https://medium.com/media/d205d1110ee33822690ea76a7f1fc9dd/href</a></iframe><p><strong>vars.yml</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fa28ce26696d2f5201df1f4e1454a0b3/href">https://medium.com/media/fa28ce26696d2f5201df1f4e1454a0b3/href</a></iframe><blockquote>it’s recommended approach to use ansible-vault to encrypt and decrypt your vars</blockquote><h4>How to use Ansible-vault</h4><p>Create vault secret file which contains encryption key which encrypts your var</p><pre>touch .vault_pass.txt<br>echo &#39;YOUR_CONFIG_PASS&#39; &gt; .vault_pass.txt</pre><p><strong>Encrypt your vars</strong></p><pre>ansible-vault encrypt group_vars/vars.yml --vault-password-file .vault_pass.txt</pre><p><strong>Decrypt your vars</strong></p><pre>ansible-vault decrypt group_vars/vars.yml --vault-password-file .vault_pass.txt</pre><h4>Creating MySql DB, UserName and Password</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/09efb13eb19e251a985af1c8ccabba3b/href">https://medium.com/media/09efb13eb19e251a985af1c8ccabba3b/href</a></iframe><h4>Clone our code base</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b6c8f1f4c4ff4845240bca7862468ac2/href">https://medium.com/media/b6c8f1f4c4ff4845240bca7862468ac2/href</a></iframe><h4>Generating .env</h4><p>Ansible uses <a href="https://docs.ansible.com/ansible/2.6/user_guide/playbooks_templating.html">Jinja2</a> templating to enable dynamic expressions and access to variables, lets create Template env.conf file</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/595ccbb924f8dc5f3ee2b38e7ac0c204/href">https://medium.com/media/595ccbb924f8dc5f3ee2b38e7ac0c204/href</a></iframe><p>Lets define role to move this template to our application dir</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9fe558154af72423338fc39267f2dff7/href">https://medium.com/media/9fe558154af72423338fc39267f2dff7/href</a></iframe><h4>Creating PlayBook</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8aaa1bcb477caf87d859c4c9f0e2da39/href">https://medium.com/media/8aaa1bcb477caf87d859c4c9f0e2da39/href</a></iframe><p><strong>Run Your Playbook</strong></p><pre>#ansible-playbook playbookName<br>ansible-playbook code-deploy.yml</pre><pre># run with specific tags <br>ansible-playbook playbook.yml --tags=&quot;env-files,php&quot;</pre><pre>#if you are using ansible-valut <br>ansible-playbook code-deploy.yml --vault-password-file  .vault_pass.txt</pre><h4><a href="https://github.com/ahmedfaragmostafa/ansible-4-laravel">The Complete Project structure</a></h4><pre>├── ansible.cfg<br>├── code-deploy.yml<br>├── files<br>│   └── dump.sql<br>├── group_vars<br>│   └── vars.yml<br>├── handlers<br>│   └── main.yml<br>├── hosts.ini<br>├── logs<br>│   └── ansible-log.log<br>├── roles<br>│   ├── bootstrap-app<br>│   │   └── tasks<br>│   │       └── main.yml<br>│   ├── code-deploy<br>│   │   ├── tasks<br>│   │   │   ├── config-files.yml<br>│   │   │   └── main.yml<br>│   │   └── templates<br>│   │       └── env.conf<br>│   ├── misc<br>│   │   └── tasks<br>│   │       └── main.yml<br>│   ├── mysql<br>│   │   └── tasks<br>│   │       ├── config.yml<br>│   │       └── main.yml<br>│   ├── nginx<br>│   │   ├── tasks<br>│   │   │   └── main.yml<br>│   │   └── templates<br>│   │       └── nginx.conf<br>│   ├── php<br>│   │   └── tasks<br>│   │       └── main.yml<br>│   └── redis<br>│       └── tasks<br>│           └── main.yml<br>├── scripts<br>│   ├── install_composer.sh<br>│   └── startup.sh<br>└── site.yml</pre><h4><a href="https://github.com/ahmedfaragmostafa/Ansible-in-action">Github Repo which contains the Complete Source Code.</a></h4><h4>This <a href="http://maqoola.co/">website</a> up and running using this code base.</h4><h3>References</h3><ul><li><a href="https://docs.ansible.com/ansible/2.5/user_guide/playbooks_best_practices.html">https://docs.ansible.com/ansible/2.5/user_guide/playbooks_best_practices.html</a></li><li><a href="https://docs.ansible.com/ansible/2.5/dev_guide/overview_architecture.html">https://docs.ansible.com/ansible/2.5/dev_guide/overview_architecture.html</a></li><li><a href="https://www.digitalocean.com/community/tutorials/how-to-create-ansible-playbooks-to-automate-system-configuration-on-ubuntu">https://www.digitalocean.com/community/tutorials/how-to-create-ansible-playbooks-to-automate-system-configuration-on-ubuntu</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f2f17706931" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Journey TO DNS - Part 1]]></title>
            <link>https://medium.com/tech-tajawal/journey-to-dns-part-1-96348198a2be?source=rss-2ff04be71f9------2</link>
            <guid isPermaLink="false">https://medium.com/p/96348198a2be</guid>
            <category><![CDATA[dns]]></category>
            <category><![CDATA[networking]]></category>
            <dc:creator><![CDATA[Ahmad Farag]]></dc:creator>
            <pubDate>Sat, 28 Jul 2018 18:14:39 GMT</pubDate>
            <atom:updated>2018-08-09T13:24:20.984Z</atom:updated>
            <content:encoded><![CDATA[<p>The Domain Name System</p><h4>The main points in this article :-</h4><ul><li><a href="#ce85"><strong>What is DNS and why we use it</strong></a></li><li><a href="#b6ad"><strong>DNS History</strong></a></li><li><a href="#c92b"><strong>DNS Hierarchy</strong></a></li><li><a href="#2b9f"><strong>How DNS works</strong></a></li></ul><blockquote><strong>Funny Fact about DNS :</strong></blockquote><blockquote>when you type <a href="http://www.googlw/"><strong>www.googl</strong></a><strong>e.com</strong> you actually going to page <a href="http://www.google.com/"><strong>www.google.com</strong></a><strong>.</strong></blockquote><blockquote>there is <strong>a dot</strong> at the end of the domain 🙂 “give it a try …….”</blockquote><blockquote>where is the last dot represents the root of the internet’s NameSpace</blockquote><h4>What is DNS “Domain Name Server”?</h4><p>Is like a phone book for the Internet, If you know a person’s name but don’t know their telephone number, you can simply look it up in a phone book.</p><p>DNS provides this same service to the Internet by <strong>mapping a domain name to IP Address</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*MUr-yjk7H6KRm5DF.jpg" /></figure><p>For example, if someone types <a href="http://google.com/">google.com</a> DNS server will look inside its <strong>zone file </strong>then it will map a domain name to an IP address 216.58.207.14</p><p>and it sends it back to the browser.</p><h4>Why DNS Is Important?</h4><ul><li>Web browsers interact through Internet Protocol (IP) addresses.</li><li>Elimination of the need for humans to memorize complex IP addresses.</li></ul><h4><strong>The History Of DNS</strong></h4><p>Before DNS there was only single monolithic file “<strong>hosts.txt</strong>” mapping the names of all ARPANET’s hosts to their addresses.</p><p>Maintaining this file was a lot of hassle as</p><ul><li>They only updated this file only twice a week.</li><li>Searching the file was linear O(n)</li><li>Latency and consistency</li></ul><blockquote>Then they started thinking about how to build DNS servers in the current structure.</blockquote><h4><strong>DNS Hierarchy</strong></h4><p>The DNS hierarchy is comprised of the following elements:</p><p><strong>1- Root Level</strong></p><p>First step in resolving human readable host names into IP addresses</p><p><strong>2- Top Level Domain Nameservers</strong></p><p>Top Level Domains (TLD) are defined in the root domain, if These servers don’t have the information we need, but they can refer us directly to the servers that <em>do</em> have the information.</p><p>We have two kinds of <strong>TLD</strong> :-</p><p>Generic Top Level Domain (gTLD) : example edu, com, net, and mil</p><p>Country Code Top Level Domain(ccTLD) : for individual countries, For example, the <strong>us</strong> domain is affiliated with USA</p><p><strong>3- Second Level Domains</strong></p><p>is 3rd level in the hierarchical Domain Name System of the internet. It is directly below the TLD.</p><p><strong>3- Sub-Domain</strong></p><p>Sub domain is considered as the part of the second level domains</p><h3>How does DNS work?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/532/1*CqMBr7xHlBBufAPeLu7Eiw.png" /></figure><p>First, computer looks is its local <strong>DNS cache</strong>, which stores information that that computer has recently retrieved.</p><p>If computer has recently retrieved your computer doesn’t already know the answer, it needs to perform a <strong>DNS query</strong> to find out</p><p>computer queries <strong>Recursive DNS servers </strong>which have their own cache, if <strong>Recursive DNS servers </strong>don’t know the answer</p><p>they query <strong>Root nameservers</strong></p><p>which look at the first part of domain example<strong>.com</strong> and direct query to <strong>TLD</strong></p><p>Then, we have to go all the way back to <strong>the root name servers</strong>.</p><p>Then we ask the COM <strong>top level domain (TLD) nameservers</strong> that handle all the traffic for sites ending in .com</p><p>From here, the .com name servers identify what name servers <strong>example.com</strong> is a responsible for, If <strong>TLD nameservers</strong> don’t have the information we need it directs the query to <strong>authoritative nameserver </strong>which know all information about specific domain<strong> </strong>which are stored in <strong>DNS records, </strong>then it retrieves<strong> “</strong>A record”.</p><p>Finally, the <strong>authoritative servers</strong> for example.com respond with the appropriate IP address for <a href="http://www.example.com./"><strong>www.example.com.</strong></a></p><p><strong>References</strong>:-</p><ul><li><a href="http://www-inf.int-evry.fr/~hennequi/CoursDNS/NOTES-COURS_eng/msg.html">http://www-inf.int-evry.fr/~hennequi/CoursDNS/NOTES-COURS_eng/msg.html</a></li><li><a href="http://www.dailywebsolutions.com/what-is-DNS-and-DNS-hierarchy">http://www.dailywebsolutions.com/what-is-DNS-and-DNS-hierarchy</a></li><li><a href="https://dyn.com/blog/dns-why-its-important-how-it-works/">https://dyn.com/blog/dns-why-its-important-how-it-works/</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=96348198a2be" width="1" height="1" alt=""><hr><p><a href="https://medium.com/tech-tajawal/journey-to-dns-part-1-96348198a2be">Journey TO DNS - Part 1</a> was originally published in <a href="https://medium.com/tech-tajawal">tajawal</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Idempotency For Dummies]]></title>
            <link>https://medium.com/@ahmadfarag/idempotency-764f7bb6e4e2?source=rss-2ff04be71f9------2</link>
            <guid isPermaLink="false">https://medium.com/p/764f7bb6e4e2</guid>
            <category><![CDATA[pipeline]]></category>
            <category><![CDATA[sofware-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[patterns]]></category>
            <dc:creator><![CDATA[Ahmad Farag]]></dc:creator>
            <pubDate>Thu, 19 Jul 2018 13:04:47 GMT</pubDate>
            <atom:updated>2018-07-19T15:23:21.457Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Y8DGbjX5ScKz8PmR" /><figcaption>Photo by <a href="https://unsplash.com/@ryansong?utm_source=medium&amp;utm_medium=referral">Ryan Song</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>What is an Idempotency?</h4><p>One can apply a certain operation on something many times, without changing the result of the operation after the first time the operation is applied.</p><blockquote>No matter how many times you call the operation, the result will be the same.</blockquote><blockquote><strong>The Funny Example about it</strong></blockquote><blockquote>let’s say we have a cow it eats a mixture of grass hay, alfalfa hay, grains as well as corn and grass silage and <strong>it always gives you a milk</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_tyfC7kU1SPJvzxe-Cm9ZA.png" /></figure><h4>Idempotent REST APIs</h4><p>If clients can make that same call repeatedly while producing the same result, for example :- avoid processing a transaction multiple times.</p><h3>Idempotent methods</h3><p>An idempotent HTTP method is a HTTP method that can be called many times without different outcomes. It would not matter if the method is called only once, or ten times over. The result should be the same.</p><p><strong>Examples</strong></p><p>The GET method is <strong>idempotent</strong>, as multiple calls to the GET resource will always return the same response.</p><p>The PUT method is <strong>idempotent</strong>, as calling the PUT method multiple times will update the same resource and not change the outcome.</p><p>The POST is <strong>not idempotent</strong>, and calling the POST method multiple times can have different results and will result in creating new resources.</p><p>The DELETE is <strong>idempotent</strong> because once the resource is deleted, it is gone and calling the method multiple times will not change the outcome.</p><p><strong>References</strong> :</p><ul><li><a href="https://tools.ietf.org/html/rfc7231#section-4.2.2">https://tools.ietf.org/html/rfc7231#section-4.2.2</a></li><li><a href="https://restfulapi.net/idempotent-rest-apis/">https://restfulapi.net/idempotent-rest-apis/</a></li><li><a href="https://ieftimov.com/understand-how-why-add-idempotent-requests-api">https://ieftimov.com/understand-how-why-add-idempotent-requests-api</a></li><li><a href="https://stackoverflow.com/questions/1077412/what-is-an-idempotent-operation">https://stackoverflow.com/questions/1077412/what-is-an-idempotent-operation</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=764f7bb6e4e2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Power Of Makefile]]></title>
            <link>https://medium.com/tech-tajawal/the-power-of-makefile-31a3767d553c?source=rss-2ff04be71f9------2</link>
            <guid isPermaLink="false">https://medium.com/p/31a3767d553c</guid>
            <category><![CDATA[c]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[makefile]]></category>
            <category><![CDATA[bash]]></category>
            <dc:creator><![CDATA[Ahmad Farag]]></dc:creator>
            <pubDate>Thu, 19 Jul 2018 11:03:23 GMT</pubDate>
            <atom:updated>2019-02-25T06:24:16.068Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PiiOLulMKVaNwQw1" /><figcaption>“Macro shot of Storm Trooper toys with a black background.” by <a href="https://unsplash.com/@lamppidotco?utm_source=medium&amp;utm_medium=referral">James Pond</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>A makefile is a special file, containing shell commands, While in the directory containing this makefile, you will type <strong><em>make</em></strong> and the commands in the makefile will be executed</p><p><strong>Get Started:</strong></p><pre>touch Makefile</pre><p>Open Makefile and paste the following lines into it which three tasks</p><p>help ,install andprepare</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0290947f811b64067f397b9374690b5e/href">https://medium.com/media/0290947f811b64067f397b9374690b5e/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*Bw4AiaXCa04jI7-92SN-pg.png" /></figure><p>by default, make considers first task as default task to change this behavior add this line</p><pre>.DEFAULT_GOAL := prepare</pre><p>Now type make</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/368/1*ASPovoLN7shxZQ8SKbR-8Q.png" /></figure><p><strong>Execute a set of tasks in one command</strong></p><p>Assume you have a project and you have first to <strong>clean</strong> unwanted files then you have to <strong>download</strong> a file then <strong>execute</strong> the command it will be a lot of hassle to tell a user to do a set of tasks instead of that we can do it via a <strong>single and short command</strong> using Makefile.</p><p>so we have to define make file contains set of tasks clean, download, execute and <strong>install</strong> which will be the task that executes <strong>[clean, download, execute]</strong></p><p>and this can happen using this syntax</p><pre>install: clean download execute</pre><p>As you see i have only two files ( <strong>Makefile</strong> and <strong>dummy.txt), </strong>dummy.txt contains text</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/874/1*GEt9R2E_k6FNiJ7WjiWrVA.png" /></figure><p><strong>Makefile Example</strong>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0cff1cd03408740e396a928dc54c55e2/href">https://medium.com/media/0cff1cd03408740e396a928dc54c55e2/href</a></iframe><p>Now type make which will execute <strong>install</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/639/1*XqXaptyNLhLtUo3OzS092A.png" /></figure><p>as we can see it executed three tasks clean, download and execute</p><p>and we have <strong>ipInfo.sh</strong> exists in current dir and it cleared <strong>dummy.txt</strong> content.</p><h3><strong>Autogenerate help command to make:</strong></h3><p>follow that then you will be able to generate it from comments</p><p>just you have to add comments that start with `##` then add the description</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e7fc891299ba0a93e967c34d980a6fa8/href">https://medium.com/media/e7fc891299ba0a93e967c34d980a6fa8/href</a></iframe><p>Output</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/877/1*LUrj9JlLOe9Ox7cuYThjug.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=31a3767d553c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/tech-tajawal/the-power-of-makefile-31a3767d553c">The Power Of Makefile</a> was originally published in <a href="https://medium.com/tech-tajawal">tajawal</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HTTP In Depth]]></title>
            <link>https://medium.com/@ahmadfarag/http-in-depth-dfdac806c2c0?source=rss-2ff04be71f9------2</link>
            <guid isPermaLink="false">https://medium.com/p/dfdac806c2c0</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[http-request]]></category>
            <category><![CDATA[tcp]]></category>
            <category><![CDATA[http2]]></category>
            <category><![CDATA[networking]]></category>
            <dc:creator><![CDATA[Ahmad Farag]]></dc:creator>
            <pubDate>Sat, 31 Mar 2018 09:27:42 GMT</pubDate>
            <atom:updated>2018-07-23T16:55:25.076Z</atom:updated>
            <content:encoded><![CDATA[<h4>HTTP</h4><blockquote>The Hypertext Transfer <strong>Protocol</strong> (HTTP) is an application protocol for distributed, collaborative, and hypermedia information systems. HTTP is the foundation of data communication for the World Wide Web.</blockquote><h4>Protocol</h4><blockquote>a protocol is the special set of rules that end points in a telecommunication connection use when they communicate. Protocols specify interactions between the communicating entities.</blockquote><blockquote>Protocols usually consist of three main parts<strong>:-</strong></blockquote><blockquote>1- <strong>Header</strong>: contains information such as source, destination, fileType and size.</blockquote><blockquote>2- <strong>Payload</strong>: the actual information transmitted using the protocol .</blockquote><blockquote>3- <strong>Footer:</strong> a control field to ensure the Payload data is transmitted free of errors.</blockquote><h3>History of HTTP</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fFgr7pu2_c4jbKqULD2ahw.png" /></figure><h4>HTTP 0.9</h4><p>From 1989, Tim Berners-Lee and his team at CERN , the European Nuclear Research Center in Switzerland, developed the Hypertext Transfer Protocol, together with the concepts of URL and HTML , which created the foundations of the World Wide Web. First results of this effort in 1991 were the version HTTP 0.9.</p><ul><li><strong>Methods supported</strong>: GET only</li><li><strong>Response type</strong>: hypertext only</li><li><strong>Connection nature</strong>: terminated immediately after the response</li><li><strong>Headers</strong>: No HTTP headers (cannot transfer other content type files), No status/error codes, No URLs, No versioning</li><li><strong>Support</strong>: HTTP/0.9 requests have been removed.</li><li><strong>keep-alive</strong>: N/A</li></ul><pre><strong>Request</strong></pre><pre>GET /</pre><pre><strong>Response</strong></pre><pre>&lt;!DOCTYPE HTML PUBLIC &quot;-//IETF//DTD HTML 2.0//EN&quot;&gt;<br>&lt;html&gt;&lt;head&gt;<br>&lt;title&gt;301 Moved Permanently&lt;/title&gt;<br>&lt;/head&gt;&lt;body&gt;<br>&lt;h1&gt;Moved Permanently&lt;/h1&gt;<br>&lt;p&gt;The document has moved &lt;a href=&quot;http://any23.apache.org&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;<br>&lt;/body&gt;&lt;/html&gt;</pre><h4>HTTP 1.0</h4><p>In 1996, <a href="https://tools.ietf.org/html/rfc1945">RFC 1945</a> became known as HTTP / 1.0. With HTTP / 1.0, a new TCP connection is established before each request and, after the response has been transmitted.</p><ul><li><strong>Methods supported</strong>: GET , HEAD , POST</li><li><strong>Response type</strong>: not limited to hypertext (Content-Type header provided ability to transmit files other than plain HTML files — e.g. scripts, stylesheets, media)</li><li><strong>Connection nature</strong>: terminated immediately after the response</li><li><strong>Headers</strong>: does not officially required</li><li><strong>Support</strong>: used by proxies, wget and some IE browsers.</li><li><strong>keep-alive</strong>: not considered persistent <strong>unless</strong> a keep-alive header is included.</li><li><strong>status code</strong>: only define up to 16 status codes.</li></ul><pre><strong>Request</strong></pre><pre>GET / HTTP/1.0</pre><pre><strong>Response</strong></pre><pre>HTTP/1.1 301 Moved Permanently<br>Date: Fri, 02 Jan 2015 05:40:17 GMT<br>Server: Apache/2.4.7 (Ubuntu)<br>Location: <a href="http://any23.apache.org/">http://any23.apache.org</a><br>Content-Length: 231<br>Connection: close<br>Content-Type: text/html; charset=iso-8859-1</pre><pre>&lt;!DOCTYPE HTML PUBLIC &quot;-//IETF//DTD HTML 2.0//EN&quot;&gt;<br>&lt;html&gt;&lt;head&gt;<br>&lt;title&gt;301 Moved Permanently&lt;/title&gt;<br>&lt;/head&gt;&lt;body&gt;<br>&lt;h1&gt;Moved Permanently&lt;/h1&gt;<br>&lt;p&gt;The document has moved &lt;a href=&quot;http://any23.apache.org&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;<br>&lt;/body&gt;&lt;/html&gt;</pre><p>so we can see HTTP 0.9 <strong>doesn’t support headers</strong> and HTTP 1.0 supports headers (not officially required).</p><h4>HTTP Headers</h4><blockquote>HTTP headers allow the client and the server to pass additional information with the request or the response.<br>Headers can be grouped according to their contexts or according to how proxies handle them, <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers">read more</a></blockquote><h4>Major Problem in both HTTP/0.9 and HTTP/1.0</h4><blockquote>both are required to <strong>open new TCP connection</strong> per outstanding Request and it closes it immediately after the response was sent.</blockquote><blockquote>to open TCP connection <strong>a three-way handshake</strong> should occur which takes time.</blockquote><h4>TCP 3-Way Handshake (SYN,SYN-ACK,ACK)</h4><blockquote>A three-way handshake is primarily used to create a TCP socket connection. It works when:<br>1- A client node sends a SYN data packet over an IP network to a server on the same or an external network. The objective of this packet is to ask/infer if the server is open for new connections.<br>2- The target server must have open ports that can accept and initiate new connections. When the server receives the SYN packet from the client node, it responds and returns a confirmation receipt — the ACK packet or SYN/ACK packet.<br>3- The client node receives the SYN/ACK from the server and responds with an ACK packet.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/418/1*qAXAGT--mkGrQwIm0It53w.png" /></figure><blockquote>Upon completion of this process, the connection is created and the host and server can communicate.</blockquote><h4>HTTP 1.1</h4><p>In 1999, <a href="https://tools.ietf.org/html/rfc2616">RFC 2616</a> , reflects the HTTP / 1.1 standards, With HTTP / 1.1 a client can use an additional header entry ( keep-alive ) to express a desire not to disconnect in order to be able to use the connection again (<strong>persistent connection</strong>).</p><ul><li><strong>Methods supported</strong>: GET , HEAD , POST , PUT , DELETE , TRACE , OPTIONS</li><li><strong>Connection nature</strong>: long-lived</li><li><strong>Support</strong>: common use until today.</li><li><strong>keep-alive</strong>: considered persistent unless declared otherwise.</li><li><strong>status code</strong>: came with 24 status codes.</li></ul><h4>The Key Features Of HTTP/1.1</h4><p><strong>1- HTTP pipelining: </strong>is a technique in which multiple HTTP requests are sent on a single TCP connection without waiting for the corresponding responses.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pXwAd8F8tdcEc3qpACfAxA.png" /></figure><blockquote>HTTP pipelining is not enabled by default in modern browsers due to proxy servers, Head-of-line blocking (HOL) .</blockquote><p><strong>2- HTTP persistent connection (HTTP keep-alive) :</strong></p><p>is the idea of using a single TCP connection to send and receive multiple HTTP requests/responses, as opposed to opening a new connection for every single request/response pair.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/704/1*3Ii5LgnuGZpHQNomb9gyqw.png" /></figure><p><strong>3- Compression/Decompression (Content Encoding) : </strong>a capability that can be built into <strong>web servers</strong> and <strong>web clients</strong> to improve transfer speed and bandwidth utilization, The most common compression schemes include gzip and Deflate.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/506/1*IiZWZLtJncNXxVBkeOWLhA.png" /></figure><p><strong>How does it work?</strong></p><ul><li>The web client advertises which compression schemes it supports by including a list of tokens in the HTTP request.</li></ul><pre>GET <strong>/encrypted-area</strong> <strong>HTTP</strong>/1.1<br>Host: <a href="http://www.example.com/">www.example.com</a><br><strong>Accept-Encoding: gzip, deflate</strong></pre><ul><li>If the server supports compression scheme the server will add a <em>Content-Encoding</em> or <em>Transfer-Encoding</em> field in the HTTP response</li></ul><pre><strong>HTTP</strong>/1.1 200 <strong>OK</strong><br>Date: mon, 26 June 2016 22:38:34 GMT<br>Server: Apache/1.3.3.7 (Unix)  (Red-Hat/Linux)<br>Last-Modified: Wed, 08 Jan 2003 23:11:55 GMT<br>Accept-Ranges: bytes<br>Content-Length: 438<br>Connection: close<br>Content-Type: text/html; charset=UTF-8<br><strong>Content-Encoding: gzip</strong></pre><p><strong>4- New Status Code: </strong>a new header code <strong>100 — Continue</strong>, this helps client to know if a large request will be processed by server and if server responds with status code 100, client sends the actual body request to the server for further processing. Apart from this, there are <strong>409-Conflict</strong> and <strong>410-Gone </strong>status code also added.</p><p><strong>5- Content Negotiation: </strong>serve different versions of a document (or more generally, representations of a resource) at the same URI, so that user agents can specify which version fits their capabilities the best. One classical use of this mechanism is to serve an image in GIF or PNG format so that a browser that cannot display PNG images (e.g. MS Internet Explorer 4) will be served the GIF version.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/767/1*yw4LSx3nYzfs4OLE6wuoKw.png" /></figure><p><strong>6-Warning Header: </strong>used to carry additional information about the status or transformation of a message which might not be reflected in the message. This information is typically used to warn about a possible lack of semantic transparency from caching operations or transformations applied to the entity body of the message.</p><h4>The Performance Issues Of HTTP/1.1</h4><p><strong>1-Head-of-line blocking(HOL blocking)</strong></p><p>It as in networking is a performance issue that occurs when a bunch of packets is blocked by the first (a large or slow ) packet in line . It can happen especially in input buffered network switches where out-of-order delivery of packets can occur (arrive out of order). A switch can be composed of buffered input ports, a switch fabric and buffered output ports. If first-in-first-out (FIFO) input buffers are used, only the oldest packet is available for forwarding.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/423/1*WH-nDZC3FrStO4PYbtdIjQ.png" /></figure><p><strong>2-The repetition of information sent for each request</strong></p><p>Each of the requests repeats a lot of the same information. Each includes the same user-agent information and accepted content information, etc.</p><p><strong>3-The additional round trips(3-Way Handshake) needed.</strong></p><h4>SPDY</h4><p>SPDY is a protocol developed by Google to increase the speed and efficiency of delivering web content. SPDY modifies parts of the HyperText Transfer Protocol (HTTP) to improve web performance.</p><h4>HTTP Problems that SPDY Solves</h4><ul><li><strong>Single request per connection:</strong> HTTP can only fetch one resource at a time, leading to delays and underutilized bandwidth. SPDY allows for many concurrent downloads.</li><li><strong>Client-initiated requests:</strong> HTTP requires the user to request content from a server before it can be delivered. With SPDY, the server can “push” data to the client without having to wait for a request, making it possible to load web content before it’s needed.</li><li><strong>Redundant Headers:</strong> HTTP headers define the behaviour of an HTTP transaction. In some cases, the same headers are repeated over the course of a session. SPDY removes unnecessary headers to reduce the amount of bandwidth required.</li><li><strong>Uncompressed Data:</strong> Compression, which shrinks the size of data during delivery, is optional for HTTP. SPDY forces compression for all communications including headers.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/1*wy3ZCm-UbS06PHfWlgJQOQ.png" /></figure><h4>BENEFITS OF SPDY</h4><ul><li><strong>Users see faster load times and lower bandwidth usage:</strong> Bandwidth is utilized more intelligently, allowing users to stretch data caps while experiencing improved performance.</li><li><strong>Enterprises see higher customer satisfaction:</strong> Web pages load faster, resulting in a better user experience.</li><li><strong>Enterprises also see lower bandwidth costs: </strong>SPDY optimizes traffic before it leaves the server, allowing enterprises to utilize more of their network without having to upgrade their hardware.</li></ul><blockquote>HTTP/2 replaces SPDY<br> Chrome drops support in 2016</blockquote><h4>HTTP/2 — A protocol for greater performance</h4><p>HTTP/2 was based largely on Google’s own protocol <strong>SPDY</strong> which had many of the same features found in HTTP/2 and managed to improve data transmission while keeping backwards compatibility. SPDY had already proven many of the concepts used in HTTP/2.</p><h4>The key Features of HTTP/2</h4><p><strong>1- Binary, instead of textual</strong></p><p>Binary protocols are more efficient to parse, more compact “on the wire”, and most importantly, they are much less error-prone, compared to textual protocols like HTTP/1.x, because they often have a number of affordances to “help” with things like whitespace handling, capitalization, line endings, blank lines and so on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*QLOrOjXhMzUe34mTs9vM_g.png" /></figure><p><strong>2- Streams</strong></p><p>an independent, bi-directional sequence of frames exchanged between the client and server within an HTTP/2 connection. Streams have several important characteristics:</p><p>A single HTTP/2 connection can contain multiple concurrently open streams, with either endpoint interleaving frames from multiple streams.<br>Streams can be established and used unilaterally or shared by either the client or server.<br>Streams can be closed by either endpoint.<br>The order in which frames are sent on a stream is significant. Recipients process frames in the order they are received. In particular, the order of HEADERS and DATA frames is semantically significant.<br>Streams are identified by an integer. Stream identifiers are assigned to streams by the endpoint initiating the stream.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kgeYfUIEpjgk5u9kjPmKjA.png" /></figure><p><strong>3- Request and Response Multiplexing</strong></p><p>is a method in HTTP/2 by which multiple HTTP requests can be sent and responses can be received asynchronously via <strong>a single TCP connection</strong>. Multiplexing is the heart of HTTP/2 protocol.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*WiG5i0H1gC1VvdseQHzoaw.png" /></figure><p><strong>With HTTP/1.x</strong>, if the client wants to make multiple parallel requests to improve performance, then multiple TCP connections must be used; see Using Multiple TCP Connections. This behaviour is a direct consequence of the HTTP/1.x delivery model, which ensures that only one response can be delivered at a time (response queuing) per connection. Worse, this also results in <strong>head-of-line blocking</strong> and inefficient use of the underlying TCP connection.</p><p>The new binary framing layer in HTTP/2 removes these limitations, and enables full request and response multiplexing, <strong>by allowing the client and server to break down an HTTP message into independent frames</strong>, interleave them, and then reassemble them on the other end.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*LgZPolncwEcdbs6nj-Ykzw.png" /></figure><p><strong>4- Server Push</strong></p><p>is the ability of the server to send multiple responses for a single client request. That is, in addition to the response to the original request, the server can <em>push</em> additional resources to the client, without the client having to request each one explicitly!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*xeYjTHj0OCK9f72Q005R5g.png" /></figure><p><strong>5- HPACK- Data compression of HTTP headers</strong></p><p>HTTP/2 introduces a form of header compression called HPACK. HPACK allows for very efficient header compression, without being vulnerable to compression related attacks such as CRIME. HPACK provides the following:</p><ul><li>The ability to encode large headers using a fixed Huffman encoding</li><li>The ability to encode commonly used headers as a variable length integer, rather than re-sending the whole header each time.</li></ul><h3>HTTP/1.1 Upgrade Header</h3><p>The HTTP Upgrade mechanism is used to establish HTTP/2 starting from plain HTTP. The client starts a HTTP/1.1 connection and sends “Upgrade: h2c” header. If the server supports HTTP/2, it replies with HTTP 101 Switching Protocol status code.</p><p>The HTTP Upgrade mechanism is used only for cleartext HTTP2 (<strong>h2c</strong>). In the case of HTTP2 over TLS (<strong>h2</strong>), the <a href="https://en.wikipedia.org/wiki/Application-Layer_Protocol_Negotiation"><strong>ALPN</strong></a> TLS protocol extension is used instead.</p><p><strong>Example:</strong></p><blockquote>curl -vs -o /dev/null — http2 nghttp2.org</blockquote><pre>* Rebuilt URL to: nghttp2.org/<br>* Trying 139.162.123.134…<br>* TCP_NODELAY set<br>* Connected to nghttp2.org (139.162.123.134) port 80 (#0)<br>&gt; GET / HTTP/1.1<br>&gt; Host: nghttp2.org<br>&gt; User-Agent: curl/7.54.0<br>&gt; Accept: */*<br>&gt; Connection: Upgrade, HTTP2-Settings<br><strong>&gt; Upgrade: h2c <br></strong>&gt; HTTP2-Settings: AAMAAABkAARAAAAAAAIAAAAA<br>&gt;<br><strong>&lt; HTTP/1.1 101 Switching Protocols<br></strong>&lt; Connection: Upgrade<br>&lt; Upgrade: h2c<br><strong>* Received 101<br></strong>* Using HTTP2, server supports multi-use<br>* Connection state changed (HTTP/2 confirmed)<br>* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=33<br>* Connection state changed (MAX_CONCURRENT_STREAMS updated)!<br>&lt; HTTP/2 200<br>&lt; date: Fri, 30 Mar 2018 18:33:00 GMT<br>&lt; content-type: text/html<br>&lt; last-modified: Tue, 27 Feb 2018 13:31:12 GMT<br>&lt; etag: “5a955da0–19d8”<br>&lt; accept-ranges: bytes<br>&lt; content-length: 6616<br>&lt; x-backend-header-rtt: 0.001283<br>&lt; server: nghttpx<br>&lt; via: 2 nghttpx<br>&lt; x-frame-options: SAMEORIGIN<br>&lt; x-xss-protection: 1; mode=block<br>&lt; x-content-type-options: nosniff<br>&lt;<br>{ [1232 bytes data]<br>* Connection #0 to host nghttp2.org left intact</pre><p><strong>References</strong> :</p><ul><li><a href="https://tools.ietf.org/html/rfc7230">https://tools.ietf.org/html/rfc7230</a></li><li><a href="https://kinsta.com/learn/what-is-http2/">https://kinsta.com/learn/what-is-http2/</a></li><li><a href="http://www.kafsemo.org/2015/01/03_talking-HTTP-0.9%2C1.0%2C1.1.html">http://www.kafsemo.org/2015/01/03_talking-HTTP-0.9%2C1.0%2C1.1.html</a></li><li><a href="https://medium.com/platform-engineer/evolution-of-http-69cfe6531ba0">https://medium.com/platform-engineer/evolution-of-http-69cfe6531ba0</a></li><li><a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Evolution_of_HTTP">https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Evolution_of_HTTP</a></li><li><a href="http://searchnetworking.techtarget.com/definition/protocol">http://searchnetworking.techtarget.com/definition/protocol</a></li><li><a href="https://en.wikipedia.org/wiki/HTTP_persistent_connection">https://en.wikipedia.org/wiki/HTTP_persistent_connection</a></li><li><a href="https://en.wikipedia.org/wiki/HTTP_pipelining">https://en.wikipedia.org/wiki/HTTP_pipelining</a></li><li><a href="http://www.dotnetfunda.com/forums/show/20691/advantage-of-http11-over-http10-version">http://www.dotnetfunda.com/forums/show/20691/advantage-of-http11-over-http10-version</a></li><li><a href="https://en.wikipedia.org/wiki/HTTP_compression">https://en.wikipedia.org/wiki/HTTP_compression</a></li><li><a href="https://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html">https://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html</a></li><li><a href="https://www.techopedia.com/definition/10339/three-way-handshake">https://www.techopedia.com/definition/10339/three-way-handshake</a></li><li><a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers">https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers</a></li><li><a href="https://tools.ietf.org/html/draft-mbelshe-httpbis-spdy-00">https://tools.ietf.org/html/draft-mbelshe-httpbis-spdy-00</a></li><li><a href="https://www.maxcdn.com/one/visual-glossary/spdy/">https://www.maxcdn.com/one/visual-glossary/spdy/</a></li><li><a href="http://qnimate.com/what-is-multiplexing-in-http2">http://qnimate.com/what-is-multiplexing-in-http2</a></li><li><a href="https://http2.github.io/">https://http2.github.io</a></li><li><a href="http://undertow.io/blog/2015/04/27/An-in-depth-overview-of-HTTP2.html">http://undertow.io/blog/2015/04/27/An-in-depth-overview-of-HTTP2.html</a></li></ul><h4>More where this came from</h4><p>This story is published in <a href="http://blog.usejournal.com/">Noteworthy</a>, where thousands come every day to learn about the people &amp; ideas shaping the products we love.</p><p>Follow our publication to see more product &amp; design stories featured by the <a href="https://usejournal.com/?utm_source=usejournal.com&amp;utm_medium=blog&amp;utm_campaign=guest_post">Journal</a> team.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dfdac806c2c0" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>