<?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 Satya Sai on Medium]]></title>
        <description><![CDATA[Stories by Satya Sai on Medium]]></description>
        <link>https://medium.com/@gsatyasai2008?source=rss-e300d0c9292b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*fksv7_-cOY7FOWK7</url>
            <title>Stories by Satya Sai on Medium</title>
            <link>https://medium.com/@gsatyasai2008?source=rss-e300d0c9292b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 20:22:28 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gsatyasai2008/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[Exploring High-Performance Connection Pooling in Java using Hikari Pool]]></title>
            <link>https://medium.com/@gsatyasai2008/exploring-high-performance-connection-pooling-in-java-using-hikari-pool-693c1d4a68d?source=rss-e300d0c9292b------2</link>
            <guid isPermaLink="false">https://medium.com/p/693c1d4a68d</guid>
            <category><![CDATA[connection-pool]]></category>
            <category><![CDATA[high-performance]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[hikari]]></category>
            <category><![CDATA[hikaricp]]></category>
            <dc:creator><![CDATA[Satya Sai]]></dc:creator>
            <pubDate>Fri, 31 Mar 2023 06:30:14 GMT</pubDate>
            <atom:updated>2023-03-31T06:30:14.849Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Introduction:</strong><br>HikariCP is a lightweight, high-performance JDBC connection pool . It is known for its ability to provide fast, reliable connections to databases while minimizing the overhead on system resources. In this blog, we’ll take a look at how to use HikariCP in Java.</p><p><strong>What is a Connection Pool?</strong></p><p>Before diving into HikariCP, let’s first understand what a connection pool is. A connection pool is a cache of database connections that can be reused by multiple client requests. Instead of creating a new database connection for each request, a connection pool provides a mechanism to reuse existing connections, which can significantly reduce the overhead of establishing and tearing down connections.</p><p><strong>Why HikariCP?</strong></p><p>HikariCP is a high-performance connection pool that is specifically designed for modern Java applications. It was created to address some of the limitations of other connection pools, such as slow initialization time, high resource usage, and low throughput.</p><p><strong>Here are some of the key features of HikariCP:</strong></p><p><strong>Lightweight and Fast</strong><br>HikariCP is a lightweight pool that has a small memory footprint and minimal dependencies. It is also designed to be fast and efficient, with low overhead for connection acquisition and release.</p><p><strong>High Throughput</strong><br>HikariCP is optimized for high throughput and low latency. It achieves this by using a highly concurrent and lock-free algorithm that reduces contention and maximizes throughput.</p><p><strong>Configuration Flexibility</strong><br>HikariCP offers a wide range of configuration options that can be customized to meet the specific requirements of your application. For example, you can configure the minimum and maximum number of connections, the connection timeout, and the idle timeout.</p><p><strong>Monitoring and Diagnostics</strong><br>HikariCP provides comprehensive monitoring and diagnostics features that can help you troubleshoot performance issues. For example, you can monitor the pool utilization, the number of active connections, and the connection wait time.</p><p><strong>Steps to add and configure Hikari pool in our application</strong></p><p>Step 1: Add HikariCP dependency to your project:<br>To use HikariCP in your Java project, you first need to add the HikariCP dependency to your project’s build file (pom.xml in case of Maven project or build.gradle in case of Gradle project). Here is how you can add HikariCP dependency to a Maven project.</p><blockquote>&lt;dependency&gt;<br> &lt;groupId&gt;com.zaxxer&lt;/groupId&gt;<br> &lt;artifactId&gt;HikariCP&lt;/artifactId&gt;<br> &lt;version&gt;4.0.3&lt;/version&gt;<br>&lt;/dependency&gt;</blockquote><p>Step 2: Create a HikariDataSource object:<br>To create a HikariDataSource object, you need to provide a set of configuration parameters. These parameters include the JDBC URL, username, password, maximum pool size, minimum idle connections, and so on. Here’s an example of how to create a HikariDataSource object:</p><blockquote>Java Code Snippet<br>HikariConfig config = new HikariConfig();<br>config.setJdbcUrl(“jdbc:mysql://localhost:3306/mydatabase”);<br>config.setUsername(“username”);<br>config.setPassword(“password”);<br>config.setMaximumPoolSize(10);<br>config.setMinimumIdle(5);</blockquote><blockquote>HikariDataSource dataSource = new HikariDataSource(config);<br>Step 3: Use the HikariDataSource object to get a connection:<br>Now that you have created a HikariDataSource object, you can use it to get a connection to the database. Here’s an example of how to get a connection:</blockquote><blockquote>Java Code Snippet<br>Connection connection = dataSource.getConnection();<br>Statement statement = connection.createStatement();<br>ResultSet resultSet = statement.executeQuery(“SELECT * FROM users”);</blockquote><blockquote>while(resultSet.next()) {<br> // Process the results<br>}</blockquote><p>Step 4: Configure HikariCP using properties file:<br>You can also configure HikariCP using a properties file. To do this, you need to create a file named “hikari.properties” in your project’s classpath and add the configuration properties to it. Here’s an example of how to configure HikariCP using a properties file:</p><p>Hikari Configuration via file</p><p>jdbcUrl=jdbc:mysql://localhost:3306/mydatabase<br>username=username<br>password=password<br>maximumPoolSize=10<br>minimumIdle=5<br>Then, you can create a HikariDataSource object by passing the properties file name to the HikariConfig object’s setDataSourceProperties() method:</p><p>Java Code Snippet</p><blockquote>HikariConfig config = new HikariConfig(“hikari.properties”);<br>HikariDataSource ds = new HikariDataSource(config);</blockquote><p><strong>Conclusion:</strong><br>HikariCP is a fast and reliable JDBC connection pool that can greatly improve the performance of your Java application. In this blog, we have seen how to use HikariCP in Java by adding its dependency to your project, creating a HikariDataSource object, getting a connection from it, and configuring it using a properties file. By following these steps, you can take advantage of HikariCP’s performance benefits and improve the scalability of your application.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=693c1d4a68d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Basics of HAProxy]]></title>
            <link>https://medium.com/@gsatyasai2008/the-basics-of-haproxy-554c26992836?source=rss-e300d0c9292b------2</link>
            <guid isPermaLink="false">https://medium.com/p/554c26992836</guid>
            <category><![CDATA[caching]]></category>
            <category><![CDATA[proxy-server]]></category>
            <category><![CDATA[load-balancing]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[haproxy]]></category>
            <dc:creator><![CDATA[Satya Sai]]></dc:creator>
            <pubDate>Tue, 08 Mar 2022 08:04:31 GMT</pubDate>
            <atom:updated>2022-03-08T08:04:31.209Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/630/1*Q90QEjgQtbzSl9fb0hr28Q.png" /><figcaption>HAProxy Simple Architecture Diagram</figcaption></figure><p><strong>A brief about HAProxy:</strong></p><p>HAProxy is a free, open source load balancer and proxy server. It can be used to distribute TCP and HTTP traffic to multiple servers and to cache static content.</p><p>HAProxy is very dynamic and can handle a high volume of traffic. It can also act as a reverse proxy, caching HTTP responses from the backend servers to improve performance.It can optimize the resource usage and improve performance.</p><p><strong>Installing and Configuring HAProxy :</strong></p><p>The process of installation and configuring HAProxy can be done very easily by following the below steps.</p><ul><li>Installing HAProxy:</li></ul><p>HAProxy package is available under the default yum repository for the linux systems. The followig command needs to be used to install HAProxy in our system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/1*-SKbE3IrFFRyQEzqfLhwWw.png" /><figcaption>Install HAProxy</figcaption></figure><ul><li>&gt; Configuring HAProxy:</li></ul><p>The HAProxy configuration file is present in the following path: <strong>/etc/haproxy/haproxy.cfg</strong></p><p>Upon execution of the following command the configuration file opens .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/453/1*QYrPCOOl1xsW5bBm2TTJHQ.png" /><figcaption>Open Configuration file</figcaption></figure><p>Once the configuration file is opened it needs to be modified according to our requirement . The configuration file looks like the following</p><pre>global<br>        log 127.0.0.1   local0<br>        log 127.0.0.1   local1 debug<br>        maxconn   45000 # Total Max Connections.<br>        daemon<br>        nbproc      1 # Number of processing cores.<br>defaults<br>        timeout server 86400000<br>        timeout connect 86400000<br>        timeout client 86400000<br>        timeout queue   1000s<br><br># [HTTP Site Configuration]<br>listen  http_web <strong>192.168.10.10:80</strong><br>        mode http<br>        balance roundrobin  # Load Balancing algorithm<br>        option httpchk<br>        option forwardfor<br>        server server1 <strong>192.168.10.100:80</strong> weight 1 maxconn 512 check<br>        server server2 <strong>192.168.10.101:80</strong> weight 1 maxconn 512 check<br><br># [HTTPS Site Configuration]<br>listen  https_web <strong>192.168.10.10:443</strong><br>        mode tcp<br>        balance source# Load Balancing algorithm<br>        reqadd X-Forwarded-Proto: http<br>        server server1 <strong>192.168.10.100:443</strong> weight 1 maxconn 512 check<br>        server server2 <strong>192.168.10.101:443</strong> weight 1 maxconn 512 check</pre><pre>#Update values marked in <strong>BOLD </strong>corresponding to setup</pre><p>Now we have to change the IPs in configuration file as per our network setup. In HTTP Site Configuration section if any request comes on IP 192.168.10.10 on port 80, this will be redirected to port 80 of 192.168.10.100 or 192.168.10.101 servers. Similarly in HTTPS Site Configuration if any request on ip 192.168.10.10 on port 443, this will be redirected to port 443 of 192.168.10.100 or 192.168.10.101 servers.</p><p>We also need to make a few changes in the configuration file as per your system configuration.</p><ul><li>nbproc &lt;value&gt; # Number of processing cores in our system.</li><li>mode &lt;value&gt; # ‘http’ for http site and ‘tcp’ for https site</li><li>balance &lt;value&gt; # Type of load balancing like ‘source’, ’roundrobin’ etc.</li></ul><p><strong>HAProxy Load Balancng based on URL</strong>:</p><p>But in case the application is a REST api or incase if we need to do the load balancing based on URL , then the above configuration would be a limitation , hence we need to add the following configuration .</p><p>Lets imagine the network setup as follows:</p><ul><li>HAProxy Server: 192.168.1.90</li><li>WEB1 : 192.168.1.103</li><li>WEB2 : 192.168.1.105</li><li>Domain: testHAproxy.com</li></ul><p>So here HAProxy ACL comes nto action .The below example includes ACL for url_beg. url_beg matches the string used in url submitted. Using the url all requests starting with /path1 ( testHAproxy.com/path1 ) will redirect to WEB2 ( 192.168.1.105 ) Server. All other requests will redirect to one of two server ( WEB1, WEB2 ), depending on load balancing algorithm used.</p><p>The configuration would be as follows:-</p><pre>global<br>    log 127.0.0.1 local0 notice<br>    maxconn 50000<br>    daemon<br>defaults<br>    log global<br>    mode http<br>    option httplog<br>    option dontlognull<br>    contimeout 120000<br>    clitimeout 120000<br>    srvtimeout 120000<br>    option forwardfor<br>    option http-server-close<br><br># Configuration for HTTP site<br>frontend http-in<br>    bind 192.168.1.90:80<br>    acl is_path1 url_beg  /path1<br>    use_backend testHAProxy_path1 if is_path1<br>    default_backend HAProxy_website<br><br>backend testHAProxy_path1<br>    mode http<br>    balance roundrobin  # Load Balancing algorithm<br>    option httpchk<br>    option forwardfor<br>    server WEB2 192.168.1.105:80 weight 1 maxconn 512 check<br><br>backend HAProxy_website<br>    mode http<br>    balance roundrobin  # Load Balancing algorithm<br>    option httpchk<br>    option forwardfor<br>    server WEB1 192.168.1.103:80 weight 1 maxconn 512 check<br>    server WEB2 192.168.1.105:80 weight 1 maxconn 512 check</pre><p><strong>Starting HAProxy:</strong></p><p>Now the following command needs to be used for starting HAProxy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/546/1*-lOt_Z9EqBwraBs6hPzVNQ.png" /><figcaption>Start HAProxy.</figcaption></figure><p><strong>Enabling HAProxy Stats:</strong></p><p>A lot of information regarding data transfer, total connection, server state etc can be found using the HAProxy statistics. For enabling stats we should edit our HAProxy configuration file and add below entries in the defaults section.</p><pre>listen  stats   192.168.10.10:1936<br>        mode            http<br>        log             global<br><br>        maxconn 10<br><br>        clitimeout      100s<br>        srvtimeout      100s<br>        contimeout      100s<br>        timeout queue   100s<br><br>        stats enable<br>        stats hide-version<br>        stats refresh 30s<br>        stats show-node<br>        stats auth admin:password<br>        stats uri  /haproxy?stats</pre><p><strong>Accessing the stats:</strong></p><p>We can access the stats using the following URL. We should use our server ip address followed by <strong>stats uri</strong> in above configuration. Use login details configured with <strong>stats auth</strong> in configuration file.</p><p>So now according to the above added configuration , the stats can be viewed by accessing the following url with the credentials mentioned .</p><pre>URL: http://192.168.10.10:1936/haproxy?stats<br> Login user: admin<br> Login password: password</pre><p><strong>Conclusion:</strong></p><p>So now by following all the above steps we can install, configure and setup HAProxy load balancing for our applications and improve the performance in a reliable way.</p><p><strong>References:</strong></p><ul><li><a href="https://www.haproxy.org/">https://www.haproxy.org/</a></li><li><a href="https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/load_balancer_administration">https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/load_balancer_administration</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=554c26992836" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>