<?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 Shawn Brito on Medium]]></title>
        <description><![CDATA[Stories by Shawn Brito on Medium]]></description>
        <link>https://medium.com/@shawnbrito?source=rss-7a6ded983bb9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*4fiAik_YIkX1LnOJWuTwQA.png</url>
            <title>Stories by Shawn Brito on Medium</title>
            <link>https://medium.com/@shawnbrito?source=rss-7a6ded983bb9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 05:29:12 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shawnbrito/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[Number Systems in ICT: The Foundation Every Computing Student Must Master]]></title>
            <link>https://medium.com/@shawnbrito/number-systems-in-ict-the-foundation-every-computing-student-must-master-ef2153600d98?source=rss-7a6ded983bb9------2</link>
            <guid isPermaLink="false">https://medium.com/p/ef2153600d98</guid>
            <dc:creator><![CDATA[Shawn Brito]]></dc:creator>
            <pubDate>Thu, 30 Jul 2026 19:38:25 GMT</pubDate>
            <atom:updated>2026-07-31T20:18:29.167Z</atom:updated>
            <content:encoded><![CDATA[<p><em>“Every app you use, every website you visit, and every game you play is built upon one simple concept — numbers represented in different forms.”</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lYhrBmHlWI76qSQyMrTg6g.jpeg" /><figcaption>Number Systems</figcaption></figure><p>When students first hear about <strong>Binary, Octal, and Hexadecimal</strong>, they often wonder why computers need so many different number systems when we already have decimal. The answer is simple: <strong>computers think differently than humans.</strong></p><p>Understanding number systems is one of the most important skills for ICT students because it forms the basis of programming, computer architecture, networking, cybersecurity, digital electronics, and data representation.</p><p>Let’s explore these fascinating number systems.</p><h3>Why Do Computers Use Different Number Systems?</h3><p>Humans naturally count using <strong>Decimal (Base 10)</strong> because we have ten fingers.</p><p>Computers, however, use electronic switches that have only two possible states:</p><ul><li>ON</li><li>OFF</li></ul><p>These two states are represented as:</p><ul><li>1</li><li>0</li></ul><p>This creates the <strong>Binary Number System (Base 2).</strong></p><p>Because binary numbers become very long, programmers often use <strong>Octal (Base 8)</strong> and <strong>Hexadecimal (Base 16)</strong> as shorter, more readable versions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/365/1*yBmqKdph54Uw-hrBCq5tAQ.jpeg" /></figure><h3>The Four Common Number Systems</h3><pre>Number System      Base           Digits Used<br>Decimal             10             0–9<br>Binary              2              0,1O<br>ctal                8              0–7<br>Hexadecimal         16             0–9, A, B, C, D, E, F</pre><p>In hexadecimal:</p><ul><li>A = 10</li><li>B = 11</li><li>C = 12</li><li>D = 13</li><li>E = 14</li><li>F = 15</li></ul><h3>Understanding Positional Value</h3><p>Each digit has a value depending on its position.</p><p>Example:</p><p><strong>Decimal 482</strong></p><pre>4 × 10² = 400<br>8 × 10¹ = 80<br>2 × 10⁰ = 2</pre><pre>Total = 482</pre><p>Binary works exactly the same way but uses powers of 2.</p><p>Example:</p><pre>101101₂</pre><pre>1×2⁵ = 32<br>0×2⁴ = 0<br>1×2³ = 8<br>1×2² = 4<br>0×2¹ = 0<br>1×2⁰ = 1</pre><pre>Total = 45₁₀</pre><h3>Decimal to Binary Conversion</h3><p>Repeatedly divide by 2.</p><p><strong>Example</strong>: Convert <strong>25₁₀</strong></p><pre>25 ÷2 =12   remainder   1<br>12 ÷2 =6    remainder   0<br>6 ÷2 =3     remainder   0<br>3 ÷2 =1     remainder   1<br>1 ÷2 =0     remainder   1</pre><p>Read from bottom upwards:</p><pre>11001₂</pre><p>Therefore,</p><p><strong>25₁₀ = 11001₂</strong></p><h3>Binary to Decimal Conversion</h3><p>Example:</p><pre>110101₂</pre><pre>1×32 =32<br>1×16 =16<br>0×8 =0<br>1×4 =4<br>0×2 =0<br>1×1 =1</pre><pre>Total =53</pre><p>Therefore,</p><pre>110101₂ =53₁₀</pre><h3>Decimal to Octal Conversion</h3><p>Divide repeatedly by 8.</p><p>Example: Convert <strong>156₁₀</strong></p><pre>156 ÷8 =19 remainder 4<br>19 ÷8 =2 remainder 3<br>2 ÷8 =0 remainder 2</pre><p>Reading upwards:</p><pre>234₈</pre><h3>Octal to Decimal</h3><p>Example:</p><pre>725₈</pre><pre>7×8² =448<br>2×8¹ =16<br>5×8⁰ =5</pre><pre>Total =469</pre><h3>Decimal to Hexadecimal</h3><p>Divide repeatedly by 16.</p><p>Example:</p><p>Convert <strong>254₁₀</strong></p><pre>254 ÷16 =15 remainder 14<br> 15 ÷16 = 0 remainder 15</pre><p>Remainders:</p><pre>15 = F<br>14 = E</pre><p>Answer:</p><pre>FE₁₆</pre><h3>Hexadecimal to Decimal</h3><p>Example:</p><pre>3A₁₆</pre><pre>3×16 =48<br>A =10</pre><pre>48+10=58</pre><p>Therefore,</p><pre>3A₁₆ =58₁₀</pre><h3>Binary ↔ Octal Conversion</h3><p>Every <strong>3 binary bits</strong> represent <strong>1 octal digit</strong>. Example:</p><pre>101110011₂</pre><p>Group into threes:</p><pre>101 110 011</pre><p>Convert each group:</p><pre>101 =5<br>110 =6<br>011 =3</pre><p>Result:</p><pre>563₈</pre><h3>Binary ↔ Hexadecimal Conversion</h3><p>Every <strong>4 binary bits</strong> represent <strong>1 hexadecimal digit.</strong></p><p>Example:</p><pre>101111001010₂</pre><p>Group:</p><pre>1011 1100 1010</pre><p>Convert:</p><pre>1011 =B<br>1100 =C<br>1010 =A</pre><p>Result:</p><pre>BCA₁₆</pre><h3>Binary Addition</h3><p>Binary addition follows four simple rules.</p><pre>0 +0 =0</pre><pre>0 +1 =1</pre><pre>1 +0 =1</pre><pre>1 +1 =10</pre><p>Notice that <strong>1 + 1 produces 10</strong>, meaning:</p><ul><li>Write 0</li><li>Carry 1</li></ul><p>Example:</p><pre>   1011<br> + 0110<br> -------<br>  10001</pre><h3>Binary Addition with Carry</h3><p>Example:</p><pre>   110101<br> + 101111<br> --------<br>  1100100</pre><p>Always begin from the rightmost bit and carry whenever the total equals 2 or 3.</p><h3>Octal Addition</h3><p>Example:</p><pre> 527₈<br>+346₈<br>-----</pre><p>Work from right to left.</p><pre>7+6 =15₁₀</pre><pre>15₁₀ =17₈</pre><pre>Write 7<br>Carry 1</pre><p>Continue similarly until all digits are added.</p><h3>Hexadecimal Addition</h3><p>Remember:</p><pre>A=10<br>B=11<br>C=12<br>D=13<br>E=14<br>F=15</pre><p>Example:</p><pre> 2A₁₆<br>+3F₁₆</pre><pre>A +F</pre><pre>10+15=25</pre><pre>25₁₀ =19₁₆</pre><pre>Write 9<br>Carry 1</pre><p>Continue with the remaining digits.</p><h3>Real-World Applications</h3><p>Number systems are used everywhere in computing.</p><h3>Programming</h3><p>Programmers frequently use hexadecimal values to represent memory locations and colors.</p><p>Example:</p><pre>#FF0000</pre><p>represents the color <strong>Red</strong>.</p><h3>Networking</h3><p>IP addresses, subnet masks, and packet structures rely heavily on binary arithmetic.</p><h3>Digital Electronics</h3><p>Logic gates and processors operate entirely using binary values.</p><h3>Cybersecurity</h3><p>Memory addresses, machine instructions, encryption algorithms, and malware analysis all involve hexadecimal numbers.</p><h3>Operating Systems</h3><p>File permissions, memory management, and low-level debugging frequently use binary and hexadecimal notation.</p><h3>Tips for Students</h3><p>✔ Memorize powers of 2.</p><p>✔ Learn hexadecimal values from A to F.</p><p>✔ Practice grouping binary digits into groups of 3 and 4.</p><p>✔ Always check carries during binary addition.</p><p>✔ Solve conversion exercises daily — the process quickly becomes intuitive with repetition.</p><h3>Practice Questions</h3><ol><li>Convert <strong>97₁₀</strong> to binary.</li><li>Convert <strong>11010110₂</strong> to decimal.</li><li>Convert <strong>751₈</strong> to decimal.</li><li>Convert <strong>3F₁₆</strong> to decimal.</li><li>Convert <strong>110110011₂</strong> to octal.</li><li>Convert <strong>111011101₂</strong> to hexadecimal.</li><li>Add <strong>101101₂ + 111010₂</strong>.</li><li>Add <strong>756₈ + 145₈</strong>.</li><li>Add <strong>2B₁₆ + 4D₁₆</strong>.</li><li>Explain why hexadecimal is preferred over binary when displaying memory addresses.</li></ol><h3>Final Thoughts</h3><p>Number systems may seem intimidating at first, but they are simply different ways of representing the same values. Once you understand the logic behind bases, positional values, conversions, and arithmetic, you’ll discover that they become one of the most rewarding topics in ICT.</p><p>Whether you’re preparing for examinations or dreaming of a career in software engineering, networking, cybersecurity, or data science, mastering number systems gives you a strong foundation for everything that follows.</p><p>Remember: <strong>Computers don’t understand words — they understand numbers. And those numbers begin with binary.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ef2153600d98" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Logic Gates (in circuits)]]></title>
            <link>https://medium.com/@shawnbrito/logic-gates-in-circuits-77d66a7cb8a1?source=rss-7a6ded983bb9------2</link>
            <guid isPermaLink="false">https://medium.com/p/77d66a7cb8a1</guid>
            <dc:creator><![CDATA[Shawn Brito]]></dc:creator>
            <pubDate>Sun, 21 Jun 2026 18:23:33 GMT</pubDate>
            <atom:updated>2026-06-21T18:23:33.344Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>What are Logic Gates in a circuit?</strong></p><p>Logic gates are the fundamental building blocks of digital electronics and computer processors. They act as little electronic switches that take one or more binary inputs (<em>1s and 0s represented by voltage</em>) and produce a single binary output based on a specific set of rules.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JgjdwdRPeX10j2m_agALQw.jpeg" /><figcaption>Basic &amp; Combined Logic Gates</figcaption></figure><h3>Logic Gate Symbols</h3><p>The primary logical operations used in digital electronics include:</p><ul><li><strong>AND </strong>Gate: The output is 1 only if <em>all</em> inputs are 1. Otherwise, the output is 0.</li><li><strong>OR </strong>Gate: The output is 1 if <em>at least one</em> input is 1. The output is 0 only if all inputs are 0.</li><li><strong>NOT </strong>Gate (Inverter): Takes a single input and reverses it. A 0 becomes a 1, and a 1 becomes a 0.</li><li><strong>NAND </strong>&amp; <strong>NOR </strong>Gates: These are “NOT-AND” and “NOT-OR” gates, which act as inverted versions of the basic AND and OR gates.</li><li><strong>XOR </strong>(Exclusive <strong>OR</strong>) Gate: The output is 1 only if the inputs are different from each other.</li></ul><h3>Logic Gates in Integrated Circuits (IC)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/457/1*Hyu1YUKCuST1r9LBmAYLjA.jpeg" /><figcaption>Integrated Circuit (IC) used in Classic Radios, TVs, Washing Machines,</figcaption></figure><p>Logic gates are the fundamental building blocks of all digital electronic circuits. They are implemented using tiny electronic components such as transistors within Integrated Circuit (IC) chips. Each logic gate performs a specific logical operation on one or more binary inputs to produce a binary output. Common logic gates include AND, OR, NOT, NAND, NOR, XOR, and XNOR gates. Modern microprocessors, memory chips, and digital devices contain millions or even billions of these gates integrated onto a single silicon chip. Logic gates operate using binary values represented by voltage levels, where 0 typically represents LOW and 1 represents HIGH.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/558/1*Rh6n3Q0pWlhIUNw5h5bFew.jpeg" /><figcaption>Logic Gates with AND &amp; OR gates</figcaption></figure><p>By combining multiple logic gates, designers can create complex digital circuits such as adders, multiplexers, registers, and processors. The NAND and NOR gates are known as universal gates because any logical function can be constructed using only one of these gate types. The development of Very Large Scale Integration (VLSI) technology has enabled the placement of enormous numbers of logic gates on a single chip. Understanding how logic gates are implemented in ICs is essential for studying computer architecture, digital electronics, and embedded systems. Today, logic gate technology forms the foundation of computers, smartphones, communication systems, and virtually every modern digital device.</p><h3>5 Real-World Use Cases of Simple Logic Gates</h3><p><strong>AND Gate — ATM Card Access</strong></p><ul><li>A customer can withdraw money only if the <strong>correct ATM card</strong> is inserted <strong>AND</strong> the <strong>correct PIN</strong> is entered.</li><li>Both conditions must be true for access to be granted.</li></ul><p><strong>OR Gate — Home Security Alarm</strong></p><ul><li>The alarm activates if the <strong>front door sensor</strong> detects intrusion <strong>OR</strong> the <strong>back door sensor</strong> detects intrusion.</li><li>Either sensor can trigger the alarm.</li></ul><p><strong>NOT Gate — Low Fuel Warning</strong></p><ul><li>A vehicle’s warning light turns ON when the fuel tank is <strong>NOT full</strong>.</li><li>The NOT gate inverts the fuel sensor’s signal.</li></ul><p><strong>AND Gate — Laboratory Safety System</strong></p><ul><li>A machine starts only when the <strong>safety guard is closed</strong> <strong>AND</strong> the <strong>start button is pressed</strong>.</li><li>This prevents accidental operation.</li></ul><p><strong>OR Gate — Emergency Exit System</strong></p><ul><li>An emergency door unlocks when either the <strong>fire alarm is activated</strong> <strong>OR</strong> the <strong>emergency release switch is pressed</strong>.</li><li>Any one condition is sufficient to unlock the door.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=77d66a7cb8a1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Terraform+Ansible, Get Dynamic Inventory of EC2]]></title>
            <link>https://faun.pub/terraform-ansible-get-dynamic-inventory-of-ec2-10f2868aae76?source=rss-7a6ded983bb9------2</link>
            <guid isPermaLink="false">https://medium.com/p/10f2868aae76</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[ansible]]></category>
            <dc:creator><![CDATA[Shawn Brito]]></dc:creator>
            <pubDate>Sat, 08 Jan 2022 11:09:26 GMT</pubDate>
            <atom:updated>2022-02-12T04:42:03.521Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YTPcya98LPg97Sq03--G-Q.png" /></figure><h4><strong>In this article I will show you how to setup dynamic ansible inventory in order to execute some ansible-playbook on NEW EC2 instances we just provisioned using Terraform. This is the most complete instruction set (with best practice) you will ever find on the internet.</strong></h4><p><strong>Some prerequisites:</strong></p><ol><li>A working ansible environment (<a href="https://www.youtube.com/watch?v=EcnqJbxBcM0">https://www.youtube.com/watch?v=EcnqJbxBcM0</a>)</li><li>Knowledge in terraform from Hashicorp (<a href="https://www.youtube.com/watch?v=SLB_c_ayRMo&amp;t=1s">https://www.youtube.com/watch?v=SLB_c_ayRMo&amp;t=1s</a>)</li><li>Knowledge in AWS/EC2 (Setup/Delete EC2, Access Keys, .pem files)</li><li>Have your AWS API key &amp; secret key ready (<a href="https://www.youtube.com/watch?v=HCl2_FzMxAg">https://www.youtube.com/watch?v=HCl2_FzMxAg</a>)</li></ol><h4>Challenges faced by developers</h4><p>Most developers were faced with the challenge of installing software on remote servers using the most optimized solutions. In order to accomplish this, they sometimes use various legacy tools such as creating automated bash scripts, or python scripts in order to execute the remote configurations. However over the year, automation tools such as <strong>Ansible</strong>, Chef &amp;Puppet has helped many developers to automate this task. The next challenge was provisioning servers, which was previously done manually. However with recent software advancements, using tools such as <strong>Terraform, Ansible </strong>or Cloud-formation, this too was now fully automated.</p><p>Provisioning a EC2 instance was easy, Installing software was easy, but what about orchestration (<em>The science of linking them without knowing any of their newly provisioned IP addresses</em>)</p><p>We had to marry these two technologies (<em>which was built by many independent companies</em>) in order to produce a fully working cloud environment without any manual software installations or IP configurations. This is where <strong>dynamic inventory</strong> comes into play.</p><p>First we need to provision the AWS cloud servers, then get their dynamic inventory using <strong>boto3 </strong><em>(which is an object-oriented API built with Python). In this article, I assume you know nothing about dynamic inventory, but have some understanding of Ansible &amp; Aws.</em></p><h4>Lets first install the boto3</h4><pre>$&gt; sudo yum install python3<br>$&gt; sudo yum install python2   //in case it needs python2<br>$&gt; sudo pip3 install boto3<br>$&gt; sudo pip2 install boto3    //in case it needs old pip2</pre><h3>Step 1 — Provision 2x EC2 instances using Terraform</h3><p>Lets first configure our AWS local credentials in order to provision EC2 instances with <strong>Terraform</strong>. <br><strong><em>Note:</em></strong><em> Creating the aws_secret keys in aws is beyond the scope of this article.</em> However I have provided a link to a youtube video above (Point #4). You will need the following permission attached to the aws-access-key in order for the boto3 to make a successful connection with aws web-servers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*QSVtROm4y9yKpi9Rm8Ex6g.png" /></figure><p>Lets first setup the .aws folder, credentials, config and give it the necessary permissions. Replace the <strong>aws_access_key_id</strong> &amp; <strong>aws_secret_access_key </strong>with your own keys.</p><pre>$&gt; mkdir ~/.aws<br>$&gt; vi ~/.aws/credentials</pre><pre>[default]<br>aws_access_key_id = Uh67Hxb52DxQ1UcID5K23<br>aws_secret_access_key = 8t4K4DaCVxhGR9E32WeBG9Rtya+gdbVcs267esSv</pre><p>Save the above ‘credentials’ file and create another file ‘config’ in the same .aws folder. Change the keys according to your preferred aws region.</p><pre>$&gt; vi ~/.aws/config</pre><pre>[default]<br>region = us-east-2<br>output = json</pre><p>Save the file, and give both files with 600 permission.</p><pre>$&gt; sudo chmod 600 -Rf ~/.aws/*</pre><p>Once this has been setup, you need to download the <strong>ec2.py</strong> &amp; <strong>ec2.ini </strong>files from the github. These two files are responsible for getting the dynamic inventory from the AWS web-services.</p><pre><a href="https://github.com/vshn/ansible-dynamic-inventory-ec2">https://github.com/vshn/ansible-dynamic-inventory-ec2</a></pre><p>Lets create a <strong>~/InfraCode/inventory</strong> folder in the home folder and place the <strong>ec2.py</strong> &amp; <strong>ec2.ini</strong> in it. Give the <strong>ec2.py</strong> &amp; <strong>ec2.ini</strong> execution permission (775) as ansible need to interpret this as dynamic inventory.</p><p>Check your <strong>ec2.py</strong> by simply typing ~/InfraCode/inventory/ec2.py --list</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/424/1*81OZjGCCLT5mMuHgDUrWDA.png" /><figcaption>Json output file from the ec2.py</figcaption></figure><p>You should get a <strong>json { … } </strong>string<strong> </strong>showing you the servers you currently have. This is your dynamic inventory file. It contains the names &amp; categories of the servers. Note the names of the groups as we will be using them in out ansible scripts (these are tag names assigned in ec2 console)</p><h3>Create the Terraform files</h3><p>In this section, we’re going to create the two terraform files. Although we can create everything in a single file, its a good practice to isolate vpc, network setting to a separate file. Lets first start by creating the <strong>vpc, subnet </strong>&amp; <strong>network interfaces</strong> for our ec2 instances.</p><p>Create a file called <strong>ec2-vpc.tf</strong> in the ~/InfaCode/ folder to hold the networking configurations before we actually create the ec2 servers. This is a good practice as we will then know precisely where to put the ec2 instances in and the network they are assigned to. Note the links between the following 3 components. The network_interface is linked to the aws_subnet, the aws_subnet is linked to the aws_vpc. And then eventually the ec2 instances get linked to the network_interface.</p><pre>#### Create The VPC, Subnet &amp; Network Interfaces ###<br>resource &quot;aws_vpc&quot; &quot;dev&quot; {<br>   cidr_block = &quot;10.0.0.0/16&quot;<br>   instance_tenancy = &quot;default&quot;<br>   provider = aws.useast2<br>   tags = {<br>     Name = &quot;dev-vpc&quot;<br>   }<br>}</pre><pre>resource &quot;aws_subnet&quot; &quot;sub&quot; {<br>   vpc_id = aws_vpc.dev.id<br>   cidr_block = &quot;10.0.1.0/24&quot;<br>   provider = aws.useast2<br>   tags = {<br>     Name = &quot;dev-subnet&quot;<br>   }<br>}</pre><pre>resource &quot;aws_network_interface&quot; &quot;mw_network&quot; {<br>   subnet_id = aws_subnet.sub.id<br>   provider = aws.useast2<br>   private_ips = [&quot;10.0.1.45&quot;]<br>   tags = {<br>     Name = &quot;network_interface&quot;<br>   }<br>}</pre><p>Save the above file and create the <strong>ec2.tf</strong> in the same folder. We’re now going to add the two ec2 servers we discussed previously with 15Gb disk space. Lets name them “kreybooks”, “kreymysql”. We’re also going to assign the network_interface.</p><pre>#### Create the AWS EC2 instance with 10 disk space ####<br>resource &quot;aws_instance&quot; &quot;mw_php1&quot; {<br>   ami = &quot;ami-0fb653ca2d3203ac1&quot;<br>   instance_type = &quot;t2.micro&quot;<br>   provider = aws.useast2</pre><pre>   root_block_device {<br>     volume_size = 15<br>     volume_type = &quot;standard&quot;<br>   }<br>   tags = {<br>     Name = &quot;<strong>kreybooks</strong>&quot;<br>     Environment = &quot;Dev&quot;<br>   }<br>   network_interface {<br>     network_interface_id = aws_network_interface.mw_network.id<br>     device_index = 0<br>   }<br>}</pre><pre>resource &quot;aws_instance&quot; &quot;mw_php2&quot; {<br>   ami = &quot;ami-0fb653ca2d3203ac1&quot;<br>   instance_type = &quot;t2.micro&quot;<br>   provider = aws.useast2</pre><pre>   root_block_device {<br>     volume_size = 15<br>     volume_type = &quot;standard&quot;<br>   }<br>   tags = {<br>     Name = &quot;<strong>kreymysql</strong>&quot;<br>     Environment = &quot;Dev&quot;<br>   }<br>   network_interface {<br>     network_interface_id = aws_network_interface.mw_network.id<br>     device_index = 0<br>   }<br>}</pre><p>Save and run the terraform plan in that same folder. If all goes well, you should get a json output.</p><h4>Tag Names are the key for dynamic inventory</h4><p>Remember the <strong>tags = { Name …}</strong> in the terraform file. These tags are vital for dynamic inventory. They will eventually become the host inventory name of the ec2 instance we use. If you have three types of ec2 instances (Ex. Web servers, Rest servers, Backoffice servers), you will name each server with a unique tag respectively. Now lets get back to the terraform plan.</p><pre>$InfraCode&gt; terraform plan</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/677/1*yuvw78c1yWsk-VPyXbvmgA.png" /></figure><p>The terraform plan will only suggest the possible changes, but does not create/modify data. You should see 5 items that need to be added/modified. <strong>VPC , Subnet , Network-Interface , +2x EC2 instances</strong>. To make the actual changes, do the following</p><pre><strong>$InfraCode&gt; terraform apply</strong></pre><p>Once we do an <strong>apply</strong>, we need to get the IPs that are now associated with the new EC2 instances. The traditional legacy way of doing this is to get the IPs manually from the aws-console and add them into the ansible static inventory file one by one. However this article is all about <strong>dynamic inventory</strong>.</p><h3>Create the ansible playbook</h3><p>In this section, we are going to use the above mentioned <strong>ec2.py</strong> in order to get the inventory for our ansible-playbooks. Lets create the ansible playbook called <strong>playbook-sample.yml</strong></p><pre>---<br> - name: &quot;Install Tools using AWS Inventory&quot;<br>   <strong>hosts: &quot;tag_Name_kreybooks&quot;</strong><br>   gather_facts: yes<br>   become: yes</pre><pre>   vars_files:<br>     - &quot;vars/all.yml&quot;</pre><pre>   tasks:<br>     - name: &quot;Install http software&quot;<br>       yum:<br>         name: httpd&gt;=2.4<br>         state: present</pre><p>The following <strong>vars/all.yml</strong> file contains the credentials to connect to the newly created <strong>EC2</strong> servers. When creating EC2 instances manually (from the aws console), you will be prompted to use an existing key. You should already have this by now.</p><pre>---<br>ansible_ssh_user: centos<br>ansible_ssh_private_key_file: ~/.ssh/aws_ec2.pem</pre><p>Notice the <strong>hosts: “tag_Name_kreybooks”</strong>, which is specified in the playbook. This is the server host name of the inventory. Based on our terraform file, we have given “<strong>kreybooks</strong>” as the tag name. The <strong>ec2.py</strong> adds a tag name “<strong>tag_Name_kreybooks</strong>” as the server name. Other names that can be used are, <strong>hosts: </strong>“<strong>type_t2_micro</strong>” which will return two host names. You can assign the same tag name to several servers (<em>which will return a group of servers with that tag name</em>)</p><h4>Tag Names are your friends</h4><pre>$InfraCode&gt; ansible-inventory -i inventory/ec2.py --graph </pre><p>You will see an output with all the tags displayed as @host names. We can use any of these names as host name to setup your software using ansible playbooks. You see names like ‘<strong>type_t2_micro</strong>’ , ‘<strong>type_t2_medium</strong>’, ‘<strong>tag_Name_kreybooks</strong>’ which are either group names or host names.</p><h3>Run the playbook</h3><p>Finally lets run the playbook using the <strong>ec2.py</strong> inventory file as the source for our dynamic inventory. Just a few minutes ago we created two EC2 instances from terraform, and we yet don’t know their IPs. But that’s the whole idea of dynamic inventory in Ansible. We don’t need to know the IPs; all we need to know is the <strong>tag </strong>Names of the two instances we created. Lets run the playbook using the following command.</p><pre>$InfraCode&gt; ansible-playbook -i inventory/ec2.py   playbook-sample.yml</pre><h3>Conclusion</h3><p>Now that you have provisioned your EC2 instances, and installed some software using ansible without knowing their IPs, what shall we plan next? Using Ansible, we have the power of automating any form of cloud infrastructure, even using Jenkins which is very popular at provisioning cloud infrastructure through thousands of plugins. You will have the potential of installing and pre-connecting a HaProxy/NginX load-balancer to a group of web-servers. Suppose we have 5 cloud instances which originally were not provisioned from terraform; Using <strong>terraform import</strong>, we can import legacy server by server into terraform state files and construct a fully automated environment.</p><h4><strong>External References</strong></h4><p>You are also welcome to read the difference between Ansible &amp; Terraform and their strengths &amp; weaknesses by “<a href="https://spacelift.io/blog/author/sumeetn">Sumeet Ninawe</a>”.</p><p><a href="https://spacelift.io/blog/ansible-vs-terraform">https://spacelift.io/blog/ansible-vs-terraform</a></p><h4>Thank you</h4><p>Thank you for reading this article, I would truly appreciate getting in touch with me if you like to know more about dynamic inventory and linking various stacks through Jenkins pipelines. <a href="https://www.linkedin.com/in/shawn-brito-06a51544/">Linkedin</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/436/1*YOSQw_5ZPddW3GG5yfGjLQ.png" /></figure><figure><a href="https://faun.to/bP1m5"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BCiLLad3dvZLwBa-B5cAVQ.png" /></a></figure><p>Join FAUN: <a href="https://faun.to/i9Pt9"><strong>Website</strong></a><strong> </strong>💻<strong>|</strong><a href="https://faun.dev/podcast"><strong>Podcast</strong></a><strong> </strong>🎙️<strong>|</strong><a href="https://twitter.com/joinfaun"><strong>Twitter</strong></a><strong> </strong>🐦<strong>|</strong><a href="https://www.facebook.com/faun.dev/"><strong>Facebook</strong></a><strong> </strong>👥<strong>|</strong><a href="https://instagram.com/fauncommunity/"><strong>Instagram</strong></a><strong> </strong>📷|<a href="https://www.facebook.com/groups/364904580892967/"><strong>Facebook Group</strong></a><strong> </strong>🗣️<strong>|</strong><a href="https://www.linkedin.com/company/faundev"><strong>Linkedin Group</strong></a><strong> </strong>💬<strong>|</strong> <a href="https://faun.dev/chat"><strong>Slack</strong></a> 📱<strong>|</strong><a href="https://thechief.io/"><strong>Cloud Native</strong> <strong>News</strong></a><strong> </strong>📰<strong>|</strong><a href="https://linktr.ee/faun.dev/"><strong>More</strong></a><strong>.</strong></p><p><strong>If this post was helpful, please click the clap 👏 button below a few times to show your support for the author 👇</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=10f2868aae76" width="1" height="1" alt=""><hr><p><a href="https://faun.pub/terraform-ansible-get-dynamic-inventory-of-ec2-10f2868aae76">Terraform+Ansible, Get Dynamic Inventory of EC2</a> was originally published in <a href="https://faun.pub/">FAUN.dev() 🐾</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I Reduced Cloud Costs by 50%]]></title>
            <link>https://medium.com/@shawnbrito/how-i-reduced-cloud-costs-by-50-97512cb1285b?source=rss-7a6ded983bb9------2</link>
            <guid isPermaLink="false">https://medium.com/p/97512cb1285b</guid>
            <category><![CDATA[cost-optimization]]></category>
            <category><![CDATA[server-cost]]></category>
            <category><![CDATA[cloud-server]]></category>
            <category><![CDATA[cloud-cost-optimization]]></category>
            <category><![CDATA[downgrade-servers]]></category>
            <dc:creator><![CDATA[Shawn Brito]]></dc:creator>
            <pubDate>Tue, 07 Sep 2021 20:46:53 GMT</pubDate>
            <atom:updated>2021-09-24T05:29:20.388Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/866/1*8cahCrxVASRXOtgrdRkc_g.png" /><figcaption>Cost Breakdown Of Servers</figcaption></figure><p>I recently had the opportunity to look at a small group of servers that had recently been configured by the admin team in order to determine the cost of the servers and especially reducing the cost of their cloud. As this was a completely new client, I was interested to know how their system had evolved over the years. The overall cost of the cloud servers had exceeded $2000/month which is not much by most standards. However this too was beyond their initial expectation.</p><p>We first took a look into the PostgreSQL server cost as that had the highest cost with 6x AWS.<em>c5.large</em> servers taking just under $600.</p><p>5x of these serves were part of the replicated load-balanced cluster, while one was a master DB. But the other servers were part of various systems.</p><ol><li>Reporting &amp; Accounting with Tomcat running the web-app</li><li>One DB was used for QA purposes</li><li>2xDB were used for Dev replicated load-balancing</li><li>1xDB for Dev master DB activity</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/955/1*WYRK-MDGhEEmaVARlA8siw.jpeg" /></figure><h3>Take Inventory</h3><p>We took an inventory of these servers and then moved onto the next group of Application servers. As these servers were built off a <strong>c5.large</strong> template, many of the instances were also built from either the <strong>c5.large</strong> or <strong>t3.large</strong> templates regardless of usage. The team had initially configured one specific server with all applications &amp; libraries in order to make future deployments much easier. This was about 6 years back, but this does not need to be so using DevOps automation tools today. After taking stock of the servers, we ran a cost analysis to understand the breakdown of each cloud instance (<em>including disk-space &amp; traffic cost</em>).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fSFTa-WUKuhRxmHDonvyrw.jpeg" /></figure><h3>Cost Reduction</h3><p>The challenge was to identify the possibility of reducing the cost while yet maintaining dozen+ cloud instances (end points). Using the Nagios monitoring &amp; Grafana, we implemented a few dashboards in order to identify the level of memory &amp; cpu usage. We came up with 3 strategies to reduce the current cost &amp; future cost.</p><ol><li>If the server usage was under load-avg 1.0 &amp; memory usage was under 30%, reduce the size of the cloud instance.</li><li>Implement Reserved instances to lower the cost by 40%. The best candidates for the reserved instances were the servers that were moderately used, and would not change over time.</li><li>Future implementations — start off by creating lower cloud instances , which can be later be upgraded and downgraded at will (<em>in order to reduce future costs</em>).</li></ol><p>Looking closely at our inventory, our gitlab experts decided to reduce the memory footprint by following this document. The existing instance was <strong><em>t3.large</em></strong> which is the default recommended specs for the gitlab community edition. After some tweaking and a few days of R&amp;D, the reduction was sufficient enough to warrant a <strong><em>t3.medium</em></strong> instance.</p><p><a href="https://gitlab.com/groups/gitlab-org/-/epics/448">https://gitlab.com/groups/gitlab-org/-/epics/448</a></p><p>The databases were not that easy to reduce as they appeared to be running at load-avg 4.x during peak hours. The only possible option was to create 5 reserved aws-instances(<em>one year commitment</em>), which cut down the cost by 40% on those 5x cloud servers. The same was done to the 4x web-servers as the business was stable enough through Covid lock-downs. Management was hesitant at first, but looking at the annual reports of the business, they decided to go with 1 year reserved plan. Reserved plans lock you into 1,2 or 3 year contracts but provide more than 40% in monthly cost reductions. The best option was to go with 5x reserved instances. Since reserved instances work like silhouettes, they need to match the running instances in order for the 40% reduction to apply.</p><h3>The ELK</h3><p>We’re now into the 2nd week of optimization. Looking at the CPU usage on the elasticsearch, Grafana/dashboards showed a significant under-usage than what we expected. As the server instances were built directly on <strong><em>t3.large</em></strong>, it could not be reduced to <strong><em>t3.mediums</em></strong>. Therefore a plan was drawn to recreate four <strong>t3.medium</strong> cloud servers and scp the elastic data, logstash &amp; kibana. The backup procedure was strait forward requiring only a zip-backup and restore onto the new <strong><em>t3.medium</em></strong> during non-working hours. As these server were somewhat permanent, 4x reserved instances were created which dropped our cost by 45% compared to the previous <strong><em>t3.large</em></strong>. Although the migration was smooth, it consumed an entire week as it couldn’t be done during working hours.</p><h3>Nexus/Jenkins</h3><p>We’re now into the 3rd week of our optimizations. A few more servers along with Nexus &amp; Jenkins. Unfortunately, downgrading the server was not possible as it was already created as <em>t3.large</em>. Therefore I followed this simple aws strategy to downgrade any server (<em>take note of the AMI ID as it reduces the risk of failure</em>). <a href="https://www.youtube.com/watch?v=W89C_OqlOwE">https://www.youtube.com/watch?v=W89C_OqlOwE</a></p><ol><li>I took a snapshot of the volumes from the current instance.</li><li>Then create a new <em>t3.medium</em> type instance</li><li>Use the snapshot(s) to create a replica of your existing volumes.</li><li>Attach the new volume(s) created to small instance.</li><li>Test &amp; Switch over once satisfied</li></ol><h3>Summery</h3><p>Looking at the effort and the time spent over 3 weeks, we may wonder if it was worth the cost &amp; effort of reducing the monthly aws bills by just $1000. Perhaps looking at it from a annual report, $12,000 certainly looks more significant. All this was possible using the combination of Nagios+Grafana dashboards <em>(Actual graphs cannot be shared due to privacy laws)</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/704/1*199frzyOomZ3r9Tb7j2gpg.png" /><figcaption>Grafana dashboard from my development environment</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=97512cb1285b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to visualize any data]]></title>
            <link>https://medium.com/@shawnbrito/how-to-visualize-any-data-a392b981380?source=rss-7a6ded983bb9------2</link>
            <guid isPermaLink="false">https://medium.com/p/a392b981380</guid>
            <category><![CDATA[kibana]]></category>
            <category><![CDATA[elasticsearch]]></category>
            <category><![CDATA[logstash]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[visualization]]></category>
            <dc:creator><![CDATA[Shawn Brito]]></dc:creator>
            <pubDate>Fri, 31 Jul 2020 19:04:07 GMT</pubDate>
            <atom:updated>2020-07-31T19:04:07.435Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/626/1*TaO6CuOKOOjeyRfQVNdlGw.jpeg" /></figure><p>15 years of volunteering for community projects was quite a thrill ride. From frequent visitations to once a year, we had much fun that will never be forgotten. I worked with some of the best guys &amp; gals over the years enabling people to get up on their feet. This year I thought of visualizing what we did over the years in Kibana. First setup the ELK Stack with Filebeats, LogStash, ElasticSearch &amp; Kibana. This is the most easiest part as there are dozens of well documented blogs for ELK setup.</p><ol><li><a href="https://logz.io/learn/complete-guide-elk-stack/#intro">https://logz.io/learn/complete-guide-elk-stack/#intro</a></li><li><a href="https://medium.com/@automationlaboratories/how-to-install-elk-stack-elasticsearch-logstash-and-kibana-on-rhel-7-c8f644ee129e">https://medium.com/@automationlaboratories/how-to-install-elk-stack-elasticsearch-logstash-and-kibana-on-rhel-7-c8f644ee129e</a></li><li><a href="https://www.digitalocean.com/community/tutorials/how-to-install-elasticsearch-logstash-and-kibana-elk-stack-on-centos-7">https://www.digitalocean.com/community/tutorials/how-to-install-elasticsearch-logstash-and-kibana-elk-stack-on-centos-7</a></li><li><a href="https://www.itzgeek.com/how-tos/linux/centos-how-tos/updated-install-elasticsearch-logstash-and-kibana-elk-stack-on-centos-7-rhel-7.html">https://www.itzgeek.com/how-tos/linux/centos-how-tos/updated-install-elasticsearch-logstash-and-kibana-elk-stack-on-centos-7-rhel-7.html</a></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/699/1*ql52f_af-cX0bYWmpL5YUA.png" /><figcaption>ELK Stack Message Flow</figcaption></figure><p>Once you have the ELK Stack operating with the basic index showing the counts, we can start working on the csv filters. The following is the <strong>volunteer.csv</strong> file that I used to create the visualizations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/1*LIz8MZApDRhAlmbDKVYLng.png" /><figcaption>My volunteering CSV data</figcaption></figure><h3>ELK 6.8.3</h3><p>I have chosen to use <strong>ELK 6.8.3</strong> at the time of this writing. There is a updated <strong>ELK 7.5</strong> available for download.</p><p>Lets start by creating the csv file readers. In the <strong>filebeat.yml</strong>, add the “volunteer” to the tags: and fields/env: variables.</p><pre>type: log<br>  enabled: true<br>  paths:<br>    - D:/Data/ELK/volunteer/*.csv<br><br>tags: [&quot;volunteer&quot;]<br><br># Optional fields that you can specify to add additional information to the<br># output.<br><br>fields:<br>  <br>  env: volunteer</pre><p>Now create the ingestion filter in the logstash/config/ by creating a pipeline configuration file. Your pipeline will also need a grok pattern file, which I have downloaded into the /config/patterns/ directory. Source: <a href="https://github.com/elastic/logstash/blob/v1.4.2/patterns/grok-patterns">https://github.com/elastic/logstash/blob/v1.4.2/patterns/grok-patterns</a></p><pre>input {<br>  beats{<br>     port =&gt; 5044<br>     tags =&gt; [&quot;metricbeat&quot;]<br>  }<br>}<br><br>filter {<br>  if (&quot;volunteer&quot; in [tags])<br>  {<br>    grok{<br>      patterns_dir =&gt; [&quot;D:/Data/ELK/logstash-6.8.3/config/patterns&quot;]<br>      match =&gt; {&quot;message&quot; =&gt; &quot;%{INT:id};%{DATA:name};%{INT:visits};%{DATE:date};%{DATA:description};%{DATA:city};%{DATA:lat};%{DATA:lon};%{INT:distance};%{INT:attendees};%{INT:contribution}&quot;}<br>      overwrite =&gt; [&quot;Message&quot;]<br>    }<br>    date {<br>      match =&gt; [ &quot;date&quot;, &quot;dd/MM/YYYY&quot; ]<br>      target =&gt; &quot;timestamp&quot;<br>    }<br>    mutate{<br>      rename =&gt; {<br>         &quot;lon&quot; =&gt; &quot;[location][lon]&quot;<br>         &quot;lat&quot; =&gt; &quot;[location][lat]&quot;<br>      }<br>      <br>      convert =&gt; {<br>        &quot;[location][lat]&quot; =&gt; &quot;float&quot;<br>        &quot;[location][lon]&quot; =&gt; &quot;float&quot;<br>        &quot;attendees&quot; =&gt; &quot;integer&quot;<br>        &quot;id&quot; =&gt; &quot;integer&quot;<br>        &quot;contribution&quot; =&gt; &quot;integer&quot;<br>        &quot;distance&quot; =&gt; &quot;integer&quot;<br>      }<br>    }<br> <br>  }<br>}<br><br>output{<br>    if(&quot;volunteer&quot; in [tags])<br>    {<br>        elasticsearch {<br>          hosts =&gt; [&quot;localhost:9200&quot;]<br>          index =&gt; &quot;%{[fields][env]}&quot;<br>        }<br>    }<br>}</pre><p>I create a template in ElasticSearch to match the index patterns “*” and convert geo coordinates to elasticsearch type <strong>geo_point</strong>. LogStash doesn’t have geo-data types, which is why elasticsearch templates comes into action.</p><pre>PUT _template/logs<br>{<br>  &quot;order&quot;: 0,<br>  &quot;index_patterns&quot;: [<br>    &quot;*&quot;<br>  ],<br>  &quot;settings&quot;: {<br>    &quot;index&quot;: {<br>      &quot;number_of_shards&quot;: &quot;2&quot;,<br>      &quot;number_of_replicas&quot;: &quot;0&quot;<br>    }<br>  },<br>  &quot;mappings&quot;: {<br>    &quot;_default_&quot;: {<br>      &quot;properties&quot;: {<br>        &quot;country&quot;: {<br>          &quot;type&quot;: &quot;keyword&quot;<br>        },<br>        &quot;geoloc&quot;: {<br>          &quot;type&quot;: &quot;geo_point&quot;<br>        },<br>        &quot;location&quot;: {<br>          &quot;type&quot;: &quot;geo_point&quot;<br>        }<br>      }<br>    }<br>  },<br>  &quot;aliases&quot;: {}<br>}</pre><h3>Kibana Visualization — The Map</h3><p>I created a kibana visual map using <strong>Visualize </strong>-&gt; <strong>Coordinate Map</strong> and set the metrics as “count”. In the <strong>Buckets </strong>section, I added the <strong>geohash </strong>aggregation, and select the <strong>location </strong>field as the aggregation. The <strong>location </strong>field details that were entered into the csv file will be converted to float and then converted to <strong>geo_point</strong> by elasticsearch when it encounters the field <strong>location</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/1*L7Wo0osNeUxNPj5InrpfJQ.png" /><figcaption>Hot spots indicating volunteer activity</figcaption></figure><p>Once I created all the relevant visualizations, I aggregated them all into a single dashboard to visualize my travels over the years. I can easy see that I had reduced my community travels over the years. Thankfully there was a new generation of community warriors that took over the work and continued where we left off.</p><p>Based on these stats, we have traveled over 9000km (2 x 4,500 return) around the country to 17 locations. We have helped over 1584 community members and raised over Rs1.3 million for the projects.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*5GnJZ-yFUsy6ujrA9Vjjlg.png" /><figcaption>Kibana Dashboard with volunteering data analysis</figcaption></figure><p>I could have added more stats, such as costs of visitations, popular items, partners, families, children which would have given better perspectives in making better decisions for future visits. Kibana makes that difference between data and visualizing. To me its a critical decision making tool. Its better than Power BI as the clients can own their data without saving it to SaaS providers. Since its web-hosted service, anyone with an internet connection can get access to critical data.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a392b981380" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Multiple PHP’s with 1 XAMPP Server]]></title>
            <link>https://medium.com/@shawnbrito/multiple-phps-with-1-xampp-server-997c4b69603d?source=rss-7a6ded983bb9------2</link>
            <guid isPermaLink="false">https://medium.com/p/997c4b69603d</guid>
            <category><![CDATA[apache]]></category>
            <category><![CDATA[xampp]]></category>
            <category><![CDATA[php5]]></category>
            <category><![CDATA[load-balancing]]></category>
            <category><![CDATA[php7]]></category>
            <dc:creator><![CDATA[Shawn Brito]]></dc:creator>
            <pubDate>Wed, 22 Jan 2020 12:44:47 GMT</pubDate>
            <atom:updated>2020-01-22T12:44:47.965Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/852/1*ZL2klfbN3sSErOFACq902w.png" /></figure><p>I recently had a situation where my client was challenged with running multiple web apps that required multiple versions of PHP. My first recommendation was to have 2x cloud servers, each running its own Xampp/PHP version (5.6 &amp; 7.3), however that significantly increased his cost by few hundred $ /per/year.</p><p>My second option was untested by me, but was implemented by others and did not seem to complicated. It was based on using cgi-script execution on a single XAMPP server on a windows machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*jCmQEHNPGlIDJUTVugO32Q.png" /></figure><p>As the XAMPP version the client was running <em>php7.3</em> by default, the objective was to add <em>php5.6</em> along with the <em>php7.3</em> without breaking any existing logic. First I downloaded the php5.6 (<em>php-5.6.39-Win32-VC11-x64.zip</em>) from the archives <a href="https://windows.php.net/downloads/releases/archives/">https://windows.php.net/downloads/releases/archives/</a></p><pre>ScriptAlias /php56 &quot;C:/Data/xampp/php56&quot;<br>Action application/x-httpd-php56 &quot;/php56/php-cgi.exe&quot; virtual<br>&lt;Directory &quot;C:/Data/xampp/php56&quot;&gt;<br>    UnsetEnv PHPRC<br>    UnsetEnv PHP_PEAR_SYSCONF_DIR<br>    AllowOverride None<br>    Options +ExecCGI<br>    Require all denied<br>    &lt;Files &quot;php-cgi.exe&quot;&gt;<br>        Require all granted<br>    &lt;/Files&gt;<br>&lt;/Directory&gt;</pre><p>After extracting it into “<em>C:\data\xampp\php56</em>”, I added the above code to the very bottom of the <em>httpd-xampp.conf</em>. The clients xampp was installed in <em>C:\data</em>.</p><p>The objective was to create a difference between the default php7.3 &amp; custom php5.6 environment in Apache. In order to achieve that I used a Directory directive as follows. Remember to UnsetEnv the <em>PHPRC</em> and <em>PHP_PEAR_SYSCONF_DIR</em> variables.</p><pre>&lt;Directory &quot;C:/Data/xampp/htdocs/akaunting3&quot;&gt;<br>    UnsetEnv PHPRC<br>    UnsetEnv PHP_PEAR_SYSCONF_DIR<br>    &lt;FilesMatch &quot;\.php$&quot;&gt;<br>        SetHandler application/x-httpd-php56<br>    &lt;/FilesMatch&gt;<br>&lt;/Directory&gt;<br><br>&lt;Directory &quot;C:/Data/xampp/htdocs/sweetcrm2&quot;&gt;<br>    UnsetEnv PHPRC<br>    UnsetEnv PHP_PEAR_SYSCONF_DIR<br>    &lt;FilesMatch &quot;\.php$&quot;&gt;<br>        SetHandler application/x-httpd-php56<br>    &lt;/FilesMatch&gt;<br>&lt;/Directory&gt;</pre><p>You can check if all went well by creating a <em>phpinfo.php</em> file in each directory.</p><p>C:\Data\xampp\htdocs\akaunting3\phpinfo.php C:\Data\xampp\htdocs\sweetcrm2\phpinfo.php</p><h3>Testing the custom php5.6 virtual sites</h3><p><a href="http://localhost/akaunting/phpinfo.php">http://localhost/akaunting/phpinfo.php</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/477/1*3Jzs0ijCCZU8jX8nL5GlXA.jpeg" /></figure><p>When the <em>/akaunting</em> virtual folder is accessed, apache executes the <em>/php56/php-cgi.exe</em> against the phpinfo.php file instead of the default php7.3. No changes were made to the existing default configurations in php7.3</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/477/1*MHovI4mMS6-Zs-q-PK9oEQ.jpeg" /></figure><h3>Testing the default php7.3 virtual site</h3><p><a href="http://localhost/spiral/phpinfo.php">http://localhost/spiral/phpinfo.php</a></p><p>The <em>/spiral</em> application on the other hand did not belong to the special <em>php5.6</em> configuration and therefore executed the <em>php7.3</em> cgi-scripts by default. Using this same principle, we can implement as many versions of php as we need. If you have done this in CentOS or Ubuntu, let me know your experience.</p><h3>NGinX</h3><p>And finalize everything, I added a front end NGinX to load-balance the 2x back-end Xampp web-servers on port 8080. The complete project took less than 3days and saved the customer hundreds of dollars.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=997c4b69603d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[An ELK Stack Under $50 ?]]></title>
            <link>https://medium.com/@shawnbrito/an-elk-stack-under-50-988ec5484f55?source=rss-7a6ded983bb9------2</link>
            <guid isPermaLink="false">https://medium.com/p/988ec5484f55</guid>
            <category><![CDATA[elasticsearch]]></category>
            <category><![CDATA[elk]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[business-intelligence]]></category>
            <category><![CDATA[elk-stack]]></category>
            <dc:creator><![CDATA[Shawn Brito]]></dc:creator>
            <pubDate>Thu, 12 Dec 2019 08:47:45 GMT</pubDate>
            <atom:updated>2019-12-12T08:47:45.275Z</atom:updated>
            <content:encoded><![CDATA[<h3>An ELK Stack Under $50 ?</h3><p>I have been building ELK stacks for almost 4 years and have come to the conclusion that cloud based ELK stacks for complex BI can be built within $50/month budget. Any lower than this could compromise the stability of the stack. With the below mentioned AWS reserved instances, we can reduce the cost to under $30/month.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/514/1*C5e_6OCyCGEclYItRg9VpQ.png" /><figcaption>Minimum ElasticStack (Under $50/month)</figcaption></figure><p>I started out by creating a simple ELK Stack on 2x cloud servers and installing the ELK stack first. I encourage you to use the following sequence when installing &amp; configuring the ELK.</p><ol><li>ElasticSearch 6.8 or 7.x (Or any other version)</li><li>Cerebro for ElasticSearch (Install this to manage the index)</li><li>Kibana (The main visualizer)</li><li>Excelastic (To import xsl or csv files into ElasticSearch)</li><li>Curator (Automate index management by creating rules)</li><li>Beats (Transfer log files from source to LogStash -over TCP)</li><li>APM (Application Performance Monitoring)</li></ol><p>There are many many documents out there with installation instructions for the ELK stack [ https://community.spiceworks.com/how_to/164166-installing-elk-7-elasticsearch-logstash-and-kibana-windows-server-2016-part-1].</p><h3>ELK Stack For $150</h3><p>A moderate size ELK stack would cost between $100 to $200 based on the capacity requirements and message frequency. If there is heavy transformation going on in LogStash, implement 2x LogStash instances. I have selected a basic $150 Master-Slave architecture with ElasticSearch query processor. This is a special ElasticSearch node with <strong>Data=False</strong> &amp; <strong>Master=False</strong> configuration. Such nodes would automatically participate in processing log files. By implementing a reserved instance architecture, we can drop this cost by 50%</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/491/1*VUc7QTVSHw38-O7Sc8-LDA.png" /><figcaption>A Standard ElasticSearch Stack (With Master/Slave ES)</figcaption></figure><h3>ELK Stack for above $250</h3><p>ELK Stack configurations can range from as low as $30 in the cloud to thousands of dollars based on the requirements. Such distributions can occupy dozens of servers, if not hundreds in larger analytical organizations. In the following architecture I have highlighted a larger elastic stack comprising of multiple levels of redundancy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*RV-cKBILoCutqqQrnCle_g.png" /><figcaption>Higher Availability ELK Stack</figcaption></figure><p>This AWS cloud configuration might cost about $330, however when the AWS reserved instance rates are applied, they sharply drop to $175. Once we have the stack established, we can start creating dashboards to our hearts content. The following shows the distribution of children in schools and distribution within a geographical bounds.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/654/1*_NgCf6M1PEc9Yl8q0nx0sw.png" /></figure><h3>What Are Reserved Instances?</h3><p>These instances cannot be dropped easily without incurring a penalty. Reserved instances are contract based instances for 1year or 3years. Reserved instances are the cheapest among the server industry, however you need to abide by the 1year contract agreement.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=988ec5484f55" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>