<?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 Vignesh Thirunavukkarasu on Medium]]></title>
        <description><![CDATA[Stories by Vignesh Thirunavukkarasu on Medium]]></description>
        <link>https://medium.com/@vignesh-thirunavukkarasu?source=rss-2e315d8a9499------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*OeRmJIKkzMcafoZYU3IXDQ.jpeg</url>
            <title>Stories by Vignesh Thirunavukkarasu on Medium</title>
            <link>https://medium.com/@vignesh-thirunavukkarasu?source=rss-2e315d8a9499------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 16:21:22 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vignesh-thirunavukkarasu/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[Pyspark Stream processing with Kafka]]></title>
            <link>https://vignesh-thirunavukkarasu.medium.com/pyspark-stream-processing-with-kafka-c216f2181d5c?source=rss-2e315d8a9499------2</link>
            <guid isPermaLink="false">https://medium.com/p/c216f2181d5c</guid>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[elk]]></category>
            <category><![CDATA[pyspark-dataframes]]></category>
            <category><![CDATA[pyspark]]></category>
            <category><![CDATA[spacy]]></category>
            <dc:creator><![CDATA[Vignesh Thirunavukkarasu]]></dc:creator>
            <pubDate>Sun, 23 Apr 2023 21:33:09 GMT</pubDate>
            <atom:updated>2023-04-23T21:33:09.654Z</atom:updated>
            <content:encoded><![CDATA[<p>A detailed example on how to stream process kafka messages, identify Named Entities and visualize Top 10 Entities in Kibana.</p><p><strong>Topics Covered</strong> — PySpark | Kafka Streaming | ELK Dashboard</p><h3><strong>Problem Statement</strong></h3><p><em>Stream reddit comments from a specific subreddit into a Kafka topic (reddit-comments). Pyspark will process the comments by extracting Named Entities and perform a word count of them and push it to another Kafka topic (word-counts). This topic is being consumed by Logstash and messages are converted into JSON format and pushed to ElasticSearch from where we will create a Top 10 word count dashboard in Kibana.</em></p><figure><img alt="High level view of the application" src="https://cdn-images-1.medium.com/max/1024/1*j4HYTwkY-t7XZypfFLZN7Q.png" /><figcaption>High Level view of the application</figcaption></figure><h3>Setup</h3><p>We will setup the below components one by one.</p><ul><li>java</li><li>Kafka</li><li>ELK</li><li>Pyspark</li><li>Streaming Reddit Comments (python producer)</li><li>Process Reddit Comments (pyspark consumer)</li></ul><blockquote><strong>NOTE:</strong> I’ve used specific versions of Pyspark, Kafka &amp; ELK, so please make sure you either use the same version or other compatible versions accordingly.</blockquote><blockquote>All the below setup is done in my local machine. In case you are opting to do this in AWS / GCP, make sure that you have all the necessary ports opened.</blockquote><h4>Install java</h4><p>To install java, I’ve used OpenJdk 1.8 version. Download the package (as dmg) and install it.</p><p><a href="https://www.azul.com/downloads/?version=java-8-lts&amp;os=macos&amp;architecture=arm-64-bit&amp;package=jdk#zulu">Azul Downloads</a></p><p>By default it will be installed in /Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home, So set JAVA_HOME dir the same.</p><pre>export JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home</pre><p>To ensure that the <strong>export</strong> command is applied universally across all processes, it is recommended to include it in the <strong>~/.zshrc</strong> file.</p><h4>Kafka Setup</h4><p>Download <a href="https://downloads.apache.org/kafka/3.4.0/kafka-3.4.0-src.tgz"><strong>Kafka 3.4.0</strong></a> and untar the package in your local directory.</p><p>Start Kafka server and Zookeeper with the below commands</p><pre>bin/zookeeper-server-start.sh config/zookeeper.properties &amp;<br>bin/kafka-server-start.sh config/server.properties &amp;</pre><p>Ensure that the Kafka versions are correct.</p><pre>bin/kafka-topics.sh --version</pre><p>Create two topics (<strong>reddit-comments</strong> &amp; <strong>word-counts</strong>)</p><pre>bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --topic reddit-comments<br>bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --topic word-counts</pre><p>List the topics to confirm if they are created properly</p><pre>bin/kafka-topics.sh --bootstrap-server=localhost:9092 --list</pre><h4>ELK Setup</h4><p>Download the packages for ElasticSearch, Logstash and Kibana and extract them in your local system. I’ve used <strong>#8.7</strong> version</p><ul><li>Kibana: <a href="https://www.elastic.co/downloads/kibana">https://www.elastic.co/downloads/kibana</a></li><li>ElasticSearch: <a href="https://www.elastic.co/downloads/elasticsearch">https://www.elastic.co/downloads/elasticsearch</a></li><li>LogStash: <a href="https://www.elastic.co/downloads/logstash">https://www.elastic.co/downloads/logstash</a></li></ul><p><strong>Disable ElasticSearch SSL</strong> (https is enabled by default) <strong>config/elasticsearch.yml</strong></p><pre>xpack.security.enabled: false<br>xpack.security.http.ssl:<br>  enabled: false</pre><p>For Kibana modify the elasticsearch url from <strong>https </strong>to<strong> http </strong>in<strong> </strong><strong>config/kibana.yml</strong></p><pre>elasticsearch.hosts: [&#39;http://192.168.10.21:9200&#39;]</pre><p>For Logstash create a new config file <strong>logstash.conf. </strong>Input block refers to the input stream (add kafka broker url &amp; topic). Output block is the ElasticSearch url and the index to create and filter converts the string to JSON.</p><pre>input {<br>    kafka {<br>            bootstrap_servers =&gt; &quot;localhost:9092&quot;<br>            topics =&gt; [&quot;word-counts&quot;]<br>    }<br>}<br><br>filter {<br>    json {<br>        source =&gt; &quot;message&quot;<br>    }<br>}<br><br>output {<br>   elasticsearch {<br>      hosts =&gt; [&quot;http://localhost:9200&quot;]<br>      index =&gt; &quot;word-counts&quot;<br>      workers =&gt; 1<br>    }<br>}</pre><h4><strong>Start ELK</strong></h4><p>Make sure you start ElasticSearch first so that kibana and Logstash can connect without any issues.</p><pre>bin/elasticsearch &amp;<br>bin/kibana &amp;<br>bin/logstash -f logstash.conf &amp;</pre><h4><strong>Pyspark Setup</strong></h4><p>Before setting up pyspark, I installed conda to ensure that I have a dedicated environment to avoid conflicting libraries.</p><p><a href="https://docs.conda.io/projects/continuumio-conda/en/latest/user-guide/install/macos.html">https://docs.conda.io/projects/continuumio-conda/en/latest/user-guide/install/macos.html</a></p><p>Install the necessary libs in requirements.txt</p><pre>pip install -r requirements.txt</pre><h3>Let’s talk Code</h3><h4>Python Producer</h4><p><strong>Setting up Reddit API Token</strong></p><p>Reddit needs api token to be setup for streaming comments. I’ve referred to <a href="https://www.geeksforgeeks.org/how-to-get-client_id-and-client_secret-for-python-reddit-api-registration/"><em>this article</em></a> from GeeksforGeeks for step-by-step process of setting up the client_id and client_secret.</p><p>I’ve used <a href="https://praw.readthedocs.io/en/stable/">reddit praw</a> to stream comments from a specific subreddit into Kafka. It takes kafka bootstrap server, kafka topic and subreddit name as input arguments.</p><p>There are two ways to pass the reddit credentials. One is via CLI arguments and other via .env file. You can choose any one of the option.</p><p><strong>.env file sample</strong></p><pre>user_name=<br>password=<br>client_id=<br>secret=</pre><p><strong>Cli based approach</strong></p><pre>python -u comments_producer.py --kafka-topic reddit-comments --bootstrap-server localhost:9092 --subreddit AskReddit --user-name abc --password abc --client-id abc --secret abc</pre><h4>Pyspark Consumer</h4><p>The code is pretty straightforward. Here the messages in the Kafka topic are consumed by Spark application which reads each messages and loads it as a Dataframe object. Then DF filters are applied to extract the Named Entities using <strong>spacy</strong>, remove special characters, empty / null strings and, finally sends the word count of messages to the kafka topic word-counts.</p><pre>spark-submit --packages org.apache.spark:spark-sql-kafka-0-10_2.12:3.1.1 --conf spark.sql.streaming.forceDeleteTempCheckpointLocation=true spark_connector.py --checkpoint-dir /tmp/checkpoint --bootstrap-server localhost:9092 --read-topic reddit-comments --write-topic word-counts</pre><p>Here, I’ve added the package <strong>org.apache.spark:spark-sql-kafka-0–10_2.12:3.1.1 </strong>corresponding to that of the pyspark version used. Update them according to your version.</p><h3>ELK Dashboard</h3><p>Since we have configured the logstash to read messages from kafka topic, it will send those messages to elasticsearch in the specified index.</p><p>In Kibana 8.7 version, I used the discover logs using <a href="https://www.elastic.co/guide/en/elasticsearch/reference/8.7/index-mgmt.html">Index Management</a>. Then, in the <a href="https://www.elastic.co/guide/en/kibana/current/add-aggregation-based-visualization-panels.html">Visualization tab choose aggregation option</a> and bucket the data on the <strong>words keyword</strong>. Finally, customize the total words to be displayed.</p><p>Here is a sample dashboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hUa0YH_yd4NKzSQ8yZcsHA.jpeg" /><figcaption>Top 10 Named Entities from subreddit topic (30 min time window)</figcaption></figure><p>The objective of this is to gain knowledge on a real world use case of PySpark with Kafka streaming. By looking at the count of Named Entities we can we can derive insights on the topics that are actively discussed in the subreddit. This is a simple use case, but the same can be extended to more productive analysis like trying to analyze the stock data based on the discussions on the company by analysing NEWS API’s etc.</p><p>Although it may seem easy to set up at first glance, there are numerous challenges involved in implementing each component, such as ensuring compatibility between Java versions, Spark versions, and running PySpark.</p><p>Additionally, running all these services on a single machine can cause overloading and slow performance. Therefore, I would recommend running Kafka on AWS or GCP, while keeping the remaining components on the local machine.</p><p>The complete project is available on Github for reference.</p><p><a href="https://github.com/vigneshkmr84/Reddit-Comments-Streaming-Word-Count">GitHub - vigneshkmr84/Reddit-Comments-Streaming-Word-Count: Stream Comments from Reddit to Kafka Topic, Streaming NER with PySpark &amp; ELK Visualization of Top 10 Words</a></p><p>-Cheers</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c216f2181d5c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Distributed Tracing setup for Enterprise]]></title>
            <link>https://blog.devgenius.io/distributed-tracing-setup-for-enterprise-dfd680c145c3?source=rss-2e315d8a9499------2</link>
            <guid isPermaLink="false">https://medium.com/p/dfd680c145c3</guid>
            <category><![CDATA[jaegertracing]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[tracing]]></category>
            <category><![CDATA[jaeger]]></category>
            <category><![CDATA[distributed-tracing]]></category>
            <dc:creator><![CDATA[Vignesh Thirunavukkarasu]]></dc:creator>
            <pubDate>Fri, 24 Mar 2023 04:51:32 GMT</pubDate>
            <atom:updated>2024-05-25T18:29:29.171Z</atom:updated>
            <content:encoded><![CDATA[<p>How Jaeger can be used to instrument the problem of distributed tracing in Enterprises</p><h3>What is distributed tracing ?</h3><p>In a microservice architecture, we always want to understand the latency of communication between two services. And, analyse the data to see which service is taking more time, and fine tune it. Also, if at all a failure happens we need to trace the error properly.</p><p><strong>Seems like not a problem right ?</strong></p><p>But think of millions of requests flowing into an ecommerce site during a Black Friday Sale, and a considerable percent of the requests are failing. Imagine the task of the SRE’s and Production Support Engineers, trying to find the root cause of the failing requests, to avoid the company lose the clients.</p><p>Offf… such a simple problem, but creating a catastrophic impact.</p><p>Well, CNCF comes up with — <a href="https://www.jaegertracing.io/">Jaeger</a>, to rescue.</p><h4>What does Jaeger do ?</h4><p>Jaeger simply adds a unique id to the incoming request, called trace id (unique for every request) and the request subsequently calling another service, it will span the original trace with a span id, and consequently creating a hierarchical chain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/864/1*YZ8ENezXL7cfP-VWegifbg.png" /><figcaption>Source : <a href="https://www.jaegertracing.io/docs/1.30/architecture/#span">Jaeger Trace and Span</a></figcaption></figure><p>The setup options that jaeger offers are interesting from a product perspective. First of all, Jaeger comprises of multiple components, that work cohesively together.</p><ul><li><strong>jaeger-client</strong>: Language specific Client libraries added to the services to ingest the data into agents. (it’s not a setup, it works with the service that we write)</li><li><strong>jaeger-agent</strong>: Listens (primarily in UDP) to all the services, and reports the data to collector</li><li><strong>jaeger-collector</strong>: Collects the data from agents and either buffers it to Kafka Topic Or simply persists it to database (ElasticSearch / Cassandra).</li><li><strong>jaeger-ingester</strong>: Needed for advanced setup — to ingest the data from Kafka (used as a temporary buffer) into database.</li><li><strong>jaeger-query</strong>: Query service that’s built to query the data and present in a UI.</li></ul><blockquote>All these modules can be independently deployed as docker containers or can simply use the image is <strong>jaegertracing/all-in-one</strong>, which has all the modules bundled and ready to be deployed and use out of the box.</blockquote><h3>What’s the challenge ?</h3><p>For quick learning and self managed small applications, all-in-one will be fine. However, it causes a single point of failure thereby disrupting the ideology high availability for distributed tracing.</p><blockquote>Using micro-services to solve the problem in microservice.</blockquote><h3>How do we overcome it ?</h3><p>We utilise the modular deployment of jaeger and dedicated persistence layer. Here is one such variant, that could be a best fit for medium to high traffic applications or cluster of smaller applications.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/897/1*a7mApuWhT5lpTYsUMwumng.png" /><figcaption>Medium to high traffic applications. Reference: <a href="https://www.jaegertracing.io/docs/1.30/architecture/#components">Jaeger Architecture</a></figcaption></figure><p>Here the modules — <strong>agent &amp; collector</strong> are the critical components to note for. Client is part of the application service and query is just a wrapper on top of the database to query &amp; visualize the data.</p><p>The client sends the span to agent listening on UDP ports 6831/6832 (<strong>since TCP guarantees the delivery of the packets, which makes it slower</strong>). <em>However, you can configure it to run on TCP as well.</em></p><p>The agent pushes the data to collector, which in turn persists it to storage like Elasticsearch / Cassandra.</p><p>The agent can be configured to push to either one or multiple collectors (on round-robin based) or to a DNS entry that could automatically resolved and load balanced.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/11e0dc1cec88fb2f6716854caedabdd6/href">https://medium.com/media/11e0dc1cec88fb2f6716854caedabdd6/href</a></iframe><h4>Why I prefer Elasticsearch over Cassandra ?</h4><p>Simply because Elasticsearch platform could be extended to ELK Stack (Elasticsearch, Logstash, Beats and Kibana) that could be used to used to aggregate and monitor the logs generated by those microservices. <strong>And Enterprises love using ELK platform given their Scalablity and Resilience</strong>. Additionally, Kibana could be used to cross-cluster multiple elasticsearch nodes as <a href="https://www.elastic.co/guide/en/elasticsearch/reference/7.7/modules-cross-cluster-search.html">referenced here</a>.</p><p>Let’s look at how to configure the clients. Refer to my github repo for the complete example.</p><p><a href="https://github.com/vigneshkmr84/springboot-distributed-tracing">vigneshkmr84/springboot-distributed-tracing</a></p><p>Java (spring boot) dependencies in pom.xml</p><pre>&lt;dependency&gt;<br>   &lt;groupId&gt;io.opentracing.contrib&lt;/groupId&gt;<br>   &lt;artifactId&gt;opentracing-spring-jaeger-cloud-starter&lt;/artifactId&gt;<br>   &lt;version&gt;3.2.0&lt;/version&gt;<br>&lt;/dependency&gt;</pre><p>Also, you might need to configure the Jaeger Tracer and the http Client (RestTemplate / WebClient) as a bean.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/da8cc91990b4a390ae51788f5007de57/href">https://medium.com/media/da8cc91990b4a390ae51788f5007de57/href</a></iframe><blockquote>The above model is perfect for medium to high throughput use cases. The collector and agent nodes could be easily scaled up as the services increases. <strong>However, there could be a bottleneck during data ingestion into the elasticsearch.</strong></blockquote><p>Again, the beauty of Jaeger is designed to overcome this problem subtly. Kafka topic is introduced as a buffer between the collector and agent to store the spans. The agents act as publishers to the topic (which can be partitioned as per scalability needs), and the collector will consume those messages and start ingesting into Elasticsearch. This approach has a controlled ingestion of the data into elasticsearch. <strong>Of course there could be some delay, but it’s manageable to a larger extent.</strong></p><h4>My personal Thoughts</h4><p>The Principal focus of Enterprises lies on consistency and reliability — as these systems will be used by multiple applications including those which are mission-critical and franchise critical. Ideally, the infrastructure will be separate for different regions — APAC, NAM, EMEA &amp; LATAM, to avoid latency issues (even though all networks are on same WAN network). So, be it the Kafka involved setup or just the elasticsearch based setup there needs to be separate infrastructure in every region.</p><p><strong>Another key design factor to consider is how many setups are we gonna do in each region ?</strong></p><p>Because there will always be an upper limit that could throttle the performance of these massive systems. One approach is to have dedicated setup per environment (per region), like one for DEV, SIT, UAT, PRE-PROD &amp; PROD. This approach also gives freedom for the Infra Engineers for upgrading / patch up from lower environment to avoid any unexpected issues in Production.</p><p>As the adoption of Kubernetes has skyrocketed over the past 5 years, Enterprises are also focussed on maintaining these clusters. One more approach it to maintain the tracing setup per cluster, by spinning jaeger related pods on separate namespace. This reduces offloading all the tracing onto a single common instance. However, adds up to over head for development teams to lookup in multiple clusters, if their applications are spanned in multiple cluster. As well, maintenance overhead increases with the increase in number of clusters.</p><p>There are tradeoffs in each approach, and personally I would suggest to separate the services running cluster and the monitoring cluster.</p><p>Note: Jaeger has support for <a href="https://github.com/jaegertracing/jaeger/issues/638">other backend storage</a>.</p><p>-cheers</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dfd680c145c3" width="1" height="1" alt=""><hr><p><a href="https://blog.devgenius.io/distributed-tracing-setup-for-enterprise-dfd680c145c3">Distributed Tracing setup for Enterprise</a> was originally published in <a href="https://blog.devgenius.io/">Dev Genius</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Better way of implementing  JWT]]></title>
            <link>https://vignesh-thirunavukkarasu.medium.com/better-way-of-implementing-jwt-884f0e4fdc88?source=rss-2e315d8a9499------2</link>
            <guid isPermaLink="false">https://medium.com/p/884f0e4fdc88</guid>
            <category><![CDATA[jwt]]></category>
            <category><![CDATA[jwt-authentication]]></category>
            <category><![CDATA[jwt-token]]></category>
            <dc:creator><![CDATA[Vignesh Thirunavukkarasu]]></dc:creator>
            <pubDate>Fri, 17 Mar 2023 08:38:59 GMT</pubDate>
            <atom:updated>2023-03-17T08:38:59.509Z</atom:updated>
            <content:encoded><![CDATA[<h3>Better way of implementing JWT</h3><p><strong>JWT — JSON Web Tokens</strong>, is a simple and easy way used to manage <strong>user roles </strong>for applications.</p><p>JSON Web Tokens are an open, industry standard RFC 7519 method for representing data securely between two parties; Reference : <a href="https://jwt.io/">JWT</a></p><p>A quick recap of how it’s composed of 3 parts, each with a <strong>‘.’</strong> separated.</p><blockquote>eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c</blockquote><ul><li><em>Header</em>: containing the some details about the algorithm</li><li><em>Payload: </em>can be used to load the user profiles data and custom parameters in key-value pairs</li><li><em>Signature:</em> essential to verify the authenticity of the entire token.</li></ul><p>The third part is the most crucial one of the all — since breaking this might spoil everything. My go to approach is always using a <strong>symmetric signature validation</strong>.</p><blockquote>What’s a Symmetric validation ?</blockquote><p>Although the concept of symmetric key encryption was originally proposed by Diffie &amp; Hellman in 1976, but there existed this concept from 1970’s itself as proposed by James Ellis (as part of British Government Communications).</p><p>It’s a way of validation in which a generating system will encode the token with a value and the receiving systems (validating systems) will have a totally different value.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NU2AYaHPJT5W0JVk.jpg" /></figure><p>As you guessed it right, for symmetric validation, <strong>Public-Private Key-Pair</strong> is the best mechanism. Lemme walk through a simple implementation.</p><p><a href="https://github.com/vigneshkmr84/spring-boot-security-jwt">GitHub - vigneshkmr84/spring-boot-security-jwt: Working example of using springboot security and JWT for user authentication and authorization over API&#39;s</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*X8cuRrqr0EOIloP_.jpg" /><figcaption>A Simple Architecture for JWT</figcaption></figure><p>The key components are the login service and other core application service. The login service is a lightweight REST api service that just focuses on authentication and authorization.</p><p>For Authentication — enterprises prefer SSO (Single-Sign-On) and for authorization it’s LDAP (Lightweight Directory Access Protocol), mainly for all internal use cases. For customizations — you can plugin database based authentication and authorizations as well, just a class away from any of the implementation methods. On successful login, a JWT will be sent back to the browser, where it can be stored and re-used for subsequent requests.</p><p><strong>Now, Let’s dig deep on how the core services handle the Token.</strong></p><p>First, we need to write a <a href="https://github.com/vigneshkmr84/spring-boot-security-jwt/blob/master/app-service/src/main/java/org/mylearning/jwtexample/SecurityConfig.java#L54">filter</a> that filters all the incoming requests for the API Context path. It’s configurable to an extent certain context paths can be allowed, while some can be skipped (eg: /health — which needs to be unauthorized during liveness / readiness checks).</p><p>Once the requests are filtered, they need to be checked if they contain the Authorization Bearer Token, as well as their validity (based on the expiry time). If valid they will be passed into the controller else <strong>404 Error</strong> will be thrown back to the client (Browser). The frontend app catches this and can redirect back to the login page.</p><p>There is one security concern “<strong>TOCTTOU”, </strong>which mainly focusses on the time of check and time of use. But this is very negligible as the check and usage within the controller is within a ms latency.</p><p>I’ve given a naive implementation using SpringBoot, but the same can be extended to Nodejs, Golang or other prominent languages as well.</p><p>Cheers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=884f0e4fdc88" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Synthetic Monitoring]]></title>
            <link>https://vignesh-thirunavukkarasu.medium.com/synthetic-monitoring-d20d75123406?source=rss-2e315d8a9499------2</link>
            <guid isPermaLink="false">https://medium.com/p/d20d75123406</guid>
            <category><![CDATA[synthetic-monitoring]]></category>
            <category><![CDATA[monitoring]]></category>
            <dc:creator><![CDATA[Vignesh Thirunavukkarasu]]></dc:creator>
            <pubDate>Tue, 07 Mar 2023 09:05:35 GMT</pubDate>
            <atom:updated>2023-03-07T09:05:35.188Z</atom:updated>
            <content:encoded><![CDATA[<p>A new way of monitoring in Enterprise products and services.</p><p>Apart from Observability, telemetry tracing, performance monitoring the neglected concept of Synthetic Monitoring has started to thrive in DevOps and SRE community.</p><h3>Monitoring the services end-to-end by emulating a user like action.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*B6CXNOC5tpvTBIsA.jpeg" /></figure><p>Consider that I have a web application where the user’s are actively using it with 2000+ TPS during peak hours, and the application is deployed globally in 10+ regions. Given the scale of the application, I take into consideration that all the traditional observability metrics have been setup and actively monitored. But the challenge is, monitoring all these regions is quite challenging for the support team.</p><p>Well, here <strong>Synthetic monitoring</strong> comes with added benefits. By emulating a user action, such as placing an order, we can test features like login, search, adding to cart, and placing an order. This ensures that the application is kept from cold starts and that the core functionalities of the product/service are also tested.</p><p>Moreover, this methodology enables us to inject and measure metrics from Grafana, Prometheus and trigger alerts if there is an abnormality in the latency of operations. This could potentially reduce system failures. Overall, this is a simple but interesting solution to strengthen application monitoring.</p><p>Cheers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d20d75123406" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[mTLS with Apache HTTP server]]></title>
            <link>https://vignesh-thirunavukkarasu.medium.com/mtls-with-apache-http-server-fbfd702106ca?source=rss-2e315d8a9499------2</link>
            <guid isPermaLink="false">https://medium.com/p/fbfd702106ca</guid>
            <category><![CDATA[mutual-tls]]></category>
            <category><![CDATA[tlm]]></category>
            <category><![CDATA[apache-httpd]]></category>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[2-way-ssl]]></category>
            <dc:creator><![CDATA[Vignesh Thirunavukkarasu]]></dc:creator>
            <pubDate>Fri, 21 Jan 2022 18:35:32 GMT</pubDate>
            <atom:updated>2022-01-21T18:35:32.291Z</atom:updated>
            <content:encoded><![CDATA[<p>Understanding mTLS and setting it up with Apache HTTP Web Server</p><h3>What is mTLS ?</h3><p>mTLS or Two way SSL, abbreviation for mutual Transport Layer Security, aims at establishing the authenticity of <strong>both the client and the server to each other</strong>. Original TLS / SSL establishes the identity of the server to the client. In simple terms, the clients also need to authenticate with the server with it’s own certificates.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eNkwowKALH0NRmSR7zW4Ig.png" /><figcaption>mTLS Handshake Steps (between Client &amp; Server)</figcaption></figure><h4>Hows does mTLS work ?</h4><p>It leverages the concept that a certificate can be used as symmetric key pair validation, where one entity can hold the public key, while the other can share the private key and get it validated.</p><p>The Client will provide Root, intermediate &amp; the actual certificate of the client (or generated ) to the server. While the client is making an API call, it needs to provide the private key along with the connection (encrypted with the public key of the server — Refer step 6 from the flow) and if matching, the server authenticates the client. If the client doesn’t provide the certificate, a <strong>403 Forbidden Error </strong>will be thrown. And, if the certificates are not matching then <strong>Handshake Error</strong> is served. The above diagram theoretically showcases all the steps that happen during a call from the client to server. Check out for the end of the blog on how it works.</p><h4>How does mTLS help ?</h4><p>mTLS proves it’s at most necessity, specially in the Cloud Era where security becomes a massive concern. It removes the dependencies in managing passwords (non-symmetric entity) or many-a-times being used alongside with these passwords, so that even if the credentials are compromised <strong>good luck for the attacker to impersonate the certificate</strong>. Additionally, certificates come with a default expiry time and it becomes a mandate to rotate them periodically, while we can not enforce the same for human bound passwords.</p><h4>Benefits of configuring mTLS in a dedicated web-server</h4><p>Spring boot can do this with embedded configuration at the top level where every API’s are being protected.</p><p>I look at this feature more from learning perspective not from a Production implementation because</p><ol><li>Under Spring boot, all API’s become mTLS protected with no exception. If you need to have any set of API’s unprotected, you need to have a separate service altogether.</li><li>In microservices, implementing the same for every services becomes pain and overhead in management. Also, for every service dedicated SSL certificates also needs to be maintained, adding to more overhead.</li><li>Apache HTTP can simply act as a single Entrypoint (similar to API Gateway) with reverse proxy capabilities to every service and we just need to implement the mTLS on Web-Server only.</li></ol><h4>Understanding the Certificate Chain</h4><p>Certificate chain is the list of certificates used to identify the authenticity of the given certificate. Let’s understand this by a scenario — If you are opening a new website first time, the browser will not have the certificate and it will try to verify via it’s parent ( Certificate Authority aka CA) and see if parent is trusted already. If the parent is also trusted, it will check for parent’s parent (essentially grandparent) and goes on. Mostly the CA chain runs upto 2 parents CA’s (<strong>CA root and CA Intermediate</strong>).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/1*CJrE4gPMaapzzZHbxawFcA.jpeg" /></figure><p>Now, this is how an untrusted certificate would look like. The browser naturally doesn’t have this certificate and finds that it’s parent (Root CA) is also not there and so is the warning.</p><p>It can be easily bypassed through adding the certificate to the system. Steps to install certificate: <a href="https://support.securly.com/hc/en-us/articles/360026808753-How-do-I-manually-install-the-Securly-SSL-certificate-on-Windows">Windows</a>, <a href="https://support.securly.com/hc/en-us/articles/206058318-How-to-install-the-Securly-SSL-certificate-on-Mac-OSX-">Mac</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/1*ByqnzPKZAiGgOHgpfpxkPg.png" /><figcaption>google — Certificate Chain</figcaption></figure><p>From given certificate chain it’s evident that <strong>GTS CA 1C3</strong> is the intermediate CA, <strong>GTS Root R1</strong> is the root CA, &amp; google.com has inherited these chains. <br>Note: It’s a wildcard DNS registration.</p><h3>Let’s get hands on….</h3><p>We need a Server SSL certificate, Client SSL Certificate (different cname and details), and will use this to configure Apache HTTP Docker image (<strong>httpd</strong>).</p><blockquote>All the configurations I have done on localhost only.</blockquote><h4>Generating Certificates</h4><blockquote>I followed this <a href="https://www.section.io/engineering-education/how-to-get-ssl-https-for-localhost/">wonderful article on creating SSL Certificate for localhost</a>, and reciprocate the same for the client certificate as well just by changing the extension certificate details.</blockquote><p>If you already have a key pair that’s generated at the enterprise level, then just use the below command to verify if the CA and the certificate are matching properly — (<strong>OK output should be displayed</strong>)</p><pre>openssl verify -verbose -CAfile ../CA.pem localhost.crt</pre><pre><strong>localhost.crt: OK</strong></pre><p>If you use wrong Certificate / Root CA or if Root CA is missing then might possibly <strong>encounter the below Error.</strong></p><pre>cat localhost.crt| openssl verify</pre><pre>stdin: C = UK, ST = London, L = Durham, O = clientorganization, OU = engineering, CN = clientorganization.com, emailAddress = myself@clientorganization.com</pre><pre><strong>error 20 at 0 depth lookup:unable to get local issuer certificate</strong></pre><h4>Configuring Apache HTTP server</h4><p>There are two parts in this configuring:</p><ol><li><strong>httpd.conf</strong> file: We need to to enable configurations from <strong>extras/httpd-ssl.conf</strong> file and enable modules <strong>mod_ssl.so</strong>, <strong>socache_shmcb_module. </strong>(just uncomment these lines)</li><li><strong>extras/httpd-ssl.conf</strong> file:</li></ol><pre><strong>- SSLCACertificateFile</strong> — provide the path of the client’s certificates<br><strong>- SSLVerifyClient</strong> — set to none, to ensure by <strong>default all API’s are unprotected</strong></pre><pre>- Adding the below lines - ie. for /protected endpoint, we need to provide client certificate<br><strong>&lt;Location /protected &gt;</strong></pre><pre><strong>     SSLVerifyClient require</strong></pre><pre><strong>     SSLVerifyDepth 2</strong></pre><pre><strong>&lt;/Location&gt;</strong></pre><pre><strong>- </strong>Changing the server name from <a href="http://www.example.com/"><strong>www.example.com</strong></a> to <strong>localhost</strong><br>- <strong>&lt;VirtualHost _default_:443&gt;</strong> to <strong>&lt;VirtualHost *:443&gt; </strong>for HTTPS<br></pre><p>3. Below is the <strong>Dockerfile</strong> for the same with self explanatory comments.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/82aba4832299713c17dd80c41dd9376a/href">https://medium.com/media/82aba4832299713c17dd80c41dd9376a/href</a></iframe><pre># Docker build <br><strong>docker build -t mtls:1 </strong></pre><pre># Docker run (note it&#39;s exposed in 443 port)<br><strong>docker run -it -p 443:443 mtls:1</strong></pre><h3>Time for Testing…</h3><h4>Using cURL</h4><p>Using curl we just need to pass the certificate and it’s key.</p><p><strong>Here are the list of endpoints to test</strong></p><pre><a href="https://localhost/unprotected/unprotected.html">https://localhost/unprotected/unprotected.html</a><br>https://localhost/protected/confidential.html<br>https://localhost/protected/protected.html<br>https://localhost/main.html<br>https://localhost/health</pre><p><strong>Testing protected endpoint (need to use — cert and — key flag)</strong></p><pre>curl -ivk &quot;https://localhost/protected/protected.html&quot; <strong>--cert</strong> ./incoming-certificate/CA/localhost/localhost.crt <strong>--key </strong>./incoming-certificate/CA/localhost/localhost.decrypted.key</pre><p>Here is the flow of the logs, and <strong><em>lines 44-73 indicate the SSL Handshake between Client and the Server</em>.</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/02058aa402077484d35b3bca5fc8892c/href">https://medium.com/media/02058aa402077484d35b3bca5fc8892c/href</a></iframe><p><strong>Incase you try to access via browser, the below Error is thrown</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2jbRyfXOJEczmHI8_dlbKA.png" /><figcaption>403 Forbidden Error on accessing protected endpoint via browser</figcaption></figure><p>For GUI user’s here’s the setup using Postman,</p><p><a href="https://learning.postman.com/docs/sending-requests/certificates/">Working with certificates</a></p><blockquote>Try using curl in verbose mode as it provides the Handshake details between Client &amp; Server</blockquote><p>Here is the complete work on github (including all the logs)</p><p><a href="https://github.com/vigneshkmr84/mtls-with-apache">vigneshkmr84/mtls-with-apache</a></p><h3>Conclusion</h3><p>Enterprises rely on mTLS for inbound API calls into their <strong>Private Network</strong> (in addition to credentials / oAuth Tokens). And it’s a Golden Standard when Regulator Systems want to communicate, where they prefer this.</p><p>API Gateways in DMZ’s are configured with the <strong>certificate, Root &amp; Intermediate CA’s </strong>for every API’s (or context path). Refer my <a href="https://vignesh-thirunavukkarasu.medium.com/does-api-gateway-really-makes-sense-in-2021-95a50fac6a65">previous blog on API gateway</a>.</p><p>-Cheers</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fbfd702106ca" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How good is uDeploy for Enterprise ?]]></title>
            <link>https://vignesh-thirunavukkarasu.medium.com/how-good-is-udeploy-for-enterprise-1f728d6dd030?source=rss-2e315d8a9499------2</link>
            <guid isPermaLink="false">https://medium.com/p/1f728d6dd030</guid>
            <category><![CDATA[ibm-udeploy]]></category>
            <category><![CDATA[udeploy]]></category>
            <dc:creator><![CDATA[Vignesh Thirunavukkarasu]]></dc:creator>
            <pubDate>Thu, 30 Dec 2021 10:35:53 GMT</pubDate>
            <atom:updated>2021-12-30T10:35:53.775Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>How good is uDeploy for Enterprise ?</strong></h3><p>A overview of uDeploy — a tool for automating application deployments through your environments</p><p>My gosh! Such a powerful tool that I came across. Originally called <strong>Urbancode Deploy</strong>, later acquired by IBM and renamed it to <strong>uDeploy. </strong>It’s a product that could be the end state of a CI / CD process, primarily focussed on deployment of application to servers, public cloud etc. It’s an agent based system, where a small agent (groovy based) runs on the every instance and when a deployment is made, the agent gets notified and the process as defined is executed.</p><p>It can be tailored to fit for various use cases, where the release management <strong>has to happen</strong> in a controller manner and every release has a potential to be audited on necessity of the release (business / tech mandatory / security aspect), who made the release, who approved it.</p><p>To begin with, there are multiple hierarchies — applications, application processes, component, component processes, environment, and other security controls. There are tonnes of role customizations can be incorporated within to follow the <strong>least privilege access </strong>methodology.</p><p>An Application represents the main entity — that’s tagged with the Application ID. Under an application, we can have different environments (like DEV, SIT, UAT, PRE-PROD, PROD, COB etc), and all the processes that you define can be executed on all of the environments (or can be customized not to execute on certain as well).</p><p>A Component Entity is an analogy to a module deployment — say a spring boot war deployment on tomcat / IBM WAS server, or Oracle Database deployment. This is the entity is being tied up with the binary (war / ear / sql files etc), which is built by the CI instances (Jenkins / TeamCity / Circle CI). A comp-process can be as small as stopping a tomcat instance Or can be as big as stop-instance -&gt; deploy the new changes -&gt; start-instance -&gt; perform health check. So, it all depends on the use cases and how modular you would prefer to have the steps. Once the artefact is deployed and successfully tested in lower environment, the same version can be moved to higher environment. It readily follows the concept of <strong>build once and deploy multiple times</strong>.</p><p>An application can also have multiple Application Processes which in turn is a combination of various component processes — which are essentially combines the processes to simplify the deployment. Ex: if you want to have all the modules (database, frontend, backend, config changes) to be deployed at one shot — like One Single Click, you can design it accordingly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/619/0*L4-vXlaF5E_KmagI" /><figcaption>Overview of a Component Process</figcaption></figure><p>Not to forget that we can have configuration variables at every level (component, component process, application &amp; application process as well) — making it much more customizable and writing generic modules for deployment.</p><p>Lemme address on the security metrics as well. We can create various groups, and can map it as per environment — like DEV, SIT, UAT can have a set of approvers (like QA testing team, or SDE-III Developers) while PROD/ COB can be left to application managers Or Production Support Team to approve, as it will be much tightly controller. And for DevOps Engineers — a configuration group is allocated where they get to configure and create the above processes / steps as desired.</p><p>One Amazing feature is it integrates well with the ServiceNow suite, so during a Production Deployment only a valid ticket (in appropriate state) will be executed, making it perfect for auditing.</p><p>Few major setup I have been involved:</p><ul><li>Created a DB Pipeline that could deploy different code (As well same) to 16 different Database instances — all simultaneously, with proper log management and failure tracking for every instance.</li><li>An End-to-End setup for deployment of 300+ java based binaries, 200+ configuration files, 300+ shell scripts.</li></ul><p>And Of Course, It’s truly a <strong>Single-Click-Deployment.</strong></p><p>-cheers</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1f728d6dd030" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Useful Linux Commands for Developers]]></title>
            <link>https://vignesh-thirunavukkarasu.medium.com/useful-linux-commands-for-developers-56b96fe53a93?source=rss-2e315d8a9499------2</link>
            <guid isPermaLink="false">https://medium.com/p/56b96fe53a93</guid>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[commands]]></category>
            <dc:creator><![CDATA[Vignesh Thirunavukkarasu]]></dc:creator>
            <pubDate>Tue, 21 Dec 2021 08:27:20 GMT</pubDate>
            <atom:updated>2022-06-09T03:33:54.136Z</atom:updated>
            <content:encoded><![CDATA[<h3>Advanced Linux Commands for Developers</h3><p>I have curated some of the most useful commands that Software Developers / DevOps Engineers often use.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*wu4wg2qVXXE2u7Z0" /></figure><p>I’m not covering the basic ones like — mkdir, rm, cat, cd, etc. Some medium to advanced commands…</p><h3><strong>grep</strong></h3><pre><em>cat sample.txt | grep -i “TIM”</em></pre><p><em>-i for case ignore</em></p><p><strong><em>Or</em></strong></p><pre><em>grep -i “TIM” sample.txt</em></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MWmpxw0J5lys-N6IRUg-SQ.jpeg" /><figcaption>grep usage</figcaption></figure><p>In case you don’t know the file name, but just a text from a folder full of files, you might want to use this.</p><pre>grep -irw -e &quot;text to find&quot;</pre><p>Note: -n with grep will show the line numbers</p><h3>find</h3><pre><em>find . -type f -name “*.csv” </em></pre><pre><em>#type can be f — folder, d — directory</em></pre><pre><em># exclude name search during find</em></pre><pre><em>find . -type f -not -name &quot;*.csv&quot;</em></pre><h3>awk</h3><p>awk can be used to split a line in a file and process (with delimiter)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u-S_8jhOjYdeU3sqMeJFvw.jpeg" /><figcaption>awk command</figcaption></figure><h3>sed</h3><p>Is a stream editor, can be used to find / replace / insert / delete in a file.</p><h3>netstat</h3><pre><em>netstat -tnpl | grep -i LISTEN</em></pre><p><em>Will help to find the list of Listeners</em></p><h3>lsof</h3><p><em>lsof does a similar to netstat, but we can give specific port and check</em></p><pre><em>lsof -t -i:&lt;port_number&gt; (list of open files)</em></pre><pre><em>lsof -i tcp (list of files opened by network tcp)</em></pre><pre><em>lsof -u &lt;username&gt; (list of files opened by user)</em></pre><pre><em>lsof -I TCP:&lt;port number&gt;</em></pre><h3>cut</h3><p>helps to split a text (line / string level manipulation)</p><pre><em>cat &lt;file&gt; | cut -d (Delimiter) ‘&lt;single_char&gt;’ -f &lt;nth element to cutting&gt;</em></pre><h3>curl</h3><p>used to make API calls to system (REST / SOAP)</p><pre><em>curl -ik “http://localhost:5000/health”</em></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bFwe3p7XL9spmKF5S_CRJw.jpeg" /><figcaption>curl usage</figcaption></figure><p>-k : used to bypass insecure network</p><h3>kill (with SIGNALS)</h3><p>The basics of kill is to simply kill a program running (given a pid).</p><p>Kill can also be used to send SIGNALS (OS Signals). Ex: HUP Signal</p><p>kill -s HUP &lt;pid&gt;</p><p>The above command becomes handy to reload a service without restarting. Can be used to reload, when a configuration has been changed / updated.</p><h3>telnet</h3><p>to check if a remote listener is active on a specific port</p><pre><em>telnet &lt;host_name&gt; &lt;port_no&gt;</em></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LhQUHbls55xEGHjjBJA8PA.jpeg" /><figcaption>telnet usage</figcaption></figure><h3>nslookup</h3><p>Helpful in DNS resolution — especially to check if load balancers are working properly</p><pre><em>nslookup &lt;dns&gt;</em></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/802/1*PPkmFKIOc6dkZ-BVRh3ExA.jpeg" /><figcaption>nslookup usage</figcaption></figure><h3>Array Usage</h3><pre><em>car=(‘BMW’ ‘TOYOTA’ ‘HONDA’ ‘ROVER’)</em></pre><pre><em>echo “${car[@]}” # print all values with space</em></pre><pre><em>echo “${!car[@]}” # print only the indexes</em></pre><pre><em>echo “${#car[@]}” # print the total number available</em></pre><pre><em>echo “${car[1]}” # print value based on index</em></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yYRXt-CFwbP5z7pJRC8tQg.jpeg" /><figcaption>Array usage</figcaption></figure><h3>Looping through file (one line at a time)</h3><pre>for file in `cat sample.txt` do echo $file done </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/408/1*YoDmqjzHGDFjgpWaWX_34Q.jpeg" /><figcaption>Looping through files</figcaption></figure><h3>Machine Stats</h3><pre><em>top</em> — will give the running stats (machine usage)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bXMpzMFImrOmP7CvjQjebA.jpeg" /><figcaption>top command usage</figcaption></figure><pre><em>vmstat </em>— will give the free, swap spaces and other details of CPU &amp; Memory</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K1QZy2Fg2D4PtQJuvXu4dQ.jpeg" /><figcaption>vmstat command</figcaption></figure><h3>Piping</h3><p>Piping helps the output of first command to be used by next one — without using any variables (like a stream)</p><pre>Commonly piped commands —  cat, grep, find, sort, awk</pre><h3>tar Commands</h3><pre># creation of tar file<br>tar -cvf &lt;tar_file_name&gt; &lt;list of files to be compressed&gt;</pre><pre># unzip tar files<br>tar -xvf &lt;tar_file_name&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MZMDPE7T1D316ZeUE-fkSg.jpeg" /><figcaption>tar usage</figcaption></figure><h3>sort</h3><pre><em>cat sample.txt | awk ‘{print $1}’ | sort</em></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U0mC1uQZOm0Enbu7HwwnxA.jpeg" /><figcaption>sort usage</figcaption></figure><h3>reverse-search</h3><p>CTRL + R — and start typing few chars, based on the history the previous commands will be displayed.</p><p>Use CTRL + R to move back and CTRL + F to move next</p><h3>run a script in background</h3><pre><em>nohup /tmp/run.sh &amp;</em></pre><h3><strong>Firewall Commands</strong></h3><pre><em>iptables -F</em></pre><pre><em>iptables -t nat -F</em></pre><pre><em>iptables -t nat -X</em></pre><pre><em>iptables -t mangle -F</em></pre><pre><em>iptables -t mangle -X</em></pre><pre><em>iptables -P INPUT ACCEPT</em></pre><pre><em>iptables -P OUTPUT ACCEPT</em></pre><pre><em>iptables -P FORWARD ACCEPT</em></pre><p><strong>Saving IP Table Rules</strong></p><pre><em>iptables-save &gt; /tmp/firewall.rules</em></pre><pre><em>ip6tables-save &gt; /tmp/firewall6.rules</em></pre><p><strong>Command to kill a process (grep and kill) — single line command</strong></p><pre>ps -elf | grep -i &lt;process&gt; | awk ‘{print $2}’ | xargs kill -9</pre><pre><br># if the process is running on a PORT</pre><pre>lsof -i -P -n | grep LISTEN | grep -i 8080 | awk &#39;{print $2}&#39; | xargs kill -9</pre><p>I’ll try to keep this list updated whenever i find something interesting</p><p>-cheers</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=56b96fe53a93" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Retry, Retry & Retry…]]></title>
            <link>https://vignesh-thirunavukkarasu.medium.com/retry-retry-retry-7ab2b460530b?source=rss-2e315d8a9499------2</link>
            <guid isPermaLink="false">https://medium.com/p/7ab2b460530b</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[retry]]></category>
            <dc:creator><![CDATA[Vignesh Thirunavukkarasu]]></dc:creator>
            <pubDate>Sat, 11 Dec 2021 23:52:39 GMT</pubDate>
            <atom:updated>2021-12-11T23:52:39.388Z</atom:updated>
            <content:encoded><![CDATA[<p>Understanding the retry mechanisms in Software Engineering</p><h3>A quick glance of when and where we need retry mechanisms.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0Hz8W2nkC3a7x0xci0OJ1Q.jpeg" /><figcaption>A standard retry pattern</figcaption></figure><p>Retry is usually needed when one service / client talking to another service / system, and the second system is down or unable to respond <strong>within the time-frame.</strong></p><p>Mostly people talk of microservice retry (as a circuit breaker pattern). However, retry is a crucial element in many places, including db persistence, fetching password from secrets (when the container / VM / EC2 is starting), Messaging bus communications.</p><p>Having said that, the Error codes vary based on the protocol used. If it’s a db/ message bus error — it has a specific Error code, and HTTP calls have the standard 4xx,500 Error codes which the initiating system can catch and act accordingly.</p><p>Now, the golden standard pattern is to have 3 retries with a delay of few seconds between them. Even after the 3 retries the Error repeats, then we log the Error and move ahead.</p><p><strong><em>During HTTP calls, most developers miss to leave out the timeout part from the initiating system. Apparently, I find that this is very critical in system design</em></strong><em>. </em>Because, the API call would simple kill time &amp; resource for the 2nd system, blocking other API calls.</p><p>Now coming to the delay part, It’s a fundamental need that a system needs few seconds to get it’s things sorted out properly if there is an Error. The delay could be an incremental one(+1) or with constant incrementals (+x).</p><p>I recently came across a system where they use Fibonacci based incrementals. I found it to be really interesting usage of the famous series — we don’t need to maintain the count, just the retry max time would suffice.</p><p>Ok. Let’s talk little deeper on where we can apply the retry mechanisms.</p><p>I usually don’t implement retry on authenticating systems — SSO/ LDAP. Also, be very cautious about retry with threading — you need to use thread-safe variables and each threads have their own instance that can track accordingly.</p><p>As pointed out earlier, using a Fibonacci based pattern is good in use cases that are not critically bound on SLA based — Ex: on Backend Jobs(talend/ spark), that have some time relaxation comparatively.</p><p>Final thoughts — I used to work more on SMS based systems and while I used to interact with vendors, they have mentioned that their system will try to retry for 3 times within a particular time and the messages are bound to keep trying for more count, upto 3 days max. I was quite surprised on how much complex this mechanisms would be.</p><p>Once we received 2 SMS instead of 1, when enquired they mentioned that the systems could have done a retry and since they were oversees MSISDN numbers, before the response of the first one was received the 2nd retry would have initiated. This made me to think more on the conditional retry.</p><p>Also — during retries I would prefer to have a different mechanisms (addition to the traditional logging) — like having the data on a In-Memory Cache system from where an API could be exposed and the data can be viewed on why the Error occurred at the first place. As an additional Step, the Production Support team can either rectify the Error and submit again (if at all such a thing is possible).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ksTJLyWU82CbpNKfS2K1Uw.jpeg" /><figcaption>Retry with Error logging on Cache</figcaption></figure><p>On a personal note I haven’t used any external libraries, because they tend to slightly bloat the program.</p><p>-cheers</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7ab2b460530b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Does API-Gateway really makes sense in 2021 ??]]></title>
            <link>https://vignesh-thirunavukkarasu.medium.com/does-api-gateway-really-makes-sense-in-2021-95a50fac6a65?source=rss-2e315d8a9499------2</link>
            <guid isPermaLink="false">https://medium.com/p/95a50fac6a65</guid>
            <category><![CDATA[tlm]]></category>
            <category><![CDATA[api-gateway]]></category>
            <dc:creator><![CDATA[Vignesh Thirunavukkarasu]]></dc:creator>
            <pubDate>Thu, 28 Oct 2021 06:01:54 GMT</pubDate>
            <atom:updated>2021-10-30T06:36:46.604Z</atom:updated>
            <content:encoded><![CDATA[<h3>Does API-Gateway really makes sense in 2021 ??</h3><p>Hmmm… an interesting thought that i had for quiet sometime. After dwelling in the Software architect role for sometime, I have finally realize the utmost use-case for API gateways.</p><p>As a novice developer, I have designed app modules, that run independently on OpenShift without an API gateway. However, after getting involved in some mission critical applications for the organization, I realized the full potential.</p><p>Here are some of the use cases that don’t surface up more often, some are quiet astonishing.</p><p>All the below use cases will make sense in <strong>Enterprise Organizations</strong>.</p><p>Lemme first set the context: In most large scale enterprises, there will be a segregation of the Network zone into primarily 2 Zones : GRN — Green Zone Network &amp; DMZ — Demilitarized Zone (both networks being in the restricted private IP zone only).</p><p>GRN — is where primarily all the normal applications are hosted. These servers don’t have access to internet — both outbound as well as inbound (this is a common practice to prevent any intrusion). ie. in simple terms they are protected by inner firewall.</p><p>DMZ — hosted machines can have access to internet — both inbound / outbound. They are behind the external firewall (or the frontline firewall).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FjL9SwsFHgHGTqHC8-MkIA.jpeg" /><figcaption>A Typical DMZ/ GRN setup for Enterprises — including the API Gateways in DMZ</figcaption></figure><p>If a application in GRN wants to communicate to / from internet — they talk to DMZ (by having the inner firewall IP whitelisted). Now, here is where the API Gateways come into play. Enterprises host a single API Gateway Cluster (Ex: <a href="https://www.ibm.com/products/datapower-gateway">IBM DataPower</a>), spanned across 3–4 data centers in more than 20–30 nodes, and are always on active-active mode.</p><p><strong>Security Concerns: </strong>API Gateways have the power to enable TPS (transactions per second), IP based limits and so on, which is very critical for the enterprises — as these could be the cause for DDOS attacks, if not implemented. They also provide additional authentication layer, mTLS (or two way SSL) which is the frontline authentication for the connection to be established beyond the API Gateway. These features can&#39;t be built on normal app’s we host on nginx / apache http / spring boot etc.</p><p><strong>Versioning:</strong> Another interesting feature is the they provide versioning of API’s which actually don’t happen that efficiently, but if incorporated is an immense tool to control the end user experience, based on the version of OS she/he is running.</p><p><strong>Single Point of Entry: </strong>This concept can be extended to have different API’s for mobile, and browser separately (if needed). Since the authentication module can be of-loaded onto API gateway, the core services become more lightweight and can just start focussing on just the business module. Also, this provides a feature to just change a single place for any security changes, avoiding the overhead on modifying all the backend services.</p><p><strong>LoadBalancing: </strong>The most common use case to provide resiliency for applications, to add more load-balancers pool and finally mapping the API gateway with 3DNS mapping (like Route 53 / F5 network) and using intelligent tiering of routing within the internal load-balancer pools in different data ceners.</p><p>One of an very weird and interesting feature that I have seen implemented is a same set of IP’s have been registered with two different internet facing DNS names and both of them have different set of certificates, and one with 1024 bits and another with 4096 bits. I have Zero clue how the certs part is possible, Mapping the DNS names with IP’s is fine, since they just eventually resolve to the IP’s only.</p><p>However, there is also a catch that they become the single point of failure, so they need to be even more self resilient than the internal applications itself. Nevertheless, if I get a chance to talk to my younger self, I would prefer not to tell him about theAPI gateway, rather let him to realize on his own</p><p>-cheers</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=95a50fac6a65" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to service mesh — istio]]></title>
            <link>https://vignesh-thirunavukkarasu.medium.com/service-mesh-with-istio-in-gcp-part-1-ab88965531a2?source=rss-2e315d8a9499------2</link>
            <guid isPermaLink="false">https://medium.com/p/ab88965531a2</guid>
            <category><![CDATA[istio-service-mesh]]></category>
            <category><![CDATA[istio]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Vignesh Thirunavukkarasu]]></dc:creator>
            <pubDate>Mon, 21 Sep 2020 18:46:31 GMT</pubDate>
            <atom:updated>2020-09-21T20:01:38.825Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction to service mesh — istio</h3><p>In modern era where containers and micro-services are becoming the reality, they also have an overhead of managing the common functionalities like inter service communications spanning between java, node, python / go-lang with diff communication protocols (REST/ gRPCs), mTLS, service discovery, Load-Balancers, etc. The maintenance can be heavily felt for franchise-critical applications where the there are 20+ µservices running with 10’s of pods in each service and every transaction is important for the business.</p><p>Service mesh simply abstracts all the common functions out of the µservices’ and helps developers to just focus on the core business logic. Service mesh can take care of the optics part for Production grade applications like — discovery, load balancing, failure recovery, metrics, and monitoring. It can also perform more funky things like A/B or canary deployments , rate limiting end-to-end authentication (mTLS). Some Popular service mesh are <a href="https://linkerd.io/">linkerd</a>, <a href="https://istio.io/">istio</a>, <a href="https://www.hashicorp.com/products/consul/multi-platform-service-mesh">Consul</a>.</p><p>The popularity of istio is mainly from the fact that it’s developed by Google, IBM &amp; Lyft. Also, it’s predominantly preferred on Kubernetes as a <a href="https://docs.microsoft.com/en-us/azure/architecture/patterns/sidecar">sidecar pattern</a>. Most common design for service mesh is the side-car one; as well spring-cloud provides alternate flavours.</p><figure><img alt="Classical representation of micro-services." src="https://cdn-images-1.medium.com/max/1024/1*tLUJSWCGzEiHXEXwgiO3Iw.png" /></figure><p>Lemme try to explain in simple terms without too much of jargons</p><p>Istio is divided into 2 main components:</p><blockquote><strong>Control plane</strong>: responsible for all the routing, proxies to routes; They also collect data for mesh traffic analysis.</blockquote><blockquote><strong>Service plane</strong>: responsible for injecting sidecar proxy to the pods and managing the service-to-service communications.</blockquote><p>In developer terms, a light weight sidecar proxy (<a href="https://www.envoyproxy.io/docs/envoy/latest/intro/what_is_envoy">Envoy proxy</a>) container is appended to the app container, which handles all the traffic for and between the pods. And ingress gateway manages all the traffic to the application services.</p><h3>What does istio offer ??</h3><p><strong>Traffic management:</strong></p><p>Virtual services, Gateways, mainly help to map the API end points to services.</p><pre>apiVersion: networking.istio.io/v1alpha3<br>kind: VirtualService<br>metadata:<br>  name: reviews<br>spec:<br>  hosts:<br>  - reviews   # kube service to route to (can be IP/FQDN as well)<br>  http:<br>  - match:<br>    - headers:<br>        end-user:<br>          exact: jason</pre><p>Gateway helps to configure the external route</p><pre>apiVersion: networking.istio.io/v1alpha3<br>kind: Gateway<br>metadata:<br>  name: ext-host-gwy<br>spec:<br>  selector:<br>    app: my-gateway-controller<br>  servers:<br>  - port:<br>      number: 443<br>      name: https<br>      protocol: HTTPS<br>    hosts:<br>    - ext-host.example.com<br>    tls:<br>      mode: SIMPLE    # public and private key for HTTPS connection <br>      serverCertificate: /tmp/tls.crt<br>      privateKey: /tmp/tls.key</pre><p><strong>Security</strong></p><p>It’s packed with the most versatile security for different platforms — AWS IAM, GCP service account, Kubernetes service account.</p><p>For Authentication</p><blockquote>peer-to-peer Auth: mTLS (2 way SSL). STRICT/PERMISSIVE/DISABLE</blockquote><blockquote>Request Auth: JSON Web tokens and common Open ID providers (Auth0, FireBase, GoogleAuth etc.).</blockquote><p><strong>Observability</strong></p><p>Telemetry collected by istio can be used to analysis the application behaviour, debug &amp; optimize the service calls.</p><p>Metrics: proxy-level, service-level &amp; control panel metrics are collected.</p><p>Access Logs: Istio generates full record of each request which can be used for analysis</p><p>Distributed Tracing: Monitoring individual requests, latency with each service throughout the mesh. Istio is compatible to be plugged for distributed tracing with popular backend tools like Zipkin, Kiali, Jaeger.</p><p>Reference: <a href="https://istio.io/latest/docs">https://istio.io/latest/docs</a></p><p>To be continued…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ab88965531a2" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>