<p>I am facing a problem where my backend application is doing some complex calculation and due to which its taking more more than 2 minutes to complete and I am constantly getting 504 gateway timeout.</p>
<p>When I check the logs using pod logs <code>watch</code> command, I can see that the process is running smoothly and its finished its task without any error.</p>
<p>Please help to fix.</p>

Muhammad Tariq
<p>Here is my solution:</p>
<p>My backend application (SprintBoot app) was performing some complex calculation and I was getting <em><strong>504 Gateway Timeout</strong></em>, while the calculation was performing its work at the backend.</p>
<p>After investing the issue, I found out that this problem is related to <code>idle timeout duration</code> annotation in the kubernetes ingress configuration. My timeout was set to <em>120 seconds</em> which wasn't enough for calculation and the calculation was taking more time to complete.</p>
<p>To resolve this issue, I updated the following annotation in the ingress.<br />
<code>alb.ingress.kubernetes.io/load-balancer-attributes: idle_timeout.timeout_seconds=300</code>.</p>
<p>To update in Windows, I performed the following steps:</p>
<ol>
<li>kubectl get ingress (Get the current ingress)</li>
</ol>
<pre><code>PS C:\aks&gt; kubectl get ingress -n my-namespace
NAME       CLASS  HOSTS ADDRESS        PORTS  AGE
my-ingress &lt;none&gt;   *    52.152.91.154  80    10m
</code></pre>
<ol start="2">
<li>Edit the ingress configuration using <code>edit</code> command<br />
<code>kubectl edit ingress my-ingress -n my-namespace</code> (It will open a new file in a notepad)</li>
</ol>
<pre><code>PS C:\aks&gt; kubectl edit ingress my-ingress -n my-namespace
ingress.networking.k8s.io/my-ingress edited
</code></pre>
<p>In the notepad , you can go-ahead and modify the service name and save it.<br />
Once you see this message <code>ingress.networking.k8s.io/my-ingress edited</code>, this means the changes have been applied.</p>
<p>I took help from following articles and wanna share here for the readers</p>
<ul>
<li><a href="https://repost.aws/knowledge-center/eks-http-504-errors" rel="nofollow noreferrer">https://repost.aws/knowledge-center/eks-http-504-errors</a></li>
<li><a href="https://learn.microsoft.com/en-us/answers/questions/1031687/how-to-edit-an-existing-ingress-nginx-rule-in-azur" rel="nofollow noreferrer">https://learn.microsoft.com/en-us/answers/questions/1031687/how-to-edit-an-existing-ingress-nginx-rule-in-azur</a> ( This is Azure example but its applicable for EKS and GKE also)</li>
</ul>
