Professional Documents
Culture Documents
Redis
Redis
D A T E : 11 T H S E P T E M B E R 2017
AUTHOR: LALIT KHANNA
REDIS
Table of Contents
1. R E D I S .......................................................................................................................................... 3
1.1. P U R P O S E ................................................................................................................................. 3
1.2. W H Y R E D I S ........................................................................................................................... 3
1.3. H I G H L E V E L A R C H I T E C T U R E D I A G R A M ( M A S T E R D A T A ) ................................... 4
1.4. S E Q U E N C E D I A G R A M ( C H E C K M A S T E R D A T A I N C A C H E ) ......................................... 5
1.5. HOW WEB SERVER WILL KNOW REDIS CACHE OR CACHE SERVER IS
A V A I L A B L E .............................................................................................................................................. 6
1.6. F A I L O V E R P R O C E S S .............................................................................................................. 7
1.7. S E C U R I T Y ................................................................................................................................ 8
1.8. M U L T I T E N A N T ....................................................................................................................... 9
1.9. S U P P O R T & P R I C I N G / L I C E N S I N G .................................................................................. 10
1.10. S O M E F A Q ........................................................................................................................... 10
1.11. S T I L L Y O U H A V E Q U E S T I O N S .......................................................................................... 10
REDIS
1. REDIS
1.1. PURPOSE
INTRODUCTION
Redis is an open source, in-memory data structure store, used as
database, cache and message broker. It supports data structures such
as strings, hashes, lists, sets, sorted sets with range queries, bitmaps
and geospatial indexes with radius queries.
Redis has built-in replication & failover, 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.
REDIS
WHAT DOES IT INVOLVE?
For session state it is a configuration change
For data caching given the current architecture of AHS we can start
with one method change and this will yield significant benefits.
Web
Server 1
Sql Server
Balancer 1
Load
Sql Server
Mirror
Web
Server 2
REDIS
1.4. SEQUENCE DIAGRAM (CHECK MASTER DATA IN CACHE)
This sequence diagram shows how we will access the cache & in case absent, how
system will work.
Web Cache DB
User
Server Server Server
Request
Get Data
Response
REDIS
1.5. HOW WEB SERVER WILL KNOW REDIS CACHE OR CACHE
SERVER IS AVAILABLE
We would have Redis reference in our application which helps to talk to Redis.After setting up the
reference we need to pass server name,User/Pwd on application side.
We’ve already written some standard classes on App side which will help us to get or
set in the Redis Cache.
Sample code
<connectionStrings>
<appSettings>
</appSettings>
This code
List<Coutries> CoutryData;
If Cache[“CoutryData]==null
{ CoutryData =GetDataFromDB();
Cache[“CoutryData]!= CoutryData;
Else
REDIS
1.6. FAILOVER PROCESS
In case of server (Redis) crash then automatically data will come from slave, if even
slave will also fail then data will come from DB.
Found Data
Return Data
Server Down
Found Data
Return Data
Get Data
Server Down
Server Down
Return Data
REDIS
1.7. SECURITY
Here is roadmap.
1.) Cache can only be access using User/Pwd. We would have different user/pwd based
on environments (i.e . Dev/QA/Prod)
3.) As this is under Linux system which is also protect all the resources.
4.) In case of sensitive data then we will use encryption from application side.
Please find below links which tells some of tips to secure for Redis Sever
https://www.1and1.com/cloud-community/learn/database/redis/securing-a-redis-installation/
REDIS
1.8. MULTITENANT
Redis running on an average Linux system can deliver even 1 million requests per
second. Redis can handle up to 2^32 keys, and was tested in practice to handle at least
250 million keys per instance.
Every hash, list, set, and sorted set, can hold 2^32 elements.
We could use this for multiple clients respect to caching because we've common master
data for all the clients, In case you've different data then we could have different key to
store in same server. This will bring very low cost model for us & awesome results.
Client C
Client B
Client A
Master
DB:D1Ma Data/
ster Data changeable
Data
Redis Server
Master
Master Data/
Data changeable
Data
Client F
Client D Client E
REDIS
1.9. SUPPORT & PRICING/LICENSING
https://redislabs.com/pricing/
https://azure.microsoft.com/en-in/pricing/details/cache/
I'm not sure buying support from Redis because it is not that complicated technology
which can't be built in house. Off-course there is some learning curve. One point as I
said in section 1.5, If Master Server fails, it goes to Salve.. in worst situation if salve fails
then Automatically data will come from DB server so no big impact .Redis is very much
Robust system. It never crash just like that.
Just FYI: We've already built the servers & did one round of testing.
https://redis.io/topics/license
Cost Benefits from Redis Cache: In current environment our focus is only SQL Server
because of that all the burden is on SQL Server, so we're keep increasing RAM, Core etc
in SQL Server which is going to surely cut in future with the REDIS, at least limiting
what we've. As we’re using REDIS for multitenant which will help us to save lot of
money.
https://redis.io/topics/faq
REDIS