<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Vineet K</title>
    <description>The latest articles on DEV Community by Vineet K (@vineetk13).</description>
    <link>https://dev.to/vineetk13</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F567453%2Fdd0bb2fd-24b1-453f-be4e-ee916067fe82.jpg</url>
      <title>DEV Community: Vineet K</title>
      <link>https://dev.to/vineetk13</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/vineetk13"/>
    <language>en</language>
    <item>
      <title>So what is Amazon EC2 then..?</title>
      <dc:creator>Vineet K</dc:creator>
      <pubDate>Mon, 27 Dec 2021 15:53:21 +0000</pubDate>
      <link>https://dev.to/vineetk13/so-what-is-amazon-ec2-then-3m4f</link>
      <guid>https://dev.to/vineetk13/so-what-is-amazon-ec2-then-3m4f</guid>
      <description>&lt;h3&gt;
  
  
  AMIs and Instances
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Amazon Machine Image (AMI) is a template that consists of software configurations. Think of it like a blueprint for your instances.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Instance is a copy of AMI that runs as a virtual server on the cloud. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Launch instance of any type from an AMI.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The root device for your instance contains an image that is used to boot the instance. This root device is either an Amazon Elastic Block Store (Amazon EBS) volume or an instance store volume.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Types of EC2 instances
&lt;/h3&gt;

&lt;h4&gt;
  
  
  ✔️ General purpose instances:
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;They provide a balance of compute, memory and networking resources.&lt;/li&gt;
&lt;li&gt;It’s use case scenarios include:

&lt;ul&gt;
&lt;li&gt;Application servers&lt;/li&gt;
&lt;li&gt;Backend servers for enterprise applications&lt;/li&gt;
&lt;li&gt;Gaming servers&lt;/li&gt;
&lt;li&gt;Small and medium databases&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  🎛 Compute optimized instances:
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;These types of instances are ideal for compute intensive tasks like -

&lt;ul&gt;
&lt;li&gt;Dedicated gaming servers&lt;/li&gt;
&lt;li&gt;High performance web &amp;amp; application servers&lt;/li&gt;
&lt;li&gt;Scientific modelling&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;These are also ideally used for batch processing workloads which requires processing many transactions in a single group.&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  ⏱ Memory optimized instances:
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;These serve workloads that process large datasets in the memory.

&lt;ul&gt;
&lt;li&gt;Memory is basically a temporary space that holds all the data and instructions required by the CPU to process. &lt;/li&gt;
&lt;li&gt;So before a program or software on any machine is able to run, all the necessary and required data/instructions are preloaded into the memory from the storage and is directly accessible to the CPU for processing. &lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Say your requirement is to have a large unstructured data to be pre-loaded (so that your application gets performant by faster data processing) before running any application, then Memory optimized EC2 instances should be your ideal choice.&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  💾 Storage optimized instances:
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;These are specifically designed for workloads that consist of high, sequential read and write access to large datasets on local storage.&lt;/li&gt;
&lt;li&gt;It’s use case scenarios include:

&lt;ul&gt;
&lt;li&gt;Distributed file systems&lt;/li&gt;
&lt;li&gt;Data warehousing applications&lt;/li&gt;
&lt;li&gt;High-frequency online transaction processing (OLTP) systems.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;In the computer world, we use the term Input Output Operations per Second(IOPS) as a metric to measure the performance of a storage device. &lt;/li&gt;
&lt;li&gt;Say you want to host an application that involves data entered into the database(input) and then analyse this data as output, you need a machine with high IOPS requirement that can in-turn provide faster low-latency results.&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  🚝 Accelerated computing instances:
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;These instances use hardware accelerators or co-processors to perform intensive tasks more efficiently than running them on traditional CPUs. &lt;/li&gt;
&lt;li&gt;Its use case scenarios include:

&lt;ul&gt;
&lt;li&gt;Floating point number calculations&lt;/li&gt;
&lt;li&gt;Graphics processing&lt;/li&gt;
&lt;li&gt;Data pattern matching&lt;/li&gt;
&lt;li&gt;Game and video streaming&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;In the computer world, a hardware accelerator is a component that can speed up data processing.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now let's talk about money too 😏&lt;/p&gt;

&lt;h3&gt;
  
  
  Amazon EC2 pricing models
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;With Amazon EC2, you pay only for the compute time that you use. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The pricing options are as follows:&lt;/p&gt;

&lt;h4&gt;
  
  
  On-demand
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Ideal for irregular workloads that cannot be interrupted and for applications with unpredictable usage patterns.&lt;/li&gt;
&lt;li&gt;No upfront costs or minimum contracts apply.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Savings plan
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;It enables us to reduce compute costs by committing to a consistent amount of compute usage for a 1-year or 3-year term.&lt;/li&gt;
&lt;li&gt;Any usage up to the commitment is charged at the discounted plan rate (for example, $10 an hour). Any usage beyond the commitment is charged at regular On-Demand rates.&lt;/li&gt;
&lt;li&gt;It can give savings of up to 66% over On-Demand costs.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Reserved instances
&lt;/h4&gt;

&lt;p&gt;🚧 Work in progress...&lt;/p&gt;

&lt;h4&gt;
  
  
  Spot instances
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Ideal for workloads with flexible start and end times; or that can withstand interruptions - example if you have a background processing job like a customer survey that you can manually start or stop at any time without affecting the overall operations of your business. If you make a spot request and if the capacity is available, the instance launches immediately. If the capacity is not available, the launch is delayed until available. Moreover, once the instance is launched and there is no more capacity left for other requests, any further increase in demand/requests can impact your launched instance but it does not effect you background job processing. &lt;/li&gt;
&lt;li&gt;These types of instances are basically unused Amazon EC2 computing capacity.&lt;/li&gt;
&lt;li&gt;These can offer you cost savings at up to 90% off of On-Demand prices.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Dedicated hosts
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;These are physical servers with Amazon EC2 instance capacity that is fully dedicated to your use.&lt;/li&gt;
&lt;li&gt;You can use your existing per-socket, per-core, or per-VM software licenses to help maintain license compliance. &lt;/li&gt;
&lt;li&gt;You can purchase On-Demand Dedicated Hosts and Dedicated Hosts Reservations. &lt;/li&gt;
&lt;li&gt;These are the most expensive among all.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Scaling Amazon EC2
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;Amazon EC2 Auto-scaling enables you to automatically add or remove EC2 instances depending upon the changing application demand. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;There are two approaches to scaling Amazon EC2:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Dynamic scaling: responds to changing demand&lt;/li&gt;
&lt;li&gt;Predictive scaling: automatically schedules the right number of Amazon EC2 instances based on predicted demand.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Auto-scaling group:
&lt;/h4&gt;

&lt;p&gt;It is a logical grouping of Amazon EC2 instances for the purposes of auto scaling and management&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Both maintaining the number of instances in the auto scaling group and the automatic scaling are the core functionality of the Amazon EC2 auto-scaling service.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Scaling configurations:
&lt;/h4&gt;

&lt;p&gt;When you create an Auto Scaling group, you can set the minimum number of Amazon EC2 instances. The &lt;strong&gt;minimum capacity&lt;/strong&gt; is the number of Amazon EC2 instances that launch immediately after you have created the Auto Scaling group.&lt;/p&gt;

&lt;p&gt;You can set the &lt;strong&gt;desired capacity&lt;/strong&gt; at two Amazon EC2 instances even though your application needs a minimum of a single Amazon EC2 instance to run.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If you do not specify the desired number of Amazon EC2 instances in an Auto Scaling group, the desired capacity defaults to your minimum capacity.&lt;/li&gt;
&lt;li&gt;The size of an Auto Scaling group depends on the number of instances that you set as the desired capacity. You can adjust its size to meet demand, either manually or by using automatic scaling.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The third configuration that you can set in an Auto Scaling group is the &lt;strong&gt;maximum capacity&lt;/strong&gt;. For example, you might configure the Auto Scaling group to scale out in response to increased demand, but only to a maximum of four Amazon EC2 instances.&lt;/p&gt;

&lt;p&gt;You can use scaling policies to increase or decrease the number of instances in your group dynamically to meet changing conditions. When the scaling policy is in effect, the Auto Scaling group adjusts the desired capacity of the group, between the minimum and maximum capacity values that you specify, and launches or terminates the instances as needed.&lt;/p&gt;

&lt;p&gt;Because Amazon EC2 Auto Scaling uses Amazon EC2 instances, you pay for only the instances you use, when you use them.&lt;/p&gt;

&lt;h3&gt;
  
  
  Elastic Load Balancing
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;Elastic Load Balancing automatically distributes your incoming traffic across multiple targets, such as EC2 instances, containers, and IP addresses, in one or more Availability Zones. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;Using a load balancer increases the availability and fault tolerance of your applications. &lt;/li&gt;
&lt;li&gt;It monitors the health of its registered targets, and routes traffic only to the healthy targets. &lt;/li&gt;
&lt;li&gt;It scales your load balancer as your incoming traffic changes over time. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To use Elastic Load Balancing with your Auto Scaling group, &lt;a href="https://docs.aws.amazon.com/autoscaling/ec2/userguide/attach-load-balancer-asg.html" rel="noopener noreferrer"&gt;attach the load balancer to your Auto Scaling group&lt;/a&gt;. This registers the group with the load balancer, which acts as a single point of contact for all incoming web traffic to your Auto Scaling group.&lt;/p&gt;

&lt;h4&gt;
  
  
  Limitations
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;The load balancer and its target group must be in the same Region as your Auto Scaling group.&lt;/li&gt;
&lt;li&gt;The target group must specify a target type of &lt;code&gt;instance&lt;/code&gt;. You can't specify a target type of &lt;code&gt;ip&lt;/code&gt; when using an Auto Scaling group.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Phew 😵, that was a lot around EC2..!!&lt;br&gt;
But I know it's worth noting them all...😍&lt;/p&gt;

</description>
      <category>aws</category>
      <category>beginners</category>
      <category>devops</category>
      <category>cloud</category>
    </item>
    <item>
      <title>Mutable values with React.useRef()</title>
      <dc:creator>Vineet K</dc:creator>
      <pubDate>Sun, 21 Mar 2021 11:26:33 +0000</pubDate>
      <link>https://dev.to/vineetk13/mutable-values-with-useref-4ilg</link>
      <guid>https://dev.to/vineetk13/mutable-values-with-useref-4ilg</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;React.useRef()&lt;/strong&gt; hook is basically used to &lt;em&gt;refer to DOM elements&lt;/em&gt; and also to &lt;em&gt;create mutable values&lt;/em&gt; persisted between component re-rendering.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The first use case seems pretty straightforward but, what about the second one.!? Let's look at what it is and how does it work.&lt;/p&gt;

&lt;h3&gt;
  
  
  Firstly, what is a Mutable?
&lt;/h3&gt;

&lt;p&gt;It can be referred to as a type of variable containing mutable values i.e., values that can be changed in same memory space they were created. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;In JavaScript, only arrays and objects are mutable.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  useRef() in action
&lt;/h3&gt;

&lt;p&gt;React.useRef() takes an initial value as it's only arguement and returns a special object called &lt;em&gt;reference&lt;/em&gt;. It has a single property named &lt;em&gt;current&lt;/em&gt; which holds the reference value.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const reference = React.useRef(initialValue);
console.log(reference);   // { current : &amp;lt;referenceValue&amp;gt; }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The reference object here is mutable which means we can access the reference value using &lt;code&gt;reference.current&lt;/code&gt; and update it by assigning reference.current to a new value or variable. Huh! what's so special about this?🤷‍♂️&lt;/p&gt;
&lt;h3&gt;
  
  
  The speciality
&lt;/h3&gt;

&lt;p&gt;There are two important behaviours to remember about useRef() references:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The reference value stays the same (persists) between component re-renders.&lt;/li&gt;
&lt;li&gt;Updating a reference value does not re-render the component.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;
  
  
  Example - Logging button clicks
&lt;/h3&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;Here &lt;code&gt;const countRef = useRef(0)&lt;/code&gt; creates a reference &lt;code&gt;countRef&lt;/code&gt; initialized to 0. We use this reference object to store the number of clicks on a button. On clicking the button, the reference value is updated and logged to the console. As you might have noticed in your console that "Component rendered" is logged only once (during the initial render) which means that the button clicks, more precisely, the reference value updates do not trigger component re-renders. &lt;/p&gt;

&lt;p&gt;This further leads us to think about the difference between state and references.&lt;/p&gt;

&lt;h3&gt;
  
  
  Difference between state and references
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Updating state does trigger component re-rendering but updating a reference does not.&lt;/li&gt;
&lt;li&gt;The state update is asynchronous (state variable is updated after re-rendering - refer &lt;a href="https://vasanthk.gitbooks.io/react-bits/content/patterns/19.async-nature-of-setState.html" rel="noopener noreferrer"&gt;this&lt;/a&gt; for more detailed explanation), while the reference update is synchronous.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  No rule of thumb
&lt;/h3&gt;

&lt;p&gt;useRefs are just escape hatches in the framework and are not meant to be used unless necessarily required. However, they can be used to store any infrastructural data but never to store presentational data. Also do mind them while accessing DOM nodes.&lt;/p&gt;

&lt;h3&gt;
  
  
  Thank you ❤
&lt;/h3&gt;

&lt;p&gt;Connect with me on &lt;a href="https://twitter.com/Vineetkme" rel="noopener noreferrer"&gt;twitter&lt;/a&gt; and let's explore the web world together.&lt;/p&gt;

</description>
      <category>react</category>
      <category>frontend</category>
      <category>hooks</category>
      <category>mutability</category>
    </item>
    <item>
      <title>AWS Infrastructure</title>
      <dc:creator>Vineet K</dc:creator>
      <pubDate>Tue, 26 Jan 2021 08:56:04 +0000</pubDate>
      <link>https://dev.to/vineetk13/aws-infrastructure-1ph8</link>
      <guid>https://dev.to/vineetk13/aws-infrastructure-1ph8</guid>
      <description>&lt;p&gt;&lt;strong&gt;AWS Infrastructure entails to how AWS is setup for use by millions around the globe.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;AWS stores all of it's resources regionally to facilitate businesses and users located in different parts of the world. &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Region&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;A &lt;em&gt;region&lt;/em&gt; is a geographically self-contained area where all of the resources(compute, storage, etc.) you need for your application are contained. &lt;/p&gt;

&lt;p&gt;It could be a country or a continent bounded by it's own set of laws and procedures. And ofcourse, you need to choose the region that likely favor your needs. &lt;/p&gt;

&lt;p&gt;Few things that you need to consider before choosing a region are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Latency&lt;/strong&gt; : Users experience the application with greater speed if they are closer to a region. Analyze where most of your users are from and then choose a region closest to them. Speed does matter and think about latency if it is your first priority.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cost&lt;/strong&gt; :  Due to the fact that every country(that bound a region) has it's own set of tax laws or financial regulations, not every region is priced the same.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Compliance&lt;/strong&gt; : Legal restrictions like that of United States HIPAA requirements or European GDPR requirements can sometimes outweigh any other consideration. Make sure to understand if the country you operate in has requirements that may dictate everything the right way.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Service availability&lt;/strong&gt; : Not every new feature or service is available at all regions simultaneously, so make you know in which region it is operating in.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So, what are regions actually made of? Where are all the resources located in these regions? Here is the answer...&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Availability Zones&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Think of a &lt;em&gt;Region&lt;/em&gt; as a collection of &lt;em&gt;Availability Zones&lt;/em&gt;. An availability zone(AZ) consists of two more standalone data centers.&lt;/p&gt;

&lt;p&gt;They are separated with miles of distance from each other to prevent any natural disaster or unprecedented breach that could bring one down. In fact, all the availability zones in a region are inter-connected with high speed fiber network and when one goes down, the other takes backup and starts running as normal. You may infer this as your application is being run on multiple AZs simultaneously. &lt;/p&gt;

&lt;p&gt;Now that's something relaxing...&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Extras&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Local Zones&lt;/strong&gt; : They are a new type infrastructure deployment closer to large populated areas, industry and IT centers. With local zones you can run applications with high priority of latency such as live video &amp;amp; game streaming, electronic automations and machine-learning models.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Points of Presence&lt;/strong&gt; : These locations consists of &lt;em&gt;Edge Locations and Regional Edge Cache Servers&lt;/em&gt;. &lt;/p&gt;

&lt;p&gt;Check out &lt;a href="https://infrastructure.aws/" rel="noopener noreferrer"&gt;this&lt;/a&gt; page for interesting visualization on AWS infrastructure.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Thank you!&lt;/strong&gt;❤️
&lt;/h3&gt;

</description>
      <category>aws</category>
      <category>beginners</category>
      <category>server</category>
    </item>
  </channel>
</rss>
