(This page has no text content)
Deep Dive Explore Redis - Its Architecture, Data Structures and Modules like Search, JSON, AI, Graph, Timeseries Suyog Dilip Kale Chinmay Kulkarni www.bpbonline.com
FIRST EDITION 2021 Copyright © BPB Publications, India ISBN: 978-81-94837-763 All Rights Reserved. No part of this publication may be reproduced, distributed or transmitted in any form or by any means or stored in a database or retrieval system, without the prior written permission of the publisher with the exception to the program listings which may be entered, stored and executed in a computer system, but they can not be reproduced by the means of publication, photocopy, recording, or by any electronic and mechanical means. LIMITS OF LIABILITY AND DISCLAIMER OF WARRANTY The information contained in this book is true to correct and the best of author’s and publisher’s knowledge. The author has made every effort to ensure the accuracy of these publications, but publisher cannot be held responsible for any loss or damage arising from any information in this book. All trademarks referred to in the book are acknowledged as properties of their respective owners but BPB Publications cannot guarantee the accuracy of this information. Distributors:
BPB PUBLICATIONS 20, Ansari Road, Darya Ganj New Delhi-110002 Ph: 23254990/23254991 MICRO MEDIA Shop No. 5, Mahendra Chambers, 150 DN Rd. Next to Capital Cinema, V.T. (C.S.T.) Station, MUMBAI-400 001 Ph: 22078296/22078297 DECCAN AGENCIES 4-3-329, Bank Street, Hyderabad-500195 Ph: 24756967/24756400
BPB BOOK CENTRE 376 Old Lajpat Rai Market, Delhi-110006 Ph: 23861747 Published by Manish Jain for BPB Publications, 20 Ansari Road, Darya Ganj, New Delhi-110002 and Printed by him at Repro India Ltd, Mumbai www.bpbonline.com
Dedicated to Redis open-source community
Foreword The NoSQL revolution is, in part, the understanding that there is more than one way of solving a problem. In the past, it was common to use a relational database for every possible use case. NoSQL broke this pattern and allowed developers to choose the tools that fit their application the most. Assembling a puzzle with pieces that actually fit. Redis started as a personal open-source project and quickly became a global phenomenon. The vision behind Redis was very appealing to the development community. It was small, smart, blazing-fast, simple to use, and above all, it worked! Redis did a lot more than key-value operations. It was built as a data structure store, allowing developers to use data types they frequently used in their code. Later came the models, which allowed even more ways to store and manipulate data. These important building blocks allowed great flexibility in application design and opened the door to creative and innovative solutions. It is not just about Redis being the fastest database, it is also about getting better results with a smart and efficient design. Awareness of the business impact of performance and the increase in real-time applications made Redis an obvious choice. Redis’s availability on the cloud, its community, and ecosystem, together with strong Enterprise-grade capabilities made it the default choice. Developers started to embrace Redis as a primary database and discovered ways to use Redis beyond cache.
In this Redis Deep Dive book, Suyog and Chinmay take the readers through their life journey with Redis. They provide great insights into how Redis is used for a variety of use cases beyond cache. Covering best practices for production deployments to ensure resilience, high availability, scaling, and much more. The book can also be viewed as a guide and reference for application design, featuring a wealth of architectural diagrams, code examples, and snippets. As a reader, I have experienced my fair share of articles, books, and tutorials. In my view, the authors found a great balance between a high-level introduction to Redis and its philosophy and a practical guide to build a successful production-grade solution based on Redis. Inspiring asset and helpful reference for any application developer. Tal Shkolnik Senior Director, Solution Architects EMEA, Redis Labs
About the Authors Suyog is a solutions architect at Redis Labs (a database unicorn company in Silicon Valley). Suyog is a technology evangelist, community helper, and has the broad technical knowledge and business experience with a specialization in distributed, micro- services, low-latency, and high-throughput demand mission-critical apps. He is a trusted advisor to Redis Labs customers, which include leading global banking institutions, fintech, telcos, media, and financial service providers. Additional to his professional work, Suyog has also built IT professionals community in Pune called Pune Developer’s Community which has today more than 13000 members, they host technical discussions and meetups in person as well as virtually. Chinmay is the founder and director of Hybrowlabs Technologies, a digital solutions and cloud consultancy company based out of Pune. He helps fortune 500 clients create awesome web applications. He is a passionate speaker of OSS. In his free time, Chinmay likes to read non-fiction books on psychology, history, and philosophy.
About the Reviewers Prakash Sivagnanam is from Noida, India, working as Senior Software Engineer at GlobalLogic. Prakash is well known as Redis Star due to his knowledge sharing and Redis tech talks at various events. Prakash previously dabbled with Microsoft technologies and MCSD, and now working on Blockchain innovations. He is also a Redis certified NoSQL enthusiast. Vikram Sahu is a well-known developer advocate. He has hosted multiple tech talks on several technologies such as Redis, Python, Golang, and full-stack frameworks. He is working as a developer evangelist at Pepipost, specialized in different growth hacking techniques to help the product grow in different forums.
Acknowledgements Both of us authors believe in open-source software development as a collaborative the effort, where developers come together and develop something useful, contribute, improve upon the source code, and share the changes within the community. With the same belief, we came together to write this book on Redis, which is the most loved open-source projects in the software world. There are a few people that we want to thank for the continued and ongoing support they have given us during the writing of this book. First and foremost, Redis creator Salvatore who built this awesome open-source database and provided all of us with very nice documentation. Then, the rest of the Redis Labs team, our CTO Yiftach Shoolman, my manager and mentor Tal Shkolnik, and R&D CTO Guy Kurland, who guided me through this journey. We would also like to thank BPB Publications for giving us this opportunity to write our first technical book with them. Vikram Sahu and Prakash Sivagnanam both worked on this book as technical reviewers. Finally, I would like to thank my wife Snehal and daughter Swara, for putting up with me, while I was spending many weekends and evenings on writing—I could have never completed this book without their support. –Suyog Kale
Firstly, I would like to thank my mother and brother for supporting me in writing the book. I would like to thank members of my team, Pragat Nikam and Sachin Pawar for helping us out in the process of reviewing the book. – Chinmay Kulkarni
Preface In this book, Chinmay and I have tried to cover everything about the Redis NoSQL database. The book discovers a world of use cases where Redis shines beyond that. Suyog is covering the basics to get started, as well as cutting-edge Redis-based technologies, tools, methods, and best practices. Our goal was to split the topics in sections. In the initial section into chapter 1 and we have covered the history of NoSQL databases and their advantages over relational databases. In the next section from chapters 3 to you will be able to know the journey of Redis from its need, how it was designed, its creator and contributors, and what kind of basic data structures it supports. As you read further in the next section chapters 7 and you will learn about scaling on Redis and its module framework, which allows you to truly leverage this in-memory Redis as a multi-model database. Chapters 9 and 10 will take you through the real-time use cases and how Redis Enterprise enhances the open-source Redis to provide you better availability, persistence, and some unique enterprise features. Finally, in the last section 11 and Chpapter we have covered new features of Redis 6 and some useful tips using Redis-client and RedisInsight the tools to access and profile your Redis. If you
want to stay in touch with the Redis community, new blogs, and forums, then you should not miss the last section. We hope that this book will help you to understand Redis’ journey from its rise to becoming the most loved database today. – Suyog and Chinmay
Downloading the code bundle and coloured images: Please follow the link to download the Code Bundle and the Coloured Images of the book: https://rebrand.ly/n2e9iup Errata We take immense pride in our work at BPB Publications and follow best practices to ensure the accuracy of our content to provide with an indulging reading experience to our subscribers. Our readers are our mirrors, and we use their inputs to reflect and improve upon human errors, if any, that may have occurred during the publishing processes involved. To let us maintain the quality and help us reach out to any readers who might be having difficulties due to any unforeseen errors, please write to us at : errata@bpbonline.com Your support, suggestions and feedbacks are highly appreciated by the BPB Publications’ Family.
Did you know that BPB offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.bpbonline.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at business@bpbonline.com for more details. At you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on BPB books and eBooks.
BPB is searching for authors like you If you're interested in becoming an author for BPB, please visit www.bpbonline.com and apply today. We have worked with thousands of developers and tech professionals, just like you, to help them share their insight with the global tech community. You can make a general application, apply for a specific hot topic that we are recruiting an author for, or submit your own idea. The code bundle for the book is also hosted on GitHub at In case there's an update to the code, it will be updated on the existing GitHub repository. We also have other code bundles from our rich catalog of books and videos available at Check them out! PIRACY If you come across any illegal copies of our works in any form on the internet, we would be grateful if you would provide us with the location address or website name. Please contact us at business@bpbonline.com with a link to the material. If you are interested in becoming an author
If there is a topic that you have expertise in, and you are interested in either writing or contributing to a book, please visit REVIEWS Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions, we at BPB can understand what you think about our products, and our authors can see your feedback on their book. Thank you! For more information about BPB, please visit
Table of Contents 1. Introduction to NoSQL World Introduction Structure Objectives Introduction to Redis What are NoSQL Databases Key-value – dictionary kind of data storage Graphical data representation Documents collections Relational – SQL databases Time series records History of NoSQL The evolution of NoSQL ACID properties Base properties Non-relational data storage design Why NoSQL databases Why not relational DBMS Scaling-Up is expensive Predefined schema and inflexible data models Relational databases vs NoSQL databases Conclusion 2. Advantages of NoSQL databases Introduction Structure Objectives
Relational databases terminology Limitations of relational databases NoSQL databases and advantages over RDBMS Benefits of NoSQL Flexible data modeling - non-structured datastore Easy to scale-out High availability Faster go to market Less maintenance cost Open-source Limitations of NoSQL databases Types of NoSQL Databases Key-value Store Document-oriented Databases Column-oriented Database Graph Database Conclusion 3. History of Redis Introduction Structure Objectives Who is the Creator of Redis? More about Redis Creator - Salvatore Sanfilippo How Redis was invented What is Redis Who first used Redis Salvatore’s contribution to open source About Yossi Gottlieb and Oran Agra who is further managing Redis Open source project Web reference to know more about Redis
Comments 0
Loading comments...
Reply to Comment
Edit Comment