<?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: Kabilan Muthusamy</title>
    <description>The latest articles on DEV Community by Kabilan Muthusamy (@kabilan).</description>
    <link>https://dev.to/kabilan</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%2F588516%2Fc3a6420f-1c18-4674-91fc-2cf4c8ca75ef.png</url>
      <title>DEV Community: Kabilan Muthusamy</title>
      <link>https://dev.to/kabilan</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kabilan"/>
    <language>en</language>
    <item>
      <title>Transactions</title>
      <dc:creator>Kabilan Muthusamy</dc:creator>
      <pubDate>Sat, 03 Feb 2024 08:36:30 +0000</pubDate>
      <link>https://dev.to/kabilan/transactions-43kp</link>
      <guid>https://dev.to/kabilan/transactions-43kp</guid>
      <description>&lt;p&gt;In Software development, it's important to prevent an application from getting into an inconsistent state. Let's get into this by looking at an example,&lt;/p&gt;

&lt;p&gt;Transferring of money, which involves deducting money from User A, and adding the money to User B. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Case 1:&lt;/strong&gt;&lt;br&gt;
What happens if the app crashes after deducting money from User A? This is an inconsistent state where User A sent the money and User B didn't receive the money.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Case 2:&lt;/strong&gt;&lt;br&gt;
What happens when User B also transfer money at the same time? There is a possibility that a transfer may override others. (race condition in a multi-threaded application). The balance of User B would be incorrect, which is also inconsistent.&lt;/p&gt;

&lt;p&gt;This can be solved using Database Transactions, a sequence of operations that is considered a single unit of work. A Transactions provides ACID properties, which stands for&lt;/p&gt;

&lt;p&gt;▶ Atomicity, all operations should succeed completely or fail i.e. If one operation fails, everything fails.&lt;/p&gt;

&lt;p&gt;▶ Consistency, all the writes should be valid.&lt;/p&gt;

&lt;p&gt;▶ Isolation, guarantees the correct execution of concurrent transactions, with isolation levels.&lt;/p&gt;

&lt;p&gt;▶ Durability, If a transaction succeeds, it should persist even in case of system crashes.&lt;/p&gt;

&lt;p&gt;The transaction's Atomicity property can solve case 1. The database locks can be used to prevent a single resource from being concurrently accessed by multiple threads/processes which will solve case 2.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Database Locks</title>
      <dc:creator>Kabilan Muthusamy</dc:creator>
      <pubDate>Sun, 16 Apr 2023 03:57:58 +0000</pubDate>
      <link>https://dev.to/kabilan/database-locks-2hl0</link>
      <guid>https://dev.to/kabilan/database-locks-2hl0</guid>
      <description>&lt;h2&gt;
  
  
  What are Locks in Database?
&lt;/h2&gt;

&lt;p&gt;In programming, Locks are used to having controlled access to resources i.e to prevent multiple threads from accessing the resources at the same time. Likewise, Database Locks provide mechanisms to access shared resources such as tables and rows in a multi-user environment.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why do we need locks?
&lt;/h2&gt;

&lt;p&gt;Let's take an example of a money transfer operation where user A transfers money to user B and user C transfers money to user A:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Vuanx8RX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aou3qy64zotxh34qkzdp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Vuanx8RX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aou3qy64zotxh34qkzdp.png" alt="Image description" width="800" height="346"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The above example produces an inconsistent result thus User A is unaware of the User C updates.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9lBsWAg6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3ma3bjwy8qtbaxq2ihlh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9lBsWAg6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3ma3bjwy8qtbaxq2ihlh.png" alt="Image description" width="800" height="508"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this case, User A acquired a lock 🔒, so User C was not able to access the rows.&lt;/p&gt;

&lt;h2&gt;
  
  
  Lock Modes
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Shared Locks&lt;/strong&gt;: Shared locks, also known as read locks, are used to allow multiple users to read a resource simultaneously while preventing any user from modifying it. Shared locks are useful when several users need to access the same data for reading purposes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Exclusive Locks&lt;/strong&gt;: Exclusive locks, also known as write locks, are used to grant exclusive access to a resource to a single user or application, preventing any other users from accessing or modifying it. Exclusive locks are useful when a user needs to modify a resource without interference from other users.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Update Locks&lt;/strong&gt;: Update locks are a combination of shared and exclusive locks. They allow multiple users to read a resource simultaneously but require exclusive access when a user needs to modify the resource. Update locks are useful when a resource needs to be frequently read but modified less frequently.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Intent Locks&lt;/strong&gt;: Intent locks are used to indicate that a transaction or user intends to acquire a lock on a resource. Intent locks can be used to coordinate the acquisition of shared or exclusive locks between multiple resources to prevent deadlocks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Schema Locks&lt;/strong&gt;: Schema locks are used to control access to the schema of a database, including tables, views, and stored procedures. Schema locks prevent other users from modifying the schema while a user is making changes to it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Range Locks&lt;/strong&gt;: Range locks are used to lock a range of values in an index, preventing other users from modifying the same range of values concurrently. Range locks are useful when multiple users need to access the same range of values in an index.&lt;/p&gt;

&lt;h2&gt;
  
  
  Problems associated with locks
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Deadlocks&lt;/strong&gt;: Deadlocks occur when two or more transactions are waiting for each other to release locks on shared resources, leading to a situation where none of the transactions can proceed. Deadlocks can cause a system to become unresponsive, and can only be resolved by aborting one or more of the transactions involved.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lock Contention&lt;/strong&gt;: Lock contention occurs when multiple transactions are waiting to acquire the same lock on a shared resource, leading to delays and reduced system performance. Lock contention can be mitigated by using lock escalation, where a database system converts multiple low-level locks into a higher-level lock.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Locking Overhead&lt;/strong&gt;: Locking overhead occurs when a database system needs to manage a large number of locks, leading to increased memory and processing requirements. Locking overhead can be reduced by using lock-free data structures, where multiple users or applications can access shared resources concurrently without the need for locks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reduced Concurrency&lt;/strong&gt;: Locks can reduce concurrency by preventing multiple users or applications from accessing shared resources simultaneously. This can lead to delays and decreased system performance, especially in scenarios where concurrent access is frequent.&lt;/p&gt;

</description>
      <category>database</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Understanding NGINX Core Contexts</title>
      <dc:creator>Kabilan Muthusamy</dc:creator>
      <pubDate>Mon, 31 May 2021 03:42:33 +0000</pubDate>
      <link>https://dev.to/kabilan/understanding-nginx-core-contexts-52o8</link>
      <guid>https://dev.to/kabilan/understanding-nginx-core-contexts-52o8</guid>
      <description>&lt;h2&gt;
  
  
  What is NGINX ?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Nginx&lt;/strong&gt; [engine x] is a free and opensource high performance &lt;strong&gt;web-server&lt;/strong&gt; that can be used as reverse proxy, load balancer, SMTP proxy and a generic TCP/UDP proxy server. Nginx originally developed by &lt;strong&gt;Igor Sysoev&lt;/strong&gt; in 2002 to solve C10k problem.&lt;/p&gt;




&lt;h2&gt;
  
  
  NGINX Configuration file
&lt;/h2&gt;

&lt;p&gt;NGINX can be configured with &lt;code&gt;nginx.conf&lt;/code&gt; file, By default this file is named as &lt;code&gt;nginx.conf&lt;/code&gt; and placed under &lt;code&gt;/usr/local/nginx/conf&lt;/code&gt;, &lt;code&gt;/etc/nginx&lt;/code&gt;, or &lt;code&gt;/usr/local/etc/nginx&lt;/code&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  What are  Directives and Contexts?
&lt;/h2&gt;

&lt;p&gt;NGINX con­fig­u­ra­tion con­sists of key-value pairs called direc­tives. Direc­tives decides which configuration to apply.They can be organized and grouped into Blocks known as Contexts. Contexts are tree like structures that can be nested within one another and Direc­tives can  only been used within Contexts.&lt;/p&gt;

&lt;p&gt;Directives looks like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight conf"&gt;&lt;code&gt;&lt;span class="n"&gt;user&lt;/span&gt; &lt;span class="n"&gt;nginx&lt;/span&gt;;
&lt;span class="n"&gt;worker_processes&lt;/span&gt; &lt;span class="m"&gt;5&lt;/span&gt;;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Contexts look like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight conf"&gt;&lt;code&gt;&lt;span class="c"&gt;# Global Context
&lt;/span&gt;....
....

&lt;span class="c"&gt;# http Context 
&lt;/span&gt;&lt;span class="n"&gt;http&lt;/span&gt; {
      ....
      ....
      &lt;span class="c"&gt;# server Context
&lt;/span&gt;      &lt;span class="n"&gt;server&lt;/span&gt; {
             ....
             ....
      }

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Global context
&lt;/h2&gt;

&lt;p&gt;The "global" context is placed at the beginning of the core NGINX configuration file and is used to set the configuration for NGINX globally.&lt;/p&gt;

&lt;p&gt;The global context allows module writer  to configure user, no.of works, file  to save the main process's PID, worker CPU affinity and niceness of worker processes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight conf"&gt;&lt;code&gt;&lt;span class="c"&gt;#global context
&lt;/span&gt;
&lt;span class="c"&gt;# global directive
&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt; &lt;span class="n"&gt;nobody&lt;/span&gt;;
&lt;span class="n"&gt;worker_processes&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;;
....
....

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Events context
&lt;/h2&gt;

&lt;p&gt;The "events" context is contained within "global" context and  can be used to set global options for NGINX connection processing.There can only be a single events context defined within the NGINX configuration.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight conf"&gt;&lt;code&gt;&lt;span class="c"&gt;#global context
&lt;/span&gt;
&lt;span class="c"&gt;# global directive
&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt; &lt;span class="n"&gt;nobody&lt;/span&gt;;
&lt;span class="n"&gt;worker_processes&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;;
....
....

&lt;span class="c"&gt;#events context
&lt;/span&gt;&lt;span class="n"&gt;events&lt;/span&gt; {
       &lt;span class="c"&gt;# events directive
&lt;/span&gt;       ....
       ....
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  HTTP context
&lt;/h2&gt;

&lt;p&gt;The "http" context holds directives for handling HTTP and HTTPS traffic. The  Server context can be placed inside the HTTP context.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight conf"&gt;&lt;code&gt;&lt;span class="c"&gt;#global context
&lt;/span&gt;
&lt;span class="c"&gt;# global directive
&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt; &lt;span class="n"&gt;nobody&lt;/span&gt;;
&lt;span class="n"&gt;worker_processes&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;;
....
....

&lt;span class="c"&gt;#events context
&lt;/span&gt;&lt;span class="n"&gt;events&lt;/span&gt; {
       &lt;span class="c"&gt;# events directive
&lt;/span&gt;       ....
       ....
}
&lt;span class="c"&gt;# http context
&lt;/span&gt;&lt;span class="n"&gt;http&lt;/span&gt; {
      &lt;span class="c"&gt;# http directive
&lt;/span&gt;      ....
      ....
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Server context
&lt;/h2&gt;

&lt;p&gt;The “server” context is declared within the "http" context. There can be multiple instance of server context within http context. Each server context instance is a virtual server to handle client request.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;listen&lt;/strong&gt; and &lt;strong&gt;server_name&lt;/strong&gt; directives within the server context will be used to determine which server context can be used to respond the request. The directives in this context can override the directives that may defined in the http context.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight conf"&gt;&lt;code&gt;&lt;span class="c"&gt;# http context
&lt;/span&gt;&lt;span class="n"&gt;http&lt;/span&gt; {
      &lt;span class="c"&gt;# server context
&lt;/span&gt;      &lt;span class="n"&gt;server&lt;/span&gt; {
             &lt;span class="c"&gt;# server directive
&lt;/span&gt;             &lt;span class="n"&gt;listen&lt;/span&gt;: &lt;span class="m"&gt;80&lt;/span&gt;;
             &lt;span class="n"&gt;server_name&lt;/span&gt;: &lt;span class="n"&gt;example&lt;/span&gt;.&lt;span class="n"&gt;com&lt;/span&gt;, &lt;span class="n"&gt;www&lt;/span&gt;.&lt;span class="n"&gt;example&lt;/span&gt;.&lt;span class="n"&gt;com&lt;/span&gt;
             ....
             ....
      }      
      ....
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Location Context
&lt;/h2&gt;

&lt;p&gt;The "location" contexts are used to define directives to handle client request. When a request for resource arrives at NGINX, it will try to match the URI to one of the locations and handle it accordingly. A location context can be  nested within server context and also within another location context.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight conf"&gt;&lt;code&gt;&lt;span class="c"&gt;# http context
&lt;/span&gt;&lt;span class="n"&gt;http&lt;/span&gt; {
      &lt;span class="c"&gt;# server context
&lt;/span&gt;      &lt;span class="n"&gt;server&lt;/span&gt; {
             &lt;span class="n"&gt;listen&lt;/span&gt; : &lt;span class="m"&gt;80&lt;/span&gt;;
             &lt;span class="c"&gt;# first location context
&lt;/span&gt;             &lt;span class="n"&gt;location&lt;/span&gt; &lt;span class="n"&gt;parameter&lt;/span&gt; {
                      ....
                      ....
             }
             &lt;span class="c"&gt;# second location context
&lt;/span&gt;             &lt;span class="n"&gt;location&lt;/span&gt; &lt;span class="n"&gt;parameter&lt;/span&gt; {
                      &lt;span class="c"&gt;# nested location context
&lt;/span&gt;                      &lt;span class="n"&gt;location&lt;/span&gt; &lt;span class="n"&gt;parameter&lt;/span&gt; {
                               ....
                               ....
                      }
                  ....
             }
      }      
      ....
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There are two types of parameter to the location directive: prefix strings (path names) and regular expressions. For a request URI to match a prefix string, it must start with the prefix string.A regular expression is preceded with the tilde (~) for case-sensitive matching, or the tilde-asterisk (~*) for case-insensitive matching.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight conf"&gt;&lt;code&gt;&lt;span class="c"&gt;# location with string (path parameter)
&lt;/span&gt;&lt;span class="n"&gt;location&lt;/span&gt; /&lt;span class="n"&gt;home&lt;/span&gt;/&lt;span class="n"&gt;user&lt;/span&gt;/ {
         &lt;span class="c"&gt;# URI starting with /home/user/ will match 
&lt;/span&gt;         &lt;span class="c"&gt;# but /some/home/user/ won't 
&lt;/span&gt;         ....
}

&lt;span class="c"&gt;# location with regular expression as parameter
&lt;/span&gt;&lt;span class="n"&gt;location&lt;/span&gt; ~ /.&lt;span class="n"&gt;html&lt;/span&gt;? {
         &lt;span class="c"&gt;# URI that  has .html or .htm string
&lt;/span&gt;         &lt;span class="c"&gt;# in it will match
&lt;/span&gt;         ....
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Upstream context
&lt;/h2&gt;

&lt;p&gt;The "upstream" context is used to define and configure “upstream” servers. Basically, this context defines a named pool of servers that Nginx can then proxy requests to. This context will likely be used when you are configuring proxies of various types.  The upstream context should be defined within http context and outside the server context, to be used.&lt;/p&gt;

&lt;p&gt;Once the upstream servers have been defined, the name of the same is available within the server context to pass the request to the pool of back-end servers.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight conf"&gt;&lt;code&gt;&lt;span class="n"&gt;http&lt;/span&gt; {
    &lt;span class="c"&gt;# upstream context
&lt;/span&gt;    &lt;span class="n"&gt;upstream&lt;/span&gt; &lt;span class="n"&gt;backend&lt;/span&gt; {
        &lt;span class="n"&gt;server&lt;/span&gt; &lt;span class="n"&gt;backend1&lt;/span&gt;.&lt;span class="n"&gt;example&lt;/span&gt;.&lt;span class="n"&gt;com&lt;/span&gt;;
        &lt;span class="n"&gt;server&lt;/span&gt; &lt;span class="n"&gt;backend2&lt;/span&gt;.&lt;span class="n"&gt;example&lt;/span&gt;.&lt;span class="n"&gt;com&lt;/span&gt;;
    }
    &lt;span class="c"&gt;# server context
&lt;/span&gt;    &lt;span class="n"&gt;server&lt;/span&gt; {
           &lt;span class="n"&gt;location&lt;/span&gt; / {
                    &lt;span class="n"&gt;proxy_pass&lt;/span&gt; &lt;span class="n"&gt;http&lt;/span&gt;://&lt;span class="n"&gt;backend&lt;/span&gt;;
           }
    }

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here the upstream group has been named as backend, which consists of two server configurations.To pass requests to a server group, the name of the group(backend) has been specified in the proxy_pass.&lt;/p&gt;




&lt;h2&gt;
  
  
  Mail context
&lt;/h2&gt;

&lt;p&gt;NGINX can also be used a mail proxy. The "mail" context provides the ability to implement mail proxy.The mail context is defined in global context and outside of http context.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight conf"&gt;&lt;code&gt;&lt;span class="c"&gt;# global  context
&lt;/span&gt;....
....
&lt;span class="c"&gt;# mail context
&lt;/span&gt;&lt;span class="n"&gt;mail&lt;/span&gt; {
     &lt;span class="c"&gt;# mail directive
&lt;/span&gt;     ....
     ....
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  If context
&lt;/h2&gt;

&lt;p&gt;The "if" context provides conditional execution just like if in other programming languages. The if context is provided by the rewrite module and is the primary use of the if context. Since NGINX will test conditions of a request with many other valid directives, the if context should not be used for most forms of conditional execution thus might result in unexpected execution.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight conf"&gt;&lt;code&gt;&lt;span class="n"&gt;http&lt;/span&gt;  {
    &lt;span class="n"&gt;server&lt;/span&gt; {
           &lt;span class="c"&gt;# server context
&lt;/span&gt;           ....
           ....
           &lt;span class="n"&gt;location&lt;/span&gt; &lt;span class="n"&gt;location_match&lt;/span&gt; {
                    &lt;span class="c"&gt;# location context
&lt;/span&gt;                    &lt;span class="n"&gt;if&lt;/span&gt; (&lt;span class="n"&gt;test_condition&lt;/span&gt;) {
                       &lt;span class="c"&gt;# if context
&lt;/span&gt;                       ....
                    }
           }
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Limit_except Context
&lt;/h2&gt;

&lt;p&gt;The "limit_except" context is used to restrict the use of certain HTTP methods within a location context.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight conf"&gt;&lt;code&gt;....
&lt;span class="c"&gt;# location context
&lt;/span&gt;&lt;span class="n"&gt;location&lt;/span&gt; /&lt;span class="n"&gt;restricted&lt;/span&gt;-&lt;span class="n"&gt;write&lt;/span&gt; {
         &lt;span class="c"&gt;# location context
&lt;/span&gt;         &lt;span class="n"&gt;limit_except&lt;/span&gt; &lt;span class="n"&gt;GET&lt;/span&gt; &lt;span class="n"&gt;HEAD&lt;/span&gt; {
                      &lt;span class="c"&gt;# limit_except context
&lt;/span&gt;                      &lt;span class="n"&gt;deny&lt;/span&gt; &lt;span class="n"&gt;all&lt;/span&gt;;
         }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here client requests with GET and HEAD methods from any client will be allowed, but client requests with other methods are denied.  &lt;/p&gt;




&lt;h2&gt;
  
  
  Some Best Practices
&lt;/h2&gt;

&lt;p&gt;1.Declare directives in the highest context to which they are applicable, and overriding them in lower contexts to avoid code replication.&lt;br&gt;
2.Use Multiple Sibling Contexts Instead of If Logic for Processing.&lt;/p&gt;




&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;Now, you have a basic knowledge of nginx.conf file , its structure and core context to create your own conf file. Read &lt;a href="http://nginx.org/en/docs/dirindex.html"&gt;NGINX's documentaion&lt;/a&gt; for more information about NGINX  context.&lt;/p&gt;

</description>
      <category>nginx</category>
      <category>tutorial</category>
      <category>webdev</category>
      <category>server</category>
    </item>
  </channel>
</rss>
