<?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 Jaskaranjit on Medium]]></title>
        <description><![CDATA[Stories by Jaskaranjit on Medium]]></description>
        <link>https://medium.com/@jaskaranjit05?source=rss-8bca15c2c78a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*lRwo1RO7UQhf699KvidkDQ.jpeg</url>
            <title>Stories by Jaskaranjit on Medium</title>
            <link>https://medium.com/@jaskaranjit05?source=rss-8bca15c2c78a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 06:19:55 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jaskaranjit05/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[Rate limiting AWS Step functions with Kong]]></title>
            <link>https://engineering.cred.club/rate-limiting-aws-step-functions-with-kong-6b6616eef55c?source=rss-8bca15c2c78a------2</link>
            <guid isPermaLink="false">https://medium.com/p/6b6616eef55c</guid>
            <category><![CDATA[step-functions]]></category>
            <category><![CDATA[kong]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[rate-limiting]]></category>
            <category><![CDATA[reverse-proxy]]></category>
            <dc:creator><![CDATA[Jaskaranjit]]></dc:creator>
            <pubDate>Tue, 14 Mar 2023 11:37:30 GMT</pubDate>
            <atom:updated>2023-03-14T11:37:30.534Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*URKASWfGuz90FPtplooI2w.png" /></figure><blockquote>User Journey is an integral part of any product, and a well defined workflow encapsulates the user experience and becomes nearly imperceptible to the user. CRED employs AWS Step Functions to offer seamless product experience.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d5XSJZeSRZLSXaZrqebs3g.png" /><figcaption>Example Onboarding Steps</figcaption></figure><h4>What are AWS Step Functions?</h4><p><a href="https://aws.amazon.com/step-functions/">AWS Step Functions</a> is a low-code, server-less orchestration service that developers can use to build distributed applications, orchestrate &amp; automate business processes, and build data &amp; ML pipelines using AWS services.</p><h4>Use cases within CRED</h4><p>We leverage AWS Step Functions for multiple use cases within CRED.</p><p>Sharing a few examples:</p><blockquote><strong>CRED Mint</strong> — for onboarding new users to the mint product, involving multiple steps for validating PAN, performing KYC checks, agreement signing &amp; adding bank accounts.</blockquote><blockquote><strong>CRED Cash </strong>— for onboarding users to the drawdown flow, performing KYC checks &amp; completing the drawdown flow (involving multiple steps) for the loans.</blockquote><blockquote><strong>CRED Max</strong> — for fetching new BBPS bills from external providers with retry mechanisms &amp; powering payment fulfilments.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PRcji27tDuQE6L0L" /><figcaption>Example Step Function definition for PAN validation</figcaption></figure><blockquote><strong><em>Challenges &amp; Limitations of AWS</em></strong><br>- Max execution time for state machine is 1 year<br>- Execution history is retained for only 90 days<br>- Max 256KB of data can be passed through workflows</blockquote><blockquote>Maximum input or output size for a task, state, or execution -&gt; 262,144 bytes of data as a UTF-8 encoded string. This quota affects tasks (activity, Lambda function, or integrated service), state or execution output, and input data when scheduling a task, entering a state, or starting an execution.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*d5qnQWPcYmeSvczm" /></figure><blockquote><strong>Noisy Neighbour Problem</strong> — There have been more incidents in the past where one micro-service/tenant ended up consuming the entire quota causing a wider degraded impact.</blockquote><pre>// throlling exception in java<br>com.amazonaws.services.stepfunctions.model.AWSStepFunctionsException: <br>Rate exceeded (Service: AWSStepFunctions; Status Code: 400; Error <br>Code: ThrottlingException; Request ID: 328f90ac-cfab-44de-acb6–458cab5a08e0; <br>Proxy: null)</pre><h3>Making API Requests to Step Functions</h3><p>Step Functions are exposed through the set of APIs. <strong><em>x-amz-target</em></strong> can be used to programmatically configure <a href="https://docs.aws.amazon.com/step-functions/latest/apireference/API_Operations.html">actions</a> on step functions. The following example depicts API usage to list step function activities:</p><pre>POST / HTTP/1.1<br>Host: states.us-east-1.amazonaws.com<br>x-amz-target: AWSStepFunctions.ListActivities<br>Content-Type: application/x-amz-json-1.1</pre><p>We enhanced the same notion and exposed Kong as reverse Proxy. The solution replaces the endpoint to which AWS SDK talks to with Kong endpoint which further acts as proxy to step function APIs.</p><h3>Leveraging Kong to solve the problem</h3><p>We introduced the notion of a tenant on the client side (via the HTTP header — <strong><em>x-cred-sfn-tenant</em></strong><em>: cash</em>). We could then leverage the tenant context to build rate limits at the individual tenant levels.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kDrisDPVmJtoFcjESZ6SRQ.png" /><figcaption>Rate Limiting Step functions via Kong</figcaption></figure><p>Sample Client SDK changes:</p><pre>// AWS SDK changes for Java 1.x<br>AwsClientBuilder.EndpointConfiguration endpointConfiguration = new AwsClientBuilder.EndpointConfiguration(&quot;http://localhost:8000&quot;,&quot;ap-south-1&quot;); //Kong endpoint<br>AWSStepFunctions client = AWSStepFunctionsClientBuilder<br>        .standard()<br>        .withClientConfiguration(new ClientConfiguration().withHeader(&quot;x-cred-sfn-tenant&quot;,&quot;cash&quot;)) //tenant for rate limiting<br>        .withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials(&quot;ACCESS_KEY&quot;, &quot;SECRET_KEY&quot;)))<br>        .withEndpointConfiguration(endpointConfiguration)<br>        .build();</pre><pre>// AWS SDK changes for Go 1.x<br>sess := session.Must(session.NewSession())<br><br>svc := sfn.New(sess,<br> &amp;aws.Config{<br>  Credentials: credentials.NewStaticCredentials(&quot;ACCESS_KEY&quot;, &quot;SECRET_KEY&quot;, &quot;&quot;),<br>  Region:      aws.String(endpoints.ApSouth1RegionID),<br>  Endpoint:    aws.String(&quot;http://localhost:8000&quot;), //Kong endpoint<br> })<br><br>svc.Handlers.Build.PushBack(func(r *request.Request) {<br> r.HTTPRequest.Header.Set(&quot;x-cred-sfn-tenant&quot;, &quot;cash&quot;) //tenant for rate limiting<br>})<br></pre><p>Post this change, the next challenge is to enforce the rate limits for each tenant, this is where we leveraged Kong. We configured Kong (as a reverse proxy to Step Functions) and forwarded the incoming requests from the clients to AWS Step Functions. <strong><em>x-amz-target</em></strong> and <strong><em>x-cred-sfn-tenant</em></strong> headers were used in Kong’s route configuration to filter requests for a specific action for a client which needs to be throttled.</p><p>For those routes, we enabled the Rate limiting plugin with the desired configuration (rate limit for the tenant)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*msduQth-Nwf18vd2KVZhQw.png" /><figcaption>Service Configuration in Kong</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PKR0tACjrr6vWg_sqA-9jw.png" /><figcaption>Route Configuration in Kong</figcaption></figure><p>Post enabling the rate-limiting plugin, we were able to detect any rate-limit breaches and intercept them within Kong and return a 429 response.</p><pre>software.amazon.awssdk.services.sfn.model.SfnException: <br>API rate limit exceeded (Service: Sfn, Status Code: 429, Request ID: null)</pre><pre>operation error SFN: ListActivities, https response error StatusCode: 429, <br>RequestID: , api error UnknownError: API rate limit exceeded</pre><p>This change has helped us control the throttling errors at the AWS account level. At the same time, there were minimum changes required on the client side and the changes at Kong are already transparent to the AWS SDK that we have been using on the client side.</p><h3>Future Scope</h3><p>The solution detailed above serves the current needs but as we scale we want to move to a solution where AWS supports the throttles at task and workflow level. We are working with the AWS team to build this capability.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6b6616eef55c" width="1" height="1" alt=""><hr><p><a href="https://engineering.cred.club/rate-limiting-aws-step-functions-with-kong-6b6616eef55c">Rate limiting AWS Step functions with Kong</a> was originally published in <a href="https://engineering.cred.club/">CRED Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>