ThreeMammals / Ocelot

.NET API Gateway
https://www.nuget.org/packages/Ocelot
MIT License
8.38k stars 1.64k forks source link

httpclient is slow without rules #1618

Closed yoholiao closed 10 months ago

yoholiao commented 2 years ago

in my production env. one post request httpclient will slow without rules, and the request qps is low (6/s).

skywalking trace: oap

kibana request log: kibana

ocelot.conf

{
  "Routes": [
    {
      "DownstreamPathTemplate": "/api/v1/task/sync",
      "DownstreamScheme": "http",
      "UpstreamPathTemplate": "/oacenter/api/v1/task/sync",
      "UpstreamHttpMethod": ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
      "ServiceName": "oacenter-sync",
      "LoadBalancerOptions": {
        "Type": "LeastConnection"
      }
    }
  ],
  "GlobalConfiguration": {
    "ServiceDiscoveryProvider": {
      "Scheme": "http",
      "Host": "consul-server",
      "Port": 8500,
      "Type": "Consul",
      "ConfigurationKey": "gateway.ocelot"
    },
    "RateLimitOptions": {
      "DisableRateLimitHeaders": false,
      "QuotaExceededMessage": "Too Many Requests",
      "HttpStatusCode": 999,
      "ClientIdHeader": "X-Forwarded-For"
    }
  }
}

Startup.cs

services
.AddOcelot()
.AddDelegatingHandler<CookieHandler>(true)
.AddDelegatingHandler<RequestHandler>(true)
.AddConsul()
.AddConfigStoredInConsul()
;

version: net5.0 + ocelot 17.0.0 platform: Kubelet v1.18.6 , docker19.3.8

raman-m commented 10 months ago

@yoholiao Hello!

Is this issue a question or a bug? Let's consider that first... Do you use IIS to host downstream services or Ocelot app?

raman-m commented 10 months ago

without rules

Considering your complex Ocelot setup: Consul service discovery, Load Balancer, Delegating handlers (two types), Kubernetes hosting... I would say your solution and setup is quite complex. Your delegating handlers can do additional tasks which affect total processing time of the request... I would say the root cause can be inside of your delegating handlers.

raman-m commented 10 months ago

Sorry we cannot accept the issue because it is related to your environment.