Express Gateway降级导致请求严重延迟

问题描述

我已将网关配置为处理某些服务,但是存在巨大的性能问题,我不知道该如何解决。这是此特定服务的配置:

http:
    port: 3020
    hostname: 'xxxx.prod.xx.xxx.net'
apiEndpoints:
    laPrdTest:
        host: 'xxx-xxxxxxxx.xxxxxxxx.com'
        paths: '/api/v1/esign/*'
serviceEndpoints:
    laPrdTest:
        urls:
            - http://xxxxxx-app1.prd.xxx.xxxxxxxx.net
            - http://xxxxxx-app2.prd.xxx.xxxxxxxx.net
policies:
    - basic-auth
    - cors
    - expression
    - log
    - jwt
    - proxy
    - rate-limit
pipelines:
laPrdTest:
        apiEndpoints:
            - laPrdTest
        policies:
            - cors:
            - log:
                - action:
                    message: ${req.method} ${req.originalUrl} ${JSON.stringify(req.headers)}
            - rate-limit:
                - action:
                    max: 50
                    windowMs: 120000
                    rateLimitBy: "${req.ip}"
            - proxy:
                - action:
                    serviceEndpoint: laPrdTest
                    changeOrigin: true

检查此gif,以便您了解这对性能的影响如何:

Bad Performance Express Gateway

这是对服务API的直接调用,没有性能问题:

No Gateway

为什么会这样? 我该怎么办才能解决这个问题?

解决方法

最后我不能再用这个直接通过 Nginx 做代理了。 任何通过网关发出的请求都需要几秒钟的时间,而现在使用 Nginx 作为网关则需要几毫秒。