Jekyll2022-01-15T10:27:38+00:00https://iamvp7.github.io//feed.xmlViswaprasathPlace to get started with ProgrammingDesigning Cache Architecture2022-01-14T10:00:00+00:002022-01-14T10:00:00+00:00https://iamvp7.github.io//designing-cache-architecture<p>Many software developers might have read about various architecture, among them for some Clean Architecture if favorite. The idea behind this architecture is as we move to the inner layers, it should not have any dependency from the external layer.</p>
<p>Recently in our team, we were planning to having casual interaction to introduce caching system; to reduce the text-based look-up from our SQL Database. Our main goal was</p>
<ol>
<li>Have good Developer Experience to new Developers to use system</li>
<li>Should be easier to introduce newer cache at any point in future</li>
</ol>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1642180916032/RoBf8nK-p.png" alt="Cache Implementation Diagration" /></p>
<p>Before moving to the details our hypothesis is as follows, at any point of time we will be having only one Distributed cache (Redis or DynamoDB or something else). Even when we are having two different caches at the same time it is not going to be difficult to do the implementation.</p>
<p>We have 4 layers in our architecture</p>
<ol>
<li>Cache Manager</li>
<li>Cache Connector</li>
<li>Cache System Connector</li>
<li>Physical Cache System</li>
</ol>
<h2 id="cache-manager">Cache Manager</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1642232711899/2xBweHEti.png" alt="business-cache.png" /></p>
<p>Cache Manager is the first layer of our Cache Architecture. Via this layer, other parts of the system will interact. And the methods which connect with the Cache API Connector are available here.</p>
<h3 id="cache-connector-and-cache-methods">Cache connector and Cache methods</h3>
<p>Here we have used the Abstract factory method to decide which Cache Layer (Redis, DynamoDB, or anything else) to connect on. We have also implemented the methods Cache API connecting methods in this layer with validations (checking NotNull for Key & Value).</p>
<h3 id="external-system-connector">External System Connector</h3>
<p>This is the Class where external components of the system connect to Connect with the Cache System to insert into Cache or Get value from Cache.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1642234097213/2Xok_-lZ_.png" alt="whole-architecture.png" /></p>
<h2 id="cache-connector">Cache Connector</h2>
<p>Once the Cache Manager decides which Cache System to connect with we will be moving to the next layer called Cache Connector or Cache API connector (Both names are interchangeable).</p>
<p>Let’s take DynamoDB as our Cache System. So once CachceManager decides its DynamoDB, we will be moving to the DynamoDB API Connector layer. This layer will be extending a few methods from CacheConnector Class.</p>
<h3 id="cacheconnector-class">CacheConnector Class</h3>
<p>In general, will be having the generic methods in which we want to interact with Cache.</p>
<p>Say we will have methods to insert/get data as JSON or text or HashMap, drop the keys so on. Some Cache may have some methods, not all so the classes (DynamoAPIConnector or RedisAPIConnector) which extend this abstract CacheConnector Class will write a little tweaked version according to their system.</p>
<p>In Redis we will have something like HSet where we can give two keys to look up the value. While in RocksDB we may not have this, so we will have a different approach to combine these two keys into a single key with some logic.</p>
<h3 id="dynamodb-cache-api-connector">DynamoDB Cache API connector</h3>
<p>So as mentioned before this method will be extending the CacheConnector Class. From this class, we will be connecting with DynamoDB System Connector which will have the core method and initialization logic.</p>
<p>In this DynamoDB Cache API connector class we will be extending the abstract methods from CacheConnector, and will be implemented according to the DynamoDB system method.</p>
<h2 id="dynamodb-cache-system-connector--actual-dynamodb-machine">DynamoDB Cache System Connector & Actual DynamoDB machine</h2>
<p>Cache System Connector is the core class where we will be having things like initialization of Cache and other core methods to interact with the Physical Cache System.</p>
<p>We will be loading the IP connection URL, read timeout, maximum connection to the physical cache machine, and so on.</p>
<h2 id="what-is-easier">What is easier?</h2>
<p>The main goal of our design decision is to make it easy for any other new system to be pluggable and removable easily.</p>
<p>If anyone wants to plug new Cache system (with KV) then they have to make 3 modification
1) In DBManager have to add Object creation for new Cache API Connector
2) Class which extends Cache API Connector
3) Class which extends Cache System Connector</p>
<h2 id="what-is-difficult">What is difficult?</h2>
<p>One of the major things is, in case we need to manage two Cache systems then we have to write a new method at DBManager.</p>
<p>This design came up during our casual interaction, feel free to share your thoughts to it can help us or anyone to improve designing the system.</p>
<p><em>All the logos are owned by the project companies</em></p>ViswaprasathMany software developers might have read about various architecture, among them for some Clean Architecture if favorite. The idea behind this architecture is as we move to the inner layers, it should not have any dependency from the external layer.What is API Gateway Server2021-05-06T00:00:00+00:002021-05-06T00:00:00+00:00https://iamvp7.github.io//what-is-api-gateway<p>In our previous post, we have seen about Load Balancer. In this post, we will be seeing about API Gateway and the little difference between Load Balancer and API Gateway.</p>
<p>The main job of the LoadBalancer is to forward the request which comes from the clients to the server, while the API gateway forwards the requests based on various conditions. Both LoadBalancer and API gateway can cache the static resources.</p>
<h3 id="ssl-updates">SSL Updates</h3>
<p>In general Load Balancer will be accepting both HTTP and HTTPS requests while API gateway is restricted to accept HTTPS API request only.</p>
<p>Its general practice to update the Encryption keys of the SSL certificates for HTTPS requests each month or on a certain frequency. These things are maintained in the API gateway mostly.</p>
<h3 id="authentication-and-authorization">Authentication and Authorization</h3>
<p>Both Loadbalancer and API gateway can help in the authentication part. Some of the complex services will be having complex authorization logic like some API for a specific set of users or organizations. This complex logic can be handled well at API gateway than in LoadBalancer.</p>
<h3 id="splitting-into-microservice">Splitting into Microservice</h3>
<p>API Gateway helps the service to split into multiple Microservice. For example, consider https://www.flipkart.com the famous e-commerce website in India.</p>
<p>In Flipkart there are a lot of actions, adding products to the cart, adding and fetching credit card details, displaying the products.</p>
<p>Each and everything is accessed from the client via API requests. So when the user adds a product into their Cart, first the request will land to API gateway and the Gateway based on the API pattern will redirect to a specific set of servers.</p>
<p><img src="https://iamvp7.github.io//assets/images/api-gatway.png" alt="API Gateway Diagram" /></p>
<p><strong>In the Above diagram consider</strong></p>
<ul>
<li>Servers with Number 1,2,3 for Adding products to Displaying Product</li>
<li>Servers with Number 4,5,6 for Adding products to cart</li>
<li>Servers with Number 7,8 for Fetching Credit and Debit card details</li>
</ul>
<h3 id="routing-of-request">Routing of Request</h3>
<p>Previously we saw the request landing to specific servers based on the user action. In the same way, based on the devices, we can forward the requests to various servers. These are done when mobile-based API is developed. In mobile-based scenarios generally, the amount of data transferred is very minimal so developers try to remove unwanted keys as much as possible and also try to accept fewer inputs from Android or iOS mobile devices.</p>
<h3 id="logging-and-monitoring">Logging and Monitoring</h3>
<p>An API gateway that can be helpful is Logging the API requests came servers. Logging can help products in a various way like allocating more resources based on the studying API patterns/device request patterns</p>
<h3 id="rate-limiting">Rate Limiting</h3>
<p>In the API gateway based on the client devices or authentication/authorization rate limiting can be done. Say we can add 35 products in our cart in one min, beyond 35 products sometimes it can be done by spammers also. So such types of rate limiting can be done at API gateway itself instead of hitting to Servers.</p>
<h3 id="can-act-as-central-adaptor">Can Act as Central Adaptor</h3>
<p>API Gateway can act as a central Adaptor that can communicate with various microservices. It can act as a coordinator between microservices.</p>ViswaprasathIn our previous post, we have seen about Load Balancer. In this post, we will be seeing about API Gateway and the little difference between Load Balancer and API Gateway.Rotating Array2021-05-06T00:00:00+00:002021-05-06T00:00:00+00:00https://iamvp7.github.io//rotate-array<p>There is a classica cryptography algorith named <a href="https://en.wikipedia.org/wiki/Caesar_cipher">Caesar Cipher</a>. In this algorithm we will be having all the 26 characters (in array arr) and we rotate the array some number of times (say 2 times and is stored in n).</p>
<p><img src="https://iamvp7.github.io/assets/images/rotated_array_new.jpg" alt="Caesar Cipher" /></p>
<p>So once we rotate the array two times, we will be having new array like below.</p>
<ul>
<li>A -> C</li>
<li>B -> D</li>
<li>C -> E</li>
<li>
<p>D -> F
…</p>
</li>
<li>X -> Z</li>
<li>Y -> A</li>
<li>Z -> B</li>
</ul>
<p>To achieve this programatically below program will be helpful. We have two algorithms for this.</p>
<h3 id="divide-reverse-reverse-reverse">Divide Reverse, Reverse, Reverse</h3>
<p><strong>Divide</strong>
In this algorithm we will be virtually splitting the array into two parts. First part will be from start position (0) to number of times we want to rotate. Second part is from next character of rotation times to end of array.</p>
<div class="language-java highlighter-rouge"><div class="highlight"><pre class="highlight"><code> <span class="kd">private</span> <span class="kt">void</span> <span class="nf">rotateUsingReverse</span><span class="o">(</span><span class="kt">int</span><span class="o">[]</span> <span class="n">arr</span><span class="o">,</span> <span class="kt">int</span> <span class="n">rotationTimes</span><span class="o">){</span>
<span class="c1">// In one access two elements are swapped</span>
<span class="n">reverse</span><span class="o">(</span><span class="n">arr</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span> <span class="n">rotationTimes</span><span class="o">-</span><span class="mi">1</span><span class="o">);</span>
<span class="n">reverse</span><span class="o">(</span><span class="n">arr</span><span class="o">,</span> <span class="n">rotationTimes</span><span class="o">,</span><span class="n">arr</span><span class="o">.</span><span class="na">length</span><span class="o">-</span><span class="mi">1</span><span class="o">);</span>
<span class="c1">// here we will have another half number of access.</span>
<span class="n">reverse</span><span class="o">(</span><span class="n">arr</span><span class="o">,</span> <span class="mi">0</span><span class="o">,</span><span class="n">arr</span><span class="o">.</span><span class="na">length</span><span class="o">-</span><span class="mi">1</span><span class="o">);</span>
<span class="o">}</span>
<span class="c1">// In one access two elements are swapped</span>
<span class="kd">private</span> <span class="kt">void</span> <span class="nf">reverse</span><span class="o">(</span><span class="kt">int</span><span class="o">[]</span> <span class="n">arr</span><span class="o">,</span> <span class="kt">int</span> <span class="n">startIndex</span><span class="o">,</span> <span class="kt">int</span> <span class="n">endIndex</span><span class="o">){</span>
<span class="k">while</span> <span class="o">(</span><span class="n">startIndex</span><span class="o"><</span><span class="n">endIndex</span><span class="o">){</span>
<span class="kt">int</span> <span class="n">tempNumber</span> <span class="o">=</span> <span class="n">arr</span><span class="o">[</span><span class="n">startIndex</span><span class="o">];</span>
<span class="n">arr</span><span class="o">[</span><span class="n">startIndex</span><span class="o">]</span> <span class="o">=</span> <span class="n">arr</span><span class="o">[</span><span class="n">endIndex</span><span class="o">];</span>
<span class="n">arr</span><span class="o">[</span><span class="n">endIndex</span><span class="o">]</span> <span class="o">=</span> <span class="n">tempNumber</span><span class="o">;</span>
<span class="o">++</span><span class="n">startIndex</span><span class="o">;</span>
<span class="o">--</span><span class="n">endIndex</span><span class="o">;</span>
<span class="o">}</span>
<span class="o">}</span>
</code></pre></div></div>
<p><strong>Reverse, Reverse, Reverse</strong></p>
<p>So We have virtually split the array into two segments. Now we take the first segment which ll have number of times the rotation to be made (say if the rotation is 5 times we will have 5 elements).</p>
<p>We will be reversing this first small array, by the following step.</p>
<ul>
<li>First we will be keeping a temporary copy of initial index(0) in temp variable.</li>
<li>We will now copy the last element (value at endIndex or value at index 4 for 5 elements), to initial Index</li>
<li>Next we will copy the value at inital index to the endIndex</li>
<li>Next we will increment the startIndex by 1</li>
<li>Next we will decrease the endIndex by 1.</li>
</ul>
<p>We will be continuing the above step till startIndex is less than endIndex.</p>
<p>Similarly we will do for the next segement of array. Now we will be reversing the whole array. Below example will help you understanding.</p>
<p>int[] arrayOfNumber = {1,2,3,4,5,6,7,8,9};
Lets rotate 3 times.</p>
<p>So We will be having 2 virital array
array1 => {1.2.3}
array2 => {4,5,6,7,8,9}</p>
<p>Now we will be reversing the virtual array1 -> {3,2,1}
Now we will be reversing the virtual array2 -> {9,8,7,6,5,4}</p>
<p>Now the arrayOfNumber will be like => {3,2,1,9,8,7,6,5,4}</p>
<p>Now again we will be rotation the whole arrayOfNumber => {4,5,6,7,8,9,1,2,3}</p>
<h3 id="divide-and-move">Divide and Move</h3>
<p>In this algorithm, we will be divinding the whole array into segments. To do this we will be first starting to find the GCD (Greatest Common Divisor) among the number of times we have to rotate and length of array.</p>
<p>Say No of Times we rotate is 3
Length of Array is 9</p>
<p>Then GCD is 3.
Assumed our array is -> int[] arrayOfNumber = {1,2,3,4,5,6,7,8,9};</p>
<p>So we will have the segments each with 3 elements.</p>
<ul>
<li>Segment1 -> {1,2,3}</li>
<li>Segment2 -> {4,5,6}</li>
<li>Segment3 -> {7,8,9}</li>
</ul>
<p>First we will be having the first element (initial index element -> 0) to swap in temporary argument. In our case its 1.</p>
<p>Then we will be move the element at 3rd index (0+3) to the initial Index (0). So now Array becomes like this</p>
<p><strong>4 is moved</strong>
{4,2,3,4,5,6,7,8,9};</p>
<p>Then we will be increment the position by 3 so we can move the next element. in case if its more than or equal to length of array, then we will subtract that value from length of array. Now the Array will look like below</p>
<p><strong>7 is moved</strong>
{4,2,3,7,5,6,7,8,9};</p>
<p>We will again will be increment the position to move the element, Now it will become 9, since its equal to length of array we will subtract it and now it becomes 0. If startIndex and new index to move element is equal we will break the while low. and at the end we will set the value of inital index element to old update position. So the array becomes like</p>
<p><strong>1 is placed at end of while</strong>
{4,2,3,7,5,6,1,8,9};</p>
<p>Now we will be increment the inital Index by 1.
So now the temporary element will be at array[1] which is 2.</p>
<p>Now we will be elements will be replaced like this</p>
<ul>
<li>2 <- 5</li>
<li>5 <- 8</li>
<li>8 <- 2</li>
</ul>
<p>Now the updated the array will be like below.
{4,5,3,7,8,6,1,2,9}</p>
<p>Next we will increment inital index by 1 so it becomes 2 now. and swap numbers left numbers</p>
<ul>
<li>3 <- 6</li>
<li>6 <- 9</li>
<li>9 <- 3</li>
</ul>
<p>Now the updated the array will be like below.
{4,5,6,7,8,9,1,2,3}</p>
<div class="language-java highlighter-rouge"><div class="highlight"><pre class="highlight"><code>
<span class="kd">private</span> <span class="kt">void</span> <span class="nf">rotateArray</span><span class="o">(</span><span class="kt">int</span><span class="o">[]</span> <span class="n">arr</span><span class="o">,</span> <span class="kt">int</span> <span class="n">rotationTimes</span><span class="o">){</span>
<span class="kt">int</span> <span class="n">numberOfItemsInSegment</span> <span class="o">=</span><span class="n">findTheGCD</span><span class="o">(</span><span class="n">arr</span><span class="o">.</span><span class="na">length</span><span class="o">,</span><span class="n">rotationTimes</span><span class="o">);</span>
<span class="k">for</span><span class="o">(</span><span class="kt">int</span> <span class="n">startIndex</span><span class="o">=</span><span class="mi">0</span><span class="o">;</span> <span class="n">startIndex</span><span class="o"><</span><span class="n">numberOfItemsInSegment</span><span class="o">;++</span><span class="n">startIndex</span><span class="o">){</span>
<span class="kt">int</span> <span class="n">tempElement</span> <span class="o">=</span> <span class="n">arr</span><span class="o">[</span><span class="n">startIndex</span><span class="o">];</span>
<span class="kt">int</span> <span class="n">indexToSwap</span> <span class="o">=</span> <span class="n">startIndex</span><span class="o">;</span>
<span class="k">while</span> <span class="o">(</span><span class="kc">true</span><span class="o">)</span> <span class="o">{</span>
<span class="kt">int</span> <span class="n">nextIndexToswp</span> <span class="o">=</span> <span class="n">indexToSwap</span> <span class="o">+</span> <span class="n">rotationTimes</span><span class="o">;</span>
<span class="k">if</span><span class="o">(</span><span class="n">nextIndexToswp</span><span class="o">>=</span> <span class="n">arr</span><span class="o">.</span><span class="na">length</span><span class="o">){</span>
<span class="n">nextIndexToswp</span> <span class="o">=</span> <span class="n">nextIndexToswp</span><span class="o">-</span><span class="n">arr</span><span class="o">.</span><span class="na">length</span><span class="o">;</span>
<span class="o">}</span>
<span class="k">if</span><span class="o">(</span><span class="n">startIndex</span><span class="o">==</span><span class="n">nextIndexToswp</span><span class="o">){</span>
<span class="k">break</span><span class="o">;</span>
<span class="o">}</span>
<span class="kt">int</span> <span class="n">swapElement</span> <span class="o">=</span> <span class="n">arr</span><span class="o">[</span><span class="n">nextIndexToswp</span><span class="o">];</span>
<span class="n">arr</span><span class="o">[</span><span class="n">indexToSwap</span><span class="o">]</span> <span class="o">=</span> <span class="n">swapElement</span><span class="o">;</span>
<span class="n">indexToSwap</span><span class="o">=</span><span class="n">nextIndexToswp</span><span class="o">;</span>
<span class="o">}</span>
<span class="n">arr</span><span class="o">[</span><span class="n">indexToSwap</span><span class="o">]</span> <span class="o">=</span> <span class="n">tempElement</span><span class="o">;</span>
<span class="o">}</span>
<span class="c1">// return arr;</span>
<span class="o">}</span>
<span class="kd">private</span> <span class="kt">int</span> <span class="nf">findTheGCD</span><span class="o">(</span><span class="kd">final</span> <span class="kt">int</span> <span class="n">firstNumber</span><span class="o">,</span> <span class="kd">final</span> <span class="kt">int</span> <span class="n">secondNumber</span><span class="o">){</span>
<span class="k">if</span><span class="o">(</span><span class="n">secondNumber</span> <span class="o">==</span> <span class="mi">0</span><span class="o">){</span>
<span class="k">return</span> <span class="n">firstNumber</span><span class="o">;</span>
<span class="o">}</span><span class="k">else</span><span class="o">{</span>
<span class="k">return</span> <span class="nf">findTheGCD</span><span class="o">(</span><span class="n">secondNumber</span><span class="o">,</span><span class="n">firstNumber</span><span class="o">%</span><span class="n">secondNumber</span><span class="o">);</span>
<span class="o">}</span>
<span class="o">}</span>
</code></pre></div></div>ViswaprasathThere is a classica cryptography algorith named Caesar Cipher. In this algorithm we will be having all the 26 characters (in array arr) and we rotate the array some number of times (say 2 times and is stored in n).Basics of Load Balancer2021-04-28T10:00:00+00:002021-04-28T10:00:00+00:00https://iamvp7.github.io//basics-of-load-balancer<p>Load Balancer</p>
<p>In our previous post <a href="/proxy-vs-reverse-proxy">Proxy Vs Reverse Proxy</a>, we have seen reverse proxy is widely used as Load Balancer. In this post, we will be checking what is a load balancer, what are various advantages of using a load balancer, what are the commonly used algorithms.</p>
<p>In this post, we can consider the website https://www.flipkart.com one of the famous E-commerce shopping website. From May 2nd - 7th they are having a massive event named Big Savings Days. During this time the requests from the users like us will be tremendous. Flipkart will be having 100’s of servers for scaling this many users.</p>
<h3 id="what-is-load-balancer">What is Load Balancer</h3>
<p>A Load balancer is a Reverse proxy. It is mainly used to distribute the huge income of requests from clients to various hosted servers. The Flipkart load balancer will be first accepting the request and then forward it to one of the 100’s servers which is free to serve the request.</p>
<h3 id="features-of-load-balancer">Features of Load Balancer</h3>
<ul>
<li>Effectively distribute the traffic coming from clients to various servers (if all request lands on to same server users will be affected so it has to be distributed)</li>
<li>Maintain the flipkart.com with great stability, by distributing the requests to the servers which are only available.</li>
<li>Can help in authenticating the client.</li>
<li>Can distribute the request to different Flipkart app servers based on the type of device used.</li>
</ul>
<h3 id="load-balancer-algorithms">Load Balancer Algorithms</h3>
<p>To distribute the load effectively, the reverse proxy uses certain algorithms to forward the request. They are mainly classified as Static algorithms and dynamic algorithms.</p>
<h4 id="static-algorithms">Static Algorithms</h4>
<p>Assumptions are made beforehand and the state of machines is not considered.
Static Algorithms are easy to configure but sometimes some machines get overloaded.</p>
<h4 id="dynamic-algorithms">Dynamic Algorithms</h4>
<p>They will be considering the state (load) of the machine and distribute traffic accordingly.
They are difficult to design but are effective and can maintain the reliability of the sites.</p>
<h3 id="algorithms">Algorithms</h3>
<p>Below are some of the most widely used algorithms. There are a lot of other techniques also.</p>
<h4 id="roundrobin-algorithm">RoundRobin Algorithm</h4>
<p>Assign the first request to the first server, second to second, and moves on in a circular fashion.</p>
<h4 id="randomize-static">Randomize Static</h4>
<p>Distribute the requests in a random way among all the servers.</p>
<h4 id="ip-hash-based">IP Hash-based</h4>
<p>Find the hash of the client IP (user IP address from which request is sent) and use the hash function to distribute it to different app servers.</p>
<h4 id="sticky-session">Sticky Session</h4>
<p>In this type of algorithm, the load balancer will be persisting the information of the server which handled the request.</p>
<p>Say the first request comes from User1, it lands to the server10; then when the request comes again from the same user, the load balancer will be forwarding the request to the same server10. This is sometimes achieved using sessionid or cookie.</p>
<h4 id="master-worker-schema">Master-worker Schema</h4>
<p>In this, there will be a Master who will be distributing the tasks to other servers (sometimes referred to as slaves). Here all the slaves have to report whether they are idle. This algorithm will distribute the load decently to all the app servers based on the load. The main problem is it’s very difficult to design and also the communication overhead is too high.</p>
<p>There are more things to learn in this direction like Consistent Hashing, Rate Limiting(one of my friends wrote an article on this, checkout in <a href="https://buildwithsammie.hashnode.dev/how-to-design-a-scalable-api-rate-limiter">hashnode</a>), API Gateway, and so on.</p>ViswaprasathLoad BalancerProxy vs Reverse Proxy2021-04-27T10:00:00+00:002021-04-27T10:00:00+00:00https://iamvp7.github.io//proxy-vs-reverse-proxy<p>Lets learn about the basics of Proxy server vs Reverse Proxy server.</p>
<h2 id="proxy-server">Proxy Server</h2>
<p>Proxy is helpful for the client-side connection. It mainly helps the client to hide their identity.</p>
<p>We can consider a scenario where we connect to the internet via our college network. Think of 3 friends connecting to various servers</p>
<ul>
<li>Friend 1: Connecting to the internet via Android phone to google.com</li>
<li>Friend 2: Connecting to the internet via iPhone to youtube.com</li>
<li>Friend 3: Connecting to the internet via Dell Laptop to wikipedia.com</li>
</ul>
<p>We all 3 connect via our college internet. And our college has a proxy server named CollegeProxy Server.</p>
<p>First of all, all our requests will be going to this CollegeProxy Server, and this server will be making connections to google.com or facebook.com, or twitter.com for us.</p>
<h3 id="hide-client-identity">Hide Client Identity</h3>
<p>For google.com or youtube.com or wikipedia.com, all the details from the client are got by this CollegeProxy Server and this CollegeProxy Server requests us. All these google.com, youtube.com, and wikipedia.com will only know CollegeProxy Server has requested.</p>
<h3 id="blocking-website">Blocking website</h3>
<p>To make students productive, colleges will be blocking sites like facebook.com or twitter.com if we are connecting via college internet.
A proxy server will be very much helpful for blocking unwanted websites.</p>
<h3 id="geofencing">GeoFencing</h3>
<p>Some of the sites can be restricted to access when connected via proxy server alone. For example, when we are connected to our College internet connection (which in turn connects to our CollegeProxy Server) we will be allowed to access our digital mark sheet website, assignments website, and timetable website which we will not be allowed when are outside of our college internet</p>
<h2 id="reverse-proxy">Reverse Proxy</h2>
<p>Reverse Proxy is helpful for Servers.</p>
<p>As the Proxy server helps the client-side connection (like making anonymity of 3 Friends mentioned above), Reverse Proxy helps Server from unwanted clients.</p>
<p>Let’s assume there are few internal websites in our College. And now let’s assume we have a reverse proxy server named CollegeReverseProxy.</p>
<p>Let’s name the domain of the internal website as collegeinternalwebsite.com</p>
<h3 id="hide-server-identity">Hide Server Identity</h3>
<p>Our college internal website (collegeinternalwebsite.com) will be running on 5 or 6 machines. If the IP address of those machines is known to hackers then it can be corrupted. CollegeReverseProxy server can help in <strong>hiding the internal IP address of the servers</strong>.</p>
<h3 id="blocking-bots-and-unwanted-users-access">Blocking bots and unwanted users access</h3>
<p>Consider there are some notorious students who try to access college internal resources without giving the password and username, these types of <strong>unauthorized access</strong> can be stopped at CollegeReverseProxy before sending the request to the resource website.</p>
<p>Think of 1000 requests coming within 10 seconds to the same internal resources from the same machine. Requests like these are mostly <strong>targeted attacks</strong> and these types of requests <strong>are blocked at CollegeReverseProxy</strong> level itself before coming to the resources server</p>
<h3 id="can-cache-resources">Can Cache Resources</h3>
<p>ReverseProxy server can <strong>cache the most static resources</strong> which won’t be changed for a long time. With this, load coming to the servers can be reduced.</p>
<h3 id="act-as-load-balancer">Act as Load Balancer</h3>
<p>Load Balancer is the special type of use case of Reverse Proxy and its most common example. Simple we can use a Reverse Proxy server to <strong>distribute the request to different servers</strong> based on some logic. We can check the later detailed post about Load balancer.</p>ViswaprasathLets learn about the basics of Proxy server vs Reverse Proxy server.