Build a real time analytics with Redis

Murari Ramuka
Google Cloud - Community
7 min readJun 25, 2022

1. What is real-time analytics?

Real-time analytics allow businesses to retrieve data and do something about the data immediately or after the data enters their system. Real-time app statistics answer questions in seconds. They handle large amounts of data at high speeds and low response times. Real-time statistics refer to the process of preparing and measuring data as soon as it enters a website. In other words, users get the data or they can reach conclusions sooner (or sooner) the data enters their system. Real-time statistics allow businesses to respond without delay. They can take advantage of opportunities or prevent problems before they occur.

Real-time math is a discipline that uses intelligence and statistics in data to provide information to make better decisions faster. In some usage cases, real time means that the calculations are completed within a few seconds or minutes after the new data arrives. The required real-time statistics wait for users or systems to request a query and submit statistical results. Ongoing real-time statistics are very effective and alert users or trigger responses as events occur.

2. What is the importance of real-time analytics?

Real-time analytics enable businesses to respond without delay, quickly detect and respond to patterns in users’ behaviour, exploit potential opportunities and prevent problems before they arise.

Entities that use real-time analysis significantly reduce risk across their entire company as the system uses data to predict results and suggest alternatives rather than relying on predictions based on past events or recent scans — as is the case with historical data analysis. Real-time statistics provide details about what is happening right now.

Other benefits of real-time statistics include:

Viewing data: Real-time data can be visualized and reflect events across the company as they occur, while historical data can only be entered into a chart to convey a complete perspective.

Improved competition: Businesses that use real-time statistics can identify trends and benchmarks faster than their competitors who still use historical data. Real-time statistics also allow businesses to review performance reports from partners and competitors quickly.

Specific information: Real-time analysis focuses on quick analysis that is always useful for creating focused results, which helps ensure that time is not wasted on useless data collection.

Low cost: While real-time technology can be expensive, their many and continuous benefits make them a great advantage if used long-term. In addition, technology helps to prevent delays in using resources or accessing information.

Quick results:

The ability to quickly separate raw data allows queries to collect relevant data and process it quickly. This, in turn, allows for faster and better trend predictions and decision-making.

Speed ​​is a key advantage of real-time data analysis. The less time a business has to wait for data to reach the time it arrives and is processed, the more quickly an entity can use data to make changes and work with important decisions. For example, analyzing the monitoring data from the production line can help to intervene early before equipment malfunctions.

Similarly, real-time data analysis tools allow companies to see how users interact with a product when it is released, which means there is no delay in understanding user behavior in making the necessary changes.

Real-time analysis offers the following advantages over standard calculations:

1. Create interactive analysis tools.

2. Share information on transparent dashboards.

3. Customize your behaviour.

4. Make adjustments as needed.

5. Use machine learning.

Other benefits and uses include:

Local data management — Helps determine the appropriate local data sets and what needs to be updated to get the full local intelligence.

Confusing discovery — Identifies statistics caused by security breaches and technical failures.

Better Marketing — Gets information on demographics and customer behavior to improve the effectiveness of advertising and marketing campaigns. It helps determine the best pricing strategies and target audience.

3. Why to use Redis?

Functional statistics dashboards serve a number of purposes. They allow you to share data and provide you with all that important information to make decisions that change the game very quickly. Creating a real-time dynamic dashboard using a standard social networking site may require a set of complex questions. By using NoSQL website like Redis, you can create a powerful interactive and dynamic dashboard with a small number of Redis commands.

#What is Redis?

Redis is an open source (BSD licensed), in-memory data structure store used as a database, cache, message broker, and streaming engine.

Redis Cache delivers sub-millisecond response times, allowing fast and powerful real-time applications in industries such as games, fintech, ad-tech, social media, healthcare, and IoT. This tutorial shows a basic mathematical dashboard application written in NodeJS (JavaScript) that uses the Redis Bitmap data type.

Redis provides data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperlog logs, geospatial indexes, and streams. Redis has built-in replication, Lua scripting, LRU eviction, transactions, and different levels of on-disk persistence, and provides high availability via Redis Sentinel and automatic partitioning with Redis Cluster.

TAKING A POINT OF VIEW TO IMPLEMENT THIS IN GOOGLE CLOUD PLATFORM

In today’s fast-paced world, the emphasis is on instant gratification. Common operating conditions include SaaS operators who provide real-time metrics for their KPIs or marketers’ need for quick data on the performance of their offerings or website testing.

This solution will show you how to build a real-time website statistics dashboard in GCP.

Google Cloud Components used:

1. Pub/Sub

2. Dataflow

3. Redis Enterprise

Pub/Sub enables you to create systems of event producers and consumers, called publishers and subscribers. Publishers communicate with subscribers asynchronously by broadcasting events, rather than by synchronous remote procedure calls (RPCs).

Dataflow is a managed service for executing a wide variety of data processing patterns. The documentation on this site shows you how to deploy your batch and streaming data processing pipelines using Dataflow, including directions for using service features.

Redis Enterprise is integrated with Google Cloud to provide a best-in-class customer experience in two major deployment form factors, a fully managed service, and a self-managed software. Redis operates as a key value store, allowing for many popular usage situations such as cache, session management and works with confidence as the main site for real-time applications. It enables many different verticals such as marketing, financial services, online games, social media, and much more to use your important apps on Google Cloud.

#How to access Redis Enterprise?

Customers have the options to subscribe to fully managed service through Google Cloud Marketplace or directly on Redis Enterprise Cloud at https://app.redislabs.com. If a customer purchases through Google Cloud Marketplace, then following are the benefits:

1. Google Cloud commit drawdown

2. Unified billing within Google Cloud

Comparison of Google Cloud Marketplace and Redis Enterprise Cloud

Here comes the solution,

We are going to start with pub/sub which is an event bus or a message bus which takes all the real-time events from whenever they are being generated. Assume that we have a web application or a web site which is generating all of these events and we are running experiments on that website so first we have a pub sub which takes all the events from the website behind it we have a data flow which is actually going to process that events or process those events generate any sort of metrics. Then instead of putting that into a traditional database we are going to put that into Redis Enterprise which is our managed version of database. Now, why memory store the reason for memory store is Redis allows us to do operations inbuilt which can do all these kinds of cardinality and set operations I don’t have to code for it.

You’re going to have these events going into pub sub a messaging bus. It’s then going to go into data flow which is going to provide a real-time streaming data pipeline. Which will then go into Redis memory store and then you’ll be able to have a real-time dashboard that’s sitting on top of that effectively.

Steps to Perform:

Create Pub/Sub Topic: Pub/Sub is a global message bus enabling easy message consumption in a decoupled fashion. Create a Pub/Sub topic to receive application instrumentation messages.

Create VPC Network: Creating a separate VPC network with external ingress blocked by a firewall provides basic security for the instance.

Start analytics pipeline: The analytic metrics pipeline will read click-stream messages from Pub/Sub and update metrics in the Redis database in real-time. The visualization application can then use the Redis database for the dashboard.

Start the website event generator: Event generator is a Python executable, which needs to keep running, this can be achieved by launching the generator in a separate shell session.

Run the Visualization Engine: Use the simple reporting application located in dashboard/ folder, built using SpringBoot and simple HTML+JS based UI. The application reads the metrics from the Redis database and makes it available to the dashboard UI. The Application server needs to be on the same VPC network as the Redis server, to achieve this for demo purposes, we will use a Proxy VM to tunnel the ports to Cloud Shell VM, as its not on the same network.

References:

1. https://redis.com/blog/redis-enterprise-on-google-cloud-five-deployment-scenarios/

2. https://github.com/GoogleCloudPlatform/redis-dataflow-realtime-analytics

Learn More about Redis:

· Try Redis Cloud for free

· Watch this video on the benefits of Redis Cloud over other Redis providers

· Embed this video if possible

· Redis Developer Hub — tools, guides, and tutorials about Redis

· RedisInsight Desktop GUI

--

--

Murari Ramuka
Google Cloud - Community

Data Enthusiast who help in key data driven outcome with Cloud Data Platform implementation