小编Dyp*_*pso的帖子

如何使用 StackExchange.Redis 解决客户端 Redis 超时问题?

我在 ac# wcf 应用程序中使用 StackExchange.Redis 客户端:我仅使用同步命令来获取和设置值。问题是我的这个奇怪的日志超时了:

Timeout performing EXISTS DataKey:50, 
inst: 1, queue: 1, qu: 0, qs: 1, qc: 0, wr: 0, wq: 0, in: 0, ar: 0, clientName: Machine1, 
serverEndpoint: redis-server:6381, keyHashSlot: 7984, 
IOCP: (Busy=1,Free=799,Min=8,Max=800), 
WORKER: (Busy=5,Free=795,Min=8,Max=800) 
(Please take a look at this article for some common client-side issues that can 
cause timeouts: http://stackexchange.github.io/StackExchange.Redis/Timeouts) 
Run Code Online (Sandbox Code Playgroud)

如果我理解正确,这意味着我的获取值已排队,因为有五个工作线程?使用 netstat,我看到我的应用程序正在打开两个到服务器的物理连接。我已确保线程池中有足够的可用线程。在我的连接设置中,我有一个syncTimeout=3000...如果我使用redis-cli,我可以在0.64秒内获取密钥的值。

有人可以帮忙吗?我能做些什么?我是否必须在代码中一直使用异步或找到另一个 redis 客户端库?

c# timeout stackexchange.redis

3
推荐指数
1
解决办法
3万
查看次数

在WebApi2上使用Serilog的正确方法

我正在寻找将serilog与aspnet webapi2结合使用的正确方法。现在,我像这样初始化全局Log.Logger属性:

   public static void Register(HttpConfiguration config)
    {

        Log.Logger = new LoggerConfiguration()
            .WriteTo.Elasticsearch(new ElasticsearchSinkOptions(new Uri("http://localhost:9200"))
            {
                IndexFormat = IndexFormat,
                BufferBaseFilename = outputLogPath,
                AutoRegisterTemplate = true,
                AutoRegisterTemplateVersion = AutoRegisterTemplateVersion.ESv6,
                CustomFormatter = new ElasticsearchJsonFormatter(renderMessageTemplate: false),
                BufferFileCountLimit = NbDaysRetention
            })
            .MinimumLevel.ControlledBy(new LoggingLevelSwitch() { MinimumLevel = LogEventLevel.Information})
            .Enrich.FromLogContext()
            .Enrich.WithWebApiRouteTemplate()
            .Enrich.WithWebApiActionName()
            .CreateLogger();

        //Trace all requests
        SerilogWebClassic.Configure(cfg => cfg.LogAtLevel(LogEventLevel.Information));


        config.MapHttpAttributeRoutes();

        config.Routes.MapHttpRoute(
            name: "DefaultApi",
            routeTemplate: "api/{controller}/{id}",
            defaults: new { id = RouteParameter.Optional }
        );
    }
Run Code Online (Sandbox Code Playgroud)

有更清洁的方法吗?我想知道,如果我必须对控制器进行一些测试,是否可能会导致问题。

asp.net-web-api2 serilog

3
推荐指数
1
解决办法
755
查看次数