-1

We encountered some TCP dial timeout issues when the node's (we use Kubernetes) CPU load is high: user received 504 status code after request exceeds 30 seconds, but the server never received those requests.

We use Traefik as our Ingress: forwardingtimeoutsdialtimeout - Traefik, I want to figure out if this caused the problem. How can I simulate a TCP dial timeout error for test?

Timeout requests (time/request_time/upstream_status):

enter image description here

CPU usage:

enter image description here

Kacifer
  • 1,334
  • 17
  • 26
  • How to simulate a dial timeout in what code? Most packages use a `Dial` or `DialContext` function of some sort, which you can do whatever you want with. – JimB Dec 22 '20 at 20:04

1 Answers1

-3
package main

import (
    "github.com/gin-gonic/gin"
    "time"
)

    func main() {
        app := gin.Default()
        app.GET("/", TO)
        app.Run(":4040")
    }
    func TO(c *gin.Context) {
        time.Sleep(time.Minute * 5)
        return
    }

defines a handler which delays response, to this if you make a request with Dial.Timeout less than 5 minutes. It will time out.

How to set timeout for http.Get() requests in Golang?

shows how to set timeout value in go's native http.Client

whitespace
  • 789
  • 6
  • 13