Closed jakey188 closed 6 years ago
i have the same problem about this. i call the service address directly, it spent 73ms. but i call the service var ocelot gateway, it spent 11022ms. it's too slow.
hi @jakey188, if you host the api by Kestrel not use iis. the problem will be solved.
@chi7cha7rito i not use iis. this should not be the key to the problem.
@jakey188
What logger level are you using and what type of logging? People often report performance problems with Ocelot and every time it is the logging in asp.net causing the problem.
Trying setting the logger level to Error or not using the console logger!
@TomPallister i setting the logger lever to error. the problem is still the same
@jakey188 please share your configuration.json. That might help us work out the problem.
@TomPallister configuration.json { "ReRoutes": [ { "DownstreamPathTemplate": "/api/user/{user}", "DownstreamScheme": "http", "DownstreamHost": "localhost", "DownstreamPort": 8362, "UpstreamPathTemplate": "/api/user/{user}", "UpstreamHttpMethod": [ "Get" ] } , { "DownstreamPathTemplate": "/api/product/{product}", "DownstreamScheme": "http", "DownstreamHost": "localhost", "DownstreamPort": 8330, "UpstreamPathTemplate": "/api/product/{product}", "UpstreamHttpMethod": [ "Get" ] } ], "GlobalConfiguration": { "ServiceDiscoveryProvider": { "Host": "localhost", "Port": 8500 } } } [Route("api/user")] public class UserController : Controller { [HttpGet("info")] public string Get(string id) { return "userInfo"; }
[HttpGet("getById")]
public string GetByUserId(string id)
{
return "user-getById";
}
}
use ocelot 2.0.10
@jakey188 can you also paste your program.cs and Startup.cs
@TomPallister
public class Program
{
public static void Main(string[] args)
{
//IWebHostBuilder builder = new WebHostBuilder();
//builder.ConfigureServices(s => {
// s.AddSingleton(builder);
//});
//builder.UseKestrel()
// .UseContentRoot(Directory.GetCurrentDirectory())
// .UseIISIntegration()
// .UseStartup
public static IWebHost BuildWebHost(string[] args)
{
IWebHostBuilder builder = WebHost.CreateDefaultBuilder(args);
builder.UseStartup<Startup>()
.ConfigureAppConfiguration((hostingContext, config) =>
{
config.AddJsonFile("configuration.json");
})
.ConfigureLogging((hostingContext, logging) =>
{
logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
logging.AddConsole();
});
return builder.Build();
}
}
public class Startup { // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) {
services.AddOcelot()
//.AddStoreOcelotConfigurationInConsul()
.AddCacheManager((x) =>
{
x.WithMicrosoftLogging(log =>
{
log.AddConsole(LogLevel.Error);
})
.WithDictionaryHandle();
});
services.AddMvc();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseOcelot().Wait();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "api/{controller}/{action}/{id?}");
});
}
}
appsettings.json { "Logging": { "IncludeScopes": false, "Debug": { "LogLevel": { "Default": "Error" } }, "Console": { "LogLevel": { "Default": "Error" } } } }
single service user I don't think I need to share it
try to delete Console Logger @jakey188
I spent more network request time with the gateway。 http://localhost:8362/api/user/info?id=1 20ms - service address http://localhost:3164/api/user/info?id=1 200ms-ocelot gateway I've tried many times.I'm not very aware of the source code now, I will spend a certain amount of time studying ocelotsource code 。 I'm not sure the specific reason, but I hope you can restore this scene