Skip to content

Commit

Permalink
Updating document with diagram
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikhail committed Jul 12, 2020
1 parent 92fc144 commit 7388b66
Show file tree
Hide file tree
Showing 3 changed files with 1,800 additions and 30 deletions.
69 changes: 39 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,40 +15,19 @@ The Pop-up store demo is using [Redis Streams](https://redis.io/topics/streams-i

![Pop-up](https://github.com/mikhailredis/redis-pop-up-store/blob/master/images/pop-up.gif)

## What is displayed on Grafana dashboard

- `Product Available` - the value of `product` key
- `Customers Ordering` - length of `queue:customers`
- `Orders Processing` - length of `queue:orders`
- `Orders Completed` - length of `queue:complete`
- `Customers Overflow` - the difference between customer submitted orders and orders completed
- `Customers Ordering` - change of `queue:customers` length
- `Orders In Queue` - change of `queue:orders` length
- `Completed Flow` - how many orders processed

## Requirements
## How it works

- [Docker](https://docker.com) to start Redis and Grafana.
- [Node.js](https://nodejs.org) to run simulation script.

## Start Redis with RedisTimeSeries and RedisGears modules installed and Grafana

For detailed instructions please take a look at [redismod - a Docker image with select Redis Labs modules](https://hub.docker.com/r/redislabs/redismod).
![Diagram](https://github.com/mikhailredis/redis-pop-up-store/blob/master/images/pop-up.png)

```
npm start:docker
```

## RedisGears scripts

- Visualize queues using RedisTimeSeries
- Node.js script add random data to Customers and Orders streams
- RedisGears is using `StreamReader` watching all `queue:` keys and adding Time-Series samples

```
# Add Time-Series
def tsAdd(x):
xlen = execute('XLEN', x['key'])
execute('TS.ADD', 'ts:len:'+x['key'], '*', xlen)
execute('TS.ADD', 'ts:enqueue:' + x['key'], '*', x['value'])
xlen = execute('XLEN', x['key'])
execute('TS.ADD', 'ts:len:'+x['key'], '*', xlen)
execute('TS.ADD', 'ts:enqueue:' + x['key'], '*', x['value'])
# Stream Reader for any Queue
Expand All @@ -57,7 +36,11 @@ gb.countby(lambda x: x['key']).map(tsAdd)
gb.register(prefix='queue:*', duration=5000, batch=10000, trimStream=False)
```

- Complete orders using `queue:complete` stream
- Another RedisGears script completes orders
- adding data to `queue:complete` stream
- deleting client's ordering
- decreasing product amount
- trimming Orders queue

```
# Complete order
Expand All @@ -74,7 +57,33 @@ gb.map(complete)
gb.register(prefix='queue:orders', batch=3, trimStream=True)
```

### Register [StreamReaders](https://oss.redislabs.com/redisgears/readers.html#streamreader)
- Grafana query streams and Time-Series keys every 5 seconds to display samples using Grafana Redis Datasource.

## What is displayed on Grafana dashboard

- `Product Available` - the value of `product` key
- `Customers Ordering` - length of `queue:customers`
- `Orders Processing` - length of `queue:orders`
- `Orders Completed` - length of `queue:complete`
- `Customers Overflow` - the difference between customer submitted orders and orders completed
- `Customers Ordering` - change of `queue:customers` length
- `Orders In Queue` - change of `queue:orders` length
- `Completed Flow` - how many orders processed

## Requirements

- [Docker](https://docker.com) to start Redis and Grafana.
- [Node.js](https://nodejs.org) to run simulation script.

## Start Redis with RedisTimeSeries and RedisGears modules installed and Grafana

For detailed instructions please take a look at [redismod - a Docker image with select Redis Labs modules](https://hub.docker.com/r/redislabs/redismod).

```
npm start:docker
```

## Register [StreamReaders](https://oss.redislabs.com/redisgears/readers.html#streamreader)

Install Readers to add Time-Series and complete orders

Expand Down
Loading

0 comments on commit 7388b66

Please sign in to comment.