Giter Site home page Giter Site logo

distributed-lock's Introduction

总结说明

1.采用redis实现分布式锁,单台redis实现分布式锁,防止单点故障,可以采用红锁方式来做

问题1: 如果设置key的有效期过期了,但是业务还没有执行完。

解决方式是自己手动续约,按照有效期的n/3来延长key的的时间,具体时间需要根据业务压测 得出来

2.采用开源redisson来实现分布式锁,它内部已经实现了续期,默认key的有效期是30s, key的续期时间为10s,防止单点故障,可以采用红锁方式来做。

  1. 采用Zookeeper来实现分布式锁,zookeeper客户端curator提供分布锁的实现

  2. mysql实现分布式锁(采用ThreadLocal + 数据库主键冲突)

  3. RedisLockRegister来实现分布式锁(采用本地锁+redis来做)

总结:至于选择哪种方式需要根据项目需求和架构来选型,个人认为在大项目中采用zookeeper来实现分布式锁是最可靠的

distributed-lock's People

Contributors

burning110-lab avatar quguangle avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.