Giter Site home page Giter Site logo

designdemo's Introduction

designDemo

延迟任务处理方案

方案一:数据库轮询 小型项目常用方式,通过一个线程去扫描数据库或数据库定时任务,通过订单时间判断超时的订单,进行更新状态或其他操作。

方案二:JDK延迟队列 DelayQueue是一个无界阻塞队列,只有在延迟期满时才能从中获取元素,放入DelayQueue中的对象需要实现Delayed接口。

方案三:Redis 有序集合 将订单超时时间戳与订单号分别设置为score与member,系统扫描第一个元素判断是否超时。

各方案总结:

DB轮询 优点:实现简单、无技术难点、异常恢复、支持分布式/集群环境; 缺点:影响数据库性能;

DelayedQueue 优点:实现简单、性能较好; 缺点:异常恢复困难、只适用于单机环境,分布式/集群实现困难;

Redis 优点:解耦、异常恢复、支持分布式/集群环境; 缺点:增加Redis维护;

designdemo's People

Contributors

smallfive55 avatar

Watchers

James Cloos 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.