Netflix/zuul

Response filter getting blocked for sometime intermittently

kark137 opened this issue · 2 comments

We are using zuul 2.1.6 and we got the response back form down stream API but it's getting blocked for some reason in the response/outbound filter sometimes (not all the time). It's happening intermittently and the CPU also not used much during these times.
What could be the root cause? Anyone faced a scenario like this?
Thank in advance for any suggestions..

Below is how the response filter looks like

@OverRide
HttpResponseMessage apply(HttpResponseMessage response) {
SessionContext context = response.getContext()

    if (SEND_RESPONSE_HEADERS.get()) {
        Headers headers = response.getHeaders()

        StatusCategory statusCategory = StatusCategoryUtils.getStatusCategory(response)
        if (statusCategory != null) {
            headers.set(X_ZUUL_STATUS, statusCategory.name())
        }

        RequestAttempts attempts = RequestAttempts.getFromSessionContext(response.getContext())
        String headerStr = ""
        if (attempts != null) {
            headerStr = attempts.toString()
        }
        headers.set(X_ZUUL_PROXY_ATTEMPTS, headerStr)

        headers.set(X_ZUUL, "zuul")
        headers.set(X_ZUUL_INSTANCE, System.getenv("EC2_INSTANCE_ID") ?: "unknown")
        headers.set(CONNECTION, KEEP_ALIVE)
        headers.set(X_ZUUL_FILTER_EXECUTION_STATUS, context.getFilterExecutionSummary().toString())
        headers.set(X_ORIGINATING_URL, response.getInboundRequest().reconstructURI())

        log.info("status:"+ attempts.get(0).getStatus()+" duration:"+ attempts.get(0).getDuration())

        if (response.getStatus() >= 400 && context.getError() != null) {
            Throwable error = context.getError()
            headers.set(X_ZUUL_ERROR_CAUSE,
                    error instanceof ZuulException ? ((ZuulException) error).getErrorCause() : "UNKNOWN_CAUSE")
        }

        if (response.getStatus() >= 400) {
            log.info("Passport: {}", CurrentPassport.fromSessionContext(context))
        }
    }

    if (context.debugRequest()) {
        Debug.getRequestDebug(context).forEach({ s -> log.info("REQ_DEBUG: " + s) })
        Debug.getRoutingDebug(context).forEach({ s -> log.info("ZUUL_DEBUG: " + s) })
    }

    return response
}

}

Let's say The status log which is after the headers.set got logged at 28-11-23 19:30:10 and the passport log, which is after few lines getting logged at 28-11-23 19:30:20. it is taking/blocked for 10 secs there.

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.

This issue was closed because it has been stalled for 7 days with no activity.