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;

  • 相关阅读:
    jupyter notebook 在mac OS上的安装
    spring cloud 学习(11)
    spring cloud 学习(10)
    spring-boot 速成(12)
    spring cloud 学习(9)
    java一些常用并发工具示例
    python语法相关---1、
    python语法相关---2、
    Python人工智能参考---感知器(神经元)
    网站部署测试---1、apache如何部署网站
  • 原文地址:https://www.cnblogs.com/yycelsu/p/13376147.html
Copyright © 2011-2022 走看看