GithubHelp home page GithubHelp logo

servercache's Introduction

##Background

  1. A system can produce various types of messages such as WeChat messages and mail messages. These messages are sent to users through different ways.
  2. The messages can be produced with a very high frequency, however, due to capacity limitation, the servers cannot send messages very fast. Therefore, messages need to be cached in a message queue. Based on the points above, we need to design a server that can cache messages and send them evenly and slowly to the users.

##Project Architecture For this project, it consists of following parts.

  1. MessageQueue. The core part of this demo. It is implemented by blocking queue. Also, due to the capacity limitation, the messages cannot be stored infinitely. Therefore, we have to assign rejection/eviction policy. In this demo, users can assign them through application.yml.
  2. Producer. When the interface /send is requested, the coming messages will be processed by the producer. It will cache message by using message queue that mentioned above.
  3. Consumer. In order to send messages smoothly, RateLimter is adopted to implement the token algorithm. ALso, due to the message is a blocking queue, when the queue is empty, the consumer thread will be blocked and will be notified by the queue automatically. To some extent, it improves the CPU utilization.
  4. ClientDemo. It can mimic the messages production with a high frequency by using thread pool. It will request server /send interface frequently.

servercache's People

Contributors

gujiawei-edinburgh avatar

Stargazers

 avatar  avatar

Watchers

 avatar  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.