<?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 Jinia Konar on Medium]]></title>
        <description><![CDATA[Stories by Jinia Konar on Medium]]></description>
        <link>https://medium.com/@jinia.konar?source=rss-8fdf4f29301b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*zWdIfl3ez_lvg5oo1OoHGg.jpeg</url>
            <title>Stories by Jinia Konar on Medium</title>
            <link>https://medium.com/@jinia.konar?source=rss-8fdf4f29301b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 22:04:58 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jinia.konar/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[Balancing Passion, Pressure, and Peace: A Journey of Saying No Without Guilt]]></title>
            <link>https://medium.com/@jinia.konar/balancing-passion-pressure-and-peace-a-journey-of-saying-no-without-guilt-fb5351ec4b90?source=rss-8fdf4f29301b------2</link>
            <guid isPermaLink="false">https://medium.com/p/fb5351ec4b90</guid>
            <category><![CDATA[work-life-balance]]></category>
            <category><![CDATA[personal-growth]]></category>
            <category><![CDATA[women-in-tech]]></category>
            <category><![CDATA[overwhelm]]></category>
            <category><![CDATA[productivity]]></category>
            <dc:creator><![CDATA[Jinia Konar]]></dc:creator>
            <pubDate>Wed, 30 Jul 2025 05:15:39 GMT</pubDate>
            <atom:updated>2025-07-30T05:15:39.919Z</atom:updated>
            <content:encoded><![CDATA[<h4>A personal reflection on juggling career, passion, family, and societal expectations — and learning that it’s okay to not do it all.</h4><blockquote>Being everything for everyone comes with a cost — sometimes that cost is yourself.</blockquote><p>I’m a software engineer by profession and a classical dancer by passion. Two identities I cherish, both close to my heart, yet both demanding in their own ways.</p><figure><img alt="Classical Dancer, the artist within me — always alive, always expressive." src="https://cdn-images-1.medium.com/max/1024/1*_1fCCfXvpaitMcxN71CCqA.png" /><figcaption>The artist within me — always alive, always expressive.</figcaption></figure><p>Some days, when dance takes center stage — perhaps an upcoming performance or rehearsals piling up — I find myself stretched thin. Because it’s never <strong>just</strong> about dance or <strong>just</strong> about work.</p><h4>🌪️ The Chaos of Doing It All</h4><p>There are days when I wake up with a long checklist screaming for attention:</p><ul><li>A critical office deadline I need to meet (because that promotion won’t wait).</li><li>A dance show I must prepare for — giving anything less than 100% isn’t an option.</li><li>Household chores and responsibilities waiting silently in the background.</li><li>Parents who need support and expect me to be available.</li><li>A younger brother who looks up to me for guidance.</li><li>Marriage conversations I need to entertain because <strong>it’s time.</strong></li></ul><p>All this, within 24 hours. Every single day.</p><figure><img alt="Modern Indian Woman Managing Multiple Roles, Trying to carry everything with a smile — but it’s not always easy." src="https://cdn-images-1.medium.com/max/1024/1*nw9IlkSuanQ4NyDXO40jmQ.png" /><figcaption>Trying to carry everything with a smile — but it’s not always easy.</figcaption></figure><p>And I try. I try to be perfect in every role. To not disappoint anyone. To be that dependable daughter, sister, colleague, artist. But in that attempt to be everything to everyone, sometimes I lose sight of <strong>myself</strong>.</p><h4>🛤️ Life at a Crossroads</h4><p>There are moments when I pause and wonder —</p><blockquote>Am I doing enough? Or am I just drowning slowly, silently?</blockquote><p>That self-doubt creeps in, whispering, <strong>You’re failing somewhere.</strong></p><figure><img alt="Forked Road with Life Choices. Each direction demands something — which one should I walk today?" src="https://cdn-images-1.medium.com/max/1024/1*s7B2_aHtEMKKsDqQYrnOSg.png" /><figcaption>Each direction demands something — which one should I walk today?</figcaption></figure><p>But here’s the truth I’ve come to embrace recently — <strong>it’s okay to step back.</strong><br>It’s okay to not be perfect at everything. <br>It’s okay to say,</p><blockquote>I can’t take this on right now.</blockquote><p>Because at the end of the day, it’s <em>my body</em>, <em>my mind</em>, and <em>my energy</em> that are on the line. No one else truly understands the weight I carry.</p><p>My parents care deeply, and they do try to help in many situations — emotionally, practically, and with advice. I’m grateful for that. But at the end of the day, it’s <strong>my</strong> life. It’s <strong>my</strong> set of struggles, my inner battles. Their generation faced a different world with different challenges.</p><p>My friends try to understand too, but only I know what it feels like to live <strong>my</strong> version of this journey.</p><figure><img alt="Cozy Workspace with Laptop, Ghungroo, Planner. This is my world — code and creativity side by side. Coffee. Dance. Deadlines." src="https://cdn-images-1.medium.com/max/1024/1*s1IxZXQ2F8lNTHi-WrzjWQ.png" /><figcaption>This is my world — code and creativity side by side. Coffee. Dance. Deadlines.</figcaption></figure><p>So if you’re like me — trying to juggle too many things, trying not to let anyone down, trying to hold it all together — hear me out:</p><blockquote>You don’t have to give 100% to everything, all the time. You are allowed to pause. To prioritize. To protect your peace.</blockquote><p>If someone else can take over something you’re carrying, let them. <br>If not, it can wait.</p><h4>💬 A Note to You</h4><p><em>You matter. Your well-being matters.</em><br>And sometimes, the bravest thing you can do is to say:</p><blockquote>No, not right now.</blockquote><p>I’m learning this every day, and I’d love to hear from others walking the same tightrope.</p><h4>📣 Your Turn</h4><p>💬 <strong>How do you manage the chaos? How do you balance everything on your plate?</strong><br>Let’s talk. Let’s normalize <strong>not doing it all</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fb5351ec4b90" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Rate limiter and its algorithms with illustrations]]></title>
            <link>https://tech.groww.in/rate-limiter-and-its-algorithms-with-illustrations-564455162935?source=rss-8fdf4f29301b------2</link>
            <guid isPermaLink="false">https://medium.com/p/564455162935</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[rate-limiting]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[backend]]></category>
            <dc:creator><![CDATA[Jinia Konar]]></dc:creator>
            <pubDate>Mon, 04 Jul 2022 11:17:17 GMT</pubDate>
            <atom:updated>2025-04-21T06:55:42.934Z</atom:updated>
            <content:encoded><![CDATA[<p><em>At times when there is lot of traffic on our system either</em> <em>resources exhausts or need to increase servers to fulfil requests. At this point Rate Limiter is the saviour, let’s talk about this in depth over here.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*Eq7D74k9V4xBabnL" /></figure><h3>What is a Rate Limiter?</h3><p>A rate limiter controls the amount of traffic sent by a client or service in a network system. It limits the number of client requests allowed to be sent over a specified period. If the number of API requests exceeds the rate limiter’s threshold, all extra calls are denied.</p><p>Above we saw a use-case and a benefit of rate limiter, there are many other benefits as well:-</p><ul><li>Prevent resource starvation caused by <a href="https://www.paloaltonetworks.com/cyberpedia/what-is-a-denial-of-service-attack-dos">Denial of Service (DoS)</a> attack.</li><li>Excess requests are limited, which means fewer servers are needed and more resources are allocated to high-priority APIs.</li><li>Ensure that servers are not overburdened. A rate limiter is used to reduce server load by filtering out excessive requests caused by bots or user misbehaviour.</li></ul><p>In this blog we will discuss few rate limit algorithms and try to come up with a solution for distributed, scalable system.</p><p>A rate limiter implementation can be client side or server side, but there is an alternate way. Instead of putting a rate limiter at the API servers, we can create a rate limiter middleware, which throttles requests to our APIs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S2j8bKGbnhX95PeTa_eaqQ.png" /><figcaption>Rate Limiter as a middleware</figcaption></figure><h3>Algorithms for rate limiting</h3><h4>1. Token bucket</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L1cen64uaVqu9n3p2o3pOg.png" /><figcaption>Token bucket algorithm</figcaption></figure><p>A token bucket is a container with a pre-defined capacity b. At pre-set intervals r token/sec, tokens are dropped in the bucket. No additional tokens are added to the bucket once it is full. For example, the token bucket capacity is 4 above. Every second, the refiller adds 1 token to the bucket. Extra tokens will overflow once the bucket is full. <br>• We take 1 token out for each request and if there are enough tokens, then the request is processed.<br>• The request is dropped if there aren’t enough tokens.</p><p>Generally it is recommended that each unique api endpoint, unique id to have a bucket associated with it.</p><p>Pros: <br>1. The algorithm is easy to implement and memory efficient.<br>2. Token bucket allows a burst of traffic for short periods. As long as there are tokens left, a request can be processed.</p><p>Cons:<br>1. It requires the tuning of two parameters, which may be difficult to achieve.<br> <em>• Bucket size: the maximum number of tokens allowed in the bucket <br> • Refill rate: number of tokens put into the bucket every second.<br></em>Let’s find out if we can get rid of two parameters by using some other algorithm.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*6TXwQB5iV1Ee2QWMJzSm-A.jpeg" /></figure><h4>2. Leaking bucket</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bFRtmNn6OA93VD8PPyQARg.png" /><figcaption>Leaking Bucket algorithm</figcaption></figure><p>It is almost similar to token bucket algorithm but here requests are pulled from the queue and processed at a fixed rate. A first-in-first-out (FIFO) queue is used. When a request arrives, the system checks if the queue is full, if not then the request is added to the queue else, the request is dropped.</p><p>Pros:<br>1. Memory efficient given the limited queue size.<br>2. Because requests are handled at a fixed rate, it is appropriate for use cases that require a consistent outflow rate.</p><p>Cons:<br>1. If a surge of traffic fills the queue with old requests, recent requests will be rate limited if they are not processed in a timely manner.<br>2. Response to the request is asynchronous due to queue.<br>3. It also requires the tuning of two parameters:-<br> <em>• Bucket size: it is equal to the queue size.<br> •Outflow rate: it defines how many requests can be processed at a fixed rate, usually in seconds.</em></p><h4>3. Fixed window counter</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RB_aQCir6gOcayaA_f0ahA.png" /><figcaption>Fixed window counter algorithm</figcaption></figure><p>This algorithm divides the timeline into fix-sized time windows and assign a counter for each window. Each request increments the counter by 1. Once the counter reaches the pre-defined threshold, new requests are dropped until a new time window starts. For example, the time unit above is 1 minute, and the system allows just 3 requests per minute, thus if more than 3 requests are received, the extra requests are dropped.</p><p>Pros:<br>1. Memory efficient and easy to understand.<br>2. Resetting the counter at the end of a unit time window fits certain use cases.</p><p>Cons:<br>1. One major problem with this algorithm is that there can be burst of traffic at the edges of time windows which may allow more request in a particular time frame. For example, the system allows a maximum of 3 requests / minute, and the counter resets to the round minute. There are 3 requests between [2:00:00–2:00:59), and 3 more between [2:01:00–2:01:59), as you can see below. Total of 6 requests are processed in the one-minute period between [2:00:29–2:01:29), which is twice the maximum allowed. 😓</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/990/1*dJX5SdMPXmsvd0rx3neiag.png" /><figcaption>Problem with fixed window counter algorithm</figcaption></figure><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Fj8nXhJ1fJM0wg%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Freaction-week-everyone-j8nXhJ1fJM0wg&amp;image=https%3A%2F%2Fmedia3.giphy.com%2Fmedia%2Fj8nXhJ1fJM0wg%2Fgiphy.gif%3Fcid%3D790b761180db0427ef2bbbd8d0c52f31a5b25abb5c9a71bb%26rid%3Dgiphy.gif%26ct%3Dg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/90f90ebc253e23bcfbe369a4d38fb78e/href">https://medium.com/media/90f90ebc253e23bcfbe369a4d38fb78e/href</a></iframe><h4>4. Sliding window log</h4><p>Sliding window log algorithm keeps a log of request timestamps for each user (Generally redis sorted sets are used for this). When a request comes, we first remove all outdated timestamps before inserting the new request time to the log. Then we decide whether this request should be processed depending on whether the log size has exceeded the limit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QxTa-NyLf5rE_UbXSutHpg.png" /><figcaption>Sliding window log algorithm</figcaption></figure><p>For example above, let us allow 2 requests/minute, the log is empty when a new request arrives at 1:00:01. Thus, the request is processed with size = 1. A new request arrives at 1:00:30, the timestamp 1:00:30 is inserted into the log with size = 2, not larger than the allowed count, thus, the request is processed. A new request arrives at 1:00:50, and the timestamp is inserted into the log with size = 3, larger than the allowed size 2. Therefore, this request is rejected even though the timestamp remains in the log. A new request arrives at 1:01:40. Requests in the range [1:00:40–1:01:40) are within the latest time frame, but requests sent before 1:00:40 are outdated. Two outdated timestamps, 1:00:01 and 1:00:30, are removed from the log with size = 2, allowed size, therefore, the request is processed.</p><p>Pros: <br>1. The advantage of sliding window log over fixed window counter is that, instead of ensuring an average rate within each window, it provides a more accurate rate limit because the window boundary is dynamic instead of fixed.</p><p>Cons: <br>1. Memory footprint is an issue here because even if a request is rejected, its timestamp might still be stored in memory.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FA3bQqTg0OxlQ6gbOOe%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fquixyofficial-hooray-hurray-wohoo-A3bQqTg0OxlQ6gbOOe&amp;image=https%3A%2F%2Fmedia0.giphy.com%2Fmedia%2FA3bQqTg0OxlQ6gbOOe%2Fgiphy.gif%3Fcid%3D790b76111fe05922528c62889313df69df023d943718a94d%26rid%3Dgiphy.gif%26ct%3Dg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/7cae705d1ca5ee6f8ee1903520f0de27/href">https://medium.com/media/7cae705d1ca5ee6f8ee1903520f0de27/href</a></iframe><p>We came very well together till here!! But there is another more important algorithm <strong>Sliding window counter (also known as rolling-rate-limiter). </strong>This algorithm combined with redis sorted sets is mostly used for scalable and distributed systems.</p><p>I have explained <strong>Sliding window counter </strong>in detail with sample project <a href="https://medium.com/@jinia.konar/rate-limiter-for-distributed-and-scalable-system-4a350ee1bb8a">here</a>.</p><p><a href="https://medium.com/@jinia.konar/rate-limiter-for-distributed-and-scalable-system-4a350ee1bb8a">Medium</a></p><p>If you’ve enjoyed this story, please click the 👏 button and share it, to help others find it as well. Also, feel free to leave a comment below.😁</p><p>Groww Engineering publishes technical anecdotes, latest technologies, and better ways to tackle common programming problems. You can subscribe <a href="https://medium.com/@groww">here</a> to get the latest updates.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=564455162935" width="1" height="1" alt=""><hr><p><a href="https://tech.groww.in/rate-limiter-and-its-algorithms-with-illustrations-564455162935">Rate limiter and its algorithms with illustrations</a> was originally published in <a href="https://tech.groww.in/">The Groww Engineering Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Rate Limiter for a distributed and scalable system.]]></title>
            <link>https://tech.groww.in/rate-limiter-for-a-distributed-and-scalable-system-4a350ee1bb8a?source=rss-8fdf4f29301b------2</link>
            <guid isPermaLink="false">https://medium.com/p/4a350ee1bb8a</guid>
            <category><![CDATA[backend]]></category>
            <category><![CDATA[rate-limiting]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[redis]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Jinia Konar]]></dc:creator>
            <pubDate>Mon, 04 Jul 2022 11:12:34 GMT</pubDate>
            <atom:updated>2025-04-21T06:56:08.809Z</atom:updated>
            <content:encoded><![CDATA[<p><em>All the systems nowadays have to be designed for a distributed environment which can support scalability. Therefore it is equally important to think of a scalable solution for even small components like </em><strong><em>Rate Limiter</em></strong><em>.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wvBjR5TxpCksj8nkeNnr6g.jpeg" /></figure><p>There are many rate limit algorithms that we have already discussed <a href="https://medium.com/@jinia.konar/rate-limiter-and-its-algorithms-with-illustrations-564455162935">here</a>, among them we will discuss the <strong>Sliding window counter (also known as rolling-rate-limiter) </strong>in depth with the combination of redis sorted sets for distributed and scalable system in this blog.</p><p><a href="https://medium.com/@jinia.konar/rate-limiter-and-its-algorithms-with-illustrations-564455162935">Medium</a></p><h3>What is Sliding window counter?</h3><p>It is a hybrid approach that combines both the fixed window counter and sliding window log algorithm discussed earlier.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jzYGc8yBvUMi9xGmk3DXPw.png" /><figcaption>Sliding window counter algorithm</figcaption></figure><p>Sliding window counter is similar to fixed window counter but it smooths out bursts of traffic by adding a weighted count in previous window to the count in current window. For example, suppose the limit is 4 requests/minute in the above diagram. There are 4 requests in window [1:00:00, 1:01:00) and 2 requests in window [1:01:00, 1:02:00). For 2 requests that arrives at 1:01:15, which is at 25% position of window [1:01:00, 1:02:00), we calculate the request count by the formula: 3 x (1 - 25%) + 2 = 4.25 &gt; 4. Thus we reject this request. Even though both windows don’t exceed the limit, the request is rejected because the weighted sum of previous and current window does exceeded the limit.</p><p>Pros: It smooths out spikes in traffic because the rate is based on the average rate of the previous window.<br>Cons: Works only for not-so-strict look back window times, especially for smaller unit times.</p><p>Above solution can be used in case of single system architecture, but in case of distributed system architecture weird race condition can occur while updating counter value. Let’s discuss below a solution to this problem😁.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FkQOxxwjjuTB7O%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FkQOxxwjjuTB7O%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2FkQOxxwjjuTB7O%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="241" frameborder="0" scrolling="no"><a href="https://medium.com/media/0c37ae6531b7f45c1db7e61cb224b621/href">https://medium.com/media/0c37ae6531b7f45c1db7e61cb224b621/href</a></iframe><h3>A Solution for distributed systems</h3><p>Along with the sliding window counter logic we can use <a href="https://www.youtube.com/watch?v=1GRJJC33igU&amp;t=198s">redis sorted sets</a> data structure to provide a solution for distributed systems.</p><p>You can checkout my <a href="https://github.com/jinia-konar/rate-limiter">Github Repository</a>, where I have created a simple employee management system in java using Spring Boot, where the read apis are rate limited. I have used <a href="https://www.baeldung.com/spring-data-redis-tutorial">Redis Template and JedisConnectionFactory</a>, which will run all the redis commands in an atomic fashion that will avoid all the weird race conditions😁. Let’s discuss the logic in depth here.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2faa0eab3471b11907cd858a67a988e9/href">https://medium.com/media/2faa0eab3471b11907cd858a67a988e9/href</a></iframe><p>Basically the logic is same as discussed earlier i.e whenever any new request will come we will do the following things:-</p><ol><li>Remove all elements of the set which were requested before the allowed time window . This can be accomplished with Redis’s <a href="https://www.tutorialspoint.com/redis/sorted_sets_zremrangebyscore.htm">ZREMRANGEBYSCORE</a> command, here in the above code it is line 10 :<br>* Here operations are the RedisOperations out of which we are using opsForZSet which will provide all the redis sorted sets functionality.<br>* removeRangeByScore will remove all the elements for the redis key rate-id which are within the range 0-(currentTime-slidingWindowTime) .</li><li>Add the current timestamp to the set, using <a href="https://www.tutorialspoint.com/redis/sorted_sets_zadd.htm">ZADD</a> command, line 11: above we have added current timestamp as score as well as value for the redis key rate-id.</li><li>Add a TTL equal to the rate-limiting interval on the set (to save space), line 12 in the above code.</li><li>Then get all the entries in the set which will help us to calculate the number of calls of the API for the time window using <a href="https://www.tutorialspoint.com/redis/sorted_sets_zrange.htm">ZRANGE(0,-1)</a> command, here line 13: for the redis key rate-id we get all the set elements from the beginning to the end.</li><li>And lastly wrap all the above operations using <a href="https://docs.spring.io/spring-data/data-redis/docs/current/reference/html/#tx">Redis Transaction</a> (MULTI / EXEC commands) to ensure that all commands are executed together in an atomic fashion.</li></ol><p>Let’s get more clarity with a small example.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F3o7TKEnU81ONy7QGY0%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F3o7TKEnU81ONy7QGY0%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2F3o7TKEnU81ONy7QGY0%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="215" frameborder="0" scrolling="no"><a href="https://medium.com/media/9c61db57644a727bbdbfd1547b464a87/href">https://medium.com/media/9c61db57644a727bbdbfd1547b464a87/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gTXiBB9_QOKDfo6k7r5ahg.png" /><figcaption>Sliding window counter algorithm example</figcaption></figure><p>In the above diagram the rate limit is 2 requests/minute, the log is empty when a new request arrives at 1:00:01. Thus, the request is processed with size = 1. A new request arrives at 1:01:40, all the older timestamps before 1:01:40–00:00:60(Allowed time window) = 1:00:40 are removed hence, the timestamp 1:00:01 is removed and 1:01:40is inserted into the log with size = 1, not larger than the allowed count, thus, the request is processed. Similarly a new request arrives at 1:01:50, and all the older timestamps before 1:01:50–00:00:60 = 1:00:50 are removed, but there is no such timestamp so nothing is removed and 1:01:50 is inserted into the log with size = 2, not larger than the allowed count, thus, the request is processed. A new request arrives at 1:01:60, and all the older timestamps before 1:01:60–00:00:60 = 1:00:00 are removed, but still there is no such timestamp so nothing is removed and 1:01:60 is inserted into the log with size = 3, larger than the allowed size 2. Therefore, this request is rejected.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Fg9582DNuQppxC%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fg9582DNuQppxC%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2Fg9582DNuQppxC%2Fgiphy-downsized-large.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/0eba96b395f1e17a357fe179074ce870/href">https://medium.com/media/0eba96b395f1e17a357fe179074ce870/href</a></iframe><p>I hope I was able to share my understanding with you, thanks for your support till here. If you’ve enjoyed this story, please click the 👏 button and share it, to help others find it as well. Also, feel free to leave a comment below.😁</p><p>Groww Engineering publishes technical anecdotes, the latest technologies, and better ways to tackle common programming problems. You can subscribe <a href="https://medium.com/@groww">here</a> to get the latest updates.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a350ee1bb8a" width="1" height="1" alt=""><hr><p><a href="https://tech.groww.in/rate-limiter-for-a-distributed-and-scalable-system-4a350ee1bb8a">Rate Limiter for a distributed and scalable system.</a> was originally published in <a href="https://tech.groww.in/">The Groww Engineering Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Send custom notification on slack in 4 minutes]]></title>
            <link>https://tech.groww.in/send-custom-notification-on-slack-in-4-minutes-89a6923c4d67?source=rss-8fdf4f29301b------2</link>
            <guid isPermaLink="false">https://medium.com/p/89a6923c4d67</guid>
            <category><![CDATA[infra]]></category>
            <category><![CDATA[slackbot]]></category>
            <category><![CDATA[cron]]></category>
            <category><![CDATA[custom-notification]]></category>
            <category><![CDATA[scheduler]]></category>
            <dc:creator><![CDATA[Jinia Konar]]></dc:creator>
            <pubDate>Mon, 17 Jan 2022 18:05:04 GMT</pubDate>
            <atom:updated>2025-04-21T07:28:36.070Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Technology helps to remember many things today, and among them the savior is notification, and we can be luckier if we can customize those notification.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lm4OUX9Qp0rTW5qStuR5QQ.jpeg" /></figure><p>Working from home has increased the difficulty level for maintaining work relationships. Along with sprint tasks and lots of work-related calls, it is difficult to do 1–1(one-on-one) with fellow developers, and a lot difficult to use the brain daily for thinking whom to call today and get on a chit chat.</p><p>So, as my savior, I thought of developing a bot that can notify me on slack with the name of a person, I can talk to today. Yes, of course, we can use this bot for sending any custom notification to ourselves and to anyone :D</p><p>I have divided the bot into 3 simple tasks:-</p><ul><li>Randomly pick a fellow developer</li><li>Notify on slack for the 1–1</li><li>Schedule the notification</li></ul><h3>1. Randomly pick a fellow developer</h3><p>Create a list of fellow developers you want to do 1–1 with, you can also create an object that can store their details and add them to the list. Then use the random() function for randomly picking one among them all.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hAmiLE0qGygd6Qaj4saUGQ.png" /><figcaption>Randomly pick a fellow developer from the list.</figcaption></figure><h3>2. Notify on slack for the 1–1</h3><p>Add slack app <a href="https://api.slack.com/messaging/webhooks">Incoming WebHooks</a> to your workspace, you can deliver automatic messages (JSON payload) from one app to another using webhooks. Webhooks can be triggered in response to specific events. When you create an Incoming Webhook, you’ll be given a unique URL to which you may send a JSON payload including the message text and some choices.</p><p>In the above python file, you can write the below python script, this will take a randomly picked name and notify the same on the specified slack channel.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5ad7c056668f2be8756fc948788f4c12/href">https://medium.com/media/5ad7c056668f2be8756fc948788f4c12/href</a></iframe><h4>Variable Used</h4><p><strong>Url: </strong>Your<strong> </strong>unique webhook URL for your workspace section, you will get after you add the app to our workspace.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/870/1*MPcYGYL5-wlnJw_jXImjaw.png" /></figure><h4>JSON Request payload</h4><p>Below is a detailed view of the slack_data used in the above python code.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5859e14102989075c30c433e20eba681/href">https://medium.com/media/5859e14102989075c30c433e20eba681/href</a></iframe><p>That’s it, just run the python script and you can see the below result 🤝😁.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/984/1*v7zREsGWU8qX1NSDxH0j5g.png" /><figcaption>Preview of the notification (Workspace name + Channel name + Custom text)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/984/1*dydGiwbU1ZnKaUtRAb6KcA.png" /><figcaption>Custom message send to the slack</figcaption></figure><h3>3. Schedule the notification</h3><p>Schedule a cron job for your notification bot. In the terminal check if there is any existing cron job with crontab -l . Then open the nano editor for writing a new cron job with crontab -e. If by default the nano editor is not specified then we can also use env EDITOR=nano crontab -e .</p><p>To learn more about corn job and how to schedule it <a href="https://medium.com/macoclock/automate-running-a-script-using-crontab-on-macos-88a378e0aeac">visit here</a>.</p><blockquote>A schedule is described using the unix-cron string format (<em>* * * * *</em>), which is a set of five values in a line, indicating when the job should be executed.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mkPHCX-IuzU_62e9bsT3og.png" /><figcaption>Cron job format</figcaption></figure><p>I wanted to schedule this job for every weekday at 12:26 PM, so for that, I used the below cron job (you can use any cron job as per your use case and verify that <a href="https://crontab.cronhub.io/">here</a>)</p><p>26 12 * * MON,TUE,WED,THU,FRI /usr/local/bin/python3 &lt;path_of_our_python_scripyt_file&gt;</p><p>Then save and exit from the editor with control + O, return , control + X</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FJir7AUookJHIVb5aYM%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FJir7AUookJHIVb5aYM%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2FJir7AUookJHIVb5aYM%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/7ba4284956137f6e30b82d874ca092c9/href">https://medium.com/media/7ba4284956137f6e30b82d874ca092c9/href</a></iframe><p>Congratulations we have scheduled the notification bot as per our use case.</p><p>For source code check out my <a href="https://github.com/jinia-konar/custom-notification-bot"><strong>GitHub repository</strong></a>.</p><p>If you’ve enjoyed this story, please click the 👏 button and share it, to help others find it as well. Also, feel free to leave a comment below.</p><p>Groww Engineering publishes technical anecdotes, latest technologies, and better ways to tackle common programming problems. You can subscribe <a href="https://medium.com/@groww">here</a> to get the latest updates.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=89a6923c4d67" width="1" height="1" alt=""><hr><p><a href="https://tech.groww.in/send-custom-notification-on-slack-in-4-minutes-89a6923c4d67">Send custom notification on slack in 4 minutes</a> was originally published in <a href="https://tech.groww.in/">The Groww Engineering Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>