zoukankan      html  css  js  c++  java
  • StackExchange.Redis client best practices

    StackExchange.Redis client best practices


    1. Enabling server GC can optimize the client and provide better performance and throughput.
    2. Set AbortOnConnectFail to false, when AbortOnConnectFail is false, the StackExchange.Redis will reconnect automatically.
    3. Reuse the ConnectionMultiplexer, do not create a new one for each request. The Lazy<ConnectionMultiplexer> pattern is recommended.
    4. Redis works best with smaller values, so consider chopping up bigger data into multiple keys. In this Redis discussion, 100KB is considered large.
    5. Configure your ThreadPool settings to avoid timeouts.
    6. Use at least the default connectTimeout of 5 seconds.
    7. Be aware of the performance costs associated with different operations you are running. For instance, the KEYS command is an O(n) operation and should be avoided.

    Performance testing
    redis-benchmakr.exe

    examples:
    private static readonly Lazy<ConnectionMultiplexer> _lazy = new Lazy<ConnectionMultiplexer>(()=>{
    string connectionString = ConfigurationManager.AppSettings["RedisConnection"].ToString();
    return ConnectionMultiplexer.Connect(connectionString);
    });

    public static ConnectionMultiplexer Connection => _lazy.Value;

  • 相关阅读:
    css3圆形轨迹动画
    css3动画
    3D效果
    css3基础下
    css3基础
    HTML5 表单 中
    HTML5 表单
    面向对象的三大特性、七大原则、类与类间的关系
    四种事务的隔离级别
    线程池(二)
  • 原文地址:https://www.cnblogs.com/yycelsu/p/13376147.html
Copyright © 2011-2022 走看看