Can Redis be used as a Primary database?

Поделиться
HTML-код
  • Опубликовано: 15 янв 2025

Комментарии • 102

  • @hnasr
    @hnasr  3 года назад +11

    Note regarding consistency @5:20: Redis also provides strict serializability(Strong consistency) through the RedisRaft project. RedisRaft has passed the Jepsen tests, an industry standard for verifying the consistency of distributed database systems.
    Read more on RedisRaft here redislabs.com/blog/redisraft-new-strong-consistency-deployment-option/

  • @nesaluj
    @nesaluj 9 месяцев назад +1

    Very nice collation and explaination of insights on Redis, thanks Hussein!

  • @randomexcuse
    @randomexcuse 3 года назад +49

    "Is Redis amazing?" proudly sponsored by Redis.
    Disclaimer: I use redis everyday and love it.

  • @Music_song_Musurmonov_Mehroj
    @Music_song_Musurmonov_Mehroj 3 года назад +77

    Cool stuff, Hussein.
    But, every time you talk about some technology, you always say that everyting has its costs. Every technology has pros and cons.
    But that time you only talked about pros.
    I think this video is more like advertisement rather than regular discussion.
    But anyway, thank you for amazing videos.
    It would be great if you make another video about drawbacks of using Redis as a primary database.

    • @Squawkize
      @Squawkize 3 года назад +12

      I wholeheartedly agree! Being sponsored might have a contribution to this. I know one disadvantage is that it’s all in memory thus your entire database must fit in memory.

    • @Pifagorass
      @Pifagorass 3 года назад +1

      @@Squawkize memory mapped files can store more data than RAM, but definitely may impact performance of the department. What's really missing is uniform queries with optimisations. But yes, agree, in most cases can replace main service store.

    • @rakeshsarangi5161
      @rakeshsarangi5161 3 года назад

      @@Pifagorass can you elaborate more on what do you mean by uniform queries with optimisations?

    • @ultiumlabs4899
      @ultiumlabs4899 3 года назад +1

      My guess, the drawback is the price. The same reason memory is split into: CPU L1 cache, CPU L2 cache, main memory, and hard disk. price vs performance reason.

    • @jaxongirrahimov7908
      @jaxongirrahimov7908 2 года назад

      Bobosher are you uzbek?

  • @xfoxawy
    @xfoxawy 3 года назад

    Thanks!

  • @Pifagorass
    @Pifagorass 3 года назад +9

    How would you do joins, aggregations, and query optimisation?

  • @shaswatkumar4078
    @shaswatkumar4078 2 года назад

    There is so much content for software engineering on you tube, but yours is on a very different level, it may sometimes have less likes but the knowledge level and quality is higher than any other content available online.

  • @cepuofficial9025
    @cepuofficial9025 3 года назад +13

    Good video Hussein but, you still need to be balanced and explaining the pros and cons. Benefit and price.

  • @yegeunator
    @yegeunator 3 года назад +2

    Just what I needed... I was literally just searching for this...

  • @Squawkize
    @Squawkize 3 года назад +6

    I believe you can use Redis as a primary database BUT the circumstances depends on what you need. AOF and snapshot can persist data yea but you’re limited to the ram you have available (which can be expensive). Not only that but less frequently visited data should be in your hd/disk instead of memory since that’s a waste of precious ram being used up. It’s a lot cheaper storing it in hd/disk.
    Would be cool if Redis could store less frequently visited data to the hd/disk in exchange for some loss in speed and once it starts getting many accesses move the data from hd/disk to RAM when needed. Not sure if the loss in speed would be significant implementing this though.

  • @mtnrabi
    @mtnrabi 3 года назад +23

    When discussing choosing a database, you often dont consider the query language capabilities . Different databases has different query languages to suit different needs.
    How come you ignore it so often?

  • @awikwok212
    @awikwok212 3 года назад +5

    I almost mistaken this fireship video lol, but thanks Hussein!

    • @rajaraodv
      @rajaraodv 3 года назад

      Very high quality

  • @ionelCristianLupu_
    @ionelCristianLupu_ 3 года назад +7

    What about relational data, cascading and foreign key checks? If we use Redis as a primary database, we will have to do all of these things in the Application level, right?

    • @luqmansen
      @luqmansen 3 года назад +3

      Yes you're correct, that's the price you have to pay for

    • @BHAVYAMATHURBEE
      @BHAVYAMATHURBEE 3 года назад +4

      Key-value NoSQL databases aren't suitable for joining in the first place. Usually the data is stored in a de-normalized fassion to prevent joining.
      In redis they can still be handled at the database level though with LUA scripts. So instead of clients manually doing join, they can call a pre-cached script in the server that does the joins for them.

    • @ionelCristianLupu_
      @ionelCristianLupu_ 3 года назад

      @@BHAVYAMATHURBEE How do you handle the case when a product name is changed for example? You need to update all the orders and change the product name for each one?

    • @rajaraodv
      @rajaraodv 3 года назад +4

      This is an age-old NoSQL vs SQL paradigm question and not really about whether Redis is a Primary DB or not. In NoSQL DBs (Redis, MongoDB, etc), you model things differently where you optimize for speed over normalization.of data. Here you may embed product name into all the orders so you don't need to do slow Joins for every read (i.e. in a denormalized form). So if you are reading the order details millions of times, you don't do millions of slow Joins. On the other hand, if at some point the product name changes, you run a script to update the product name in all orders. So you end up with millions of fast reads and a few slower updates and overall you come out ahead. BTW, there are multiple, well established patterns to handle these sorts of SQL versus NoSQL questions.

    • @luqmansen
      @luqmansen 3 года назад

      @@rajaraodv Yeah I also agree with this, you have to model your data differently

  • @__redacted__
    @__redacted__ 3 года назад +1

    Maybe three things to think about are 1) what's the literal cost of I/O in memory vs persisted storage on disk needed 2) what's the average and foreseeable max space needed and 3) what's the probability of memory going down or being corrupted vs disk, and what are you willing to tolerate before resorting to backups (or a secondary db)

  • @MrYokyScape
    @MrYokyScape 3 года назад +4

    This video felt more like an ad than a discussion like your usual videos.

  • @promatic-code
    @promatic-code 3 года назад +16

    I have seen redis as cache. Never thought of it as primarily database. Can it be horizontally scaled without downtime?

    • @thenaman047
      @thenaman047 3 года назад

      Short answer Yes.

    • @javilionaire
      @javilionaire 3 года назад +3

      Long answer: No.

    • @kevinshah_tv
      @kevinshah_tv 3 года назад

      Realistic answer: It depends. what is your current configuration? Redis offers something called as a "Redis Cluster" which is a piece of art (coming from someone who wanted to scale Postgres) but it is some work not every library supports its 100% and / or you have to use different methods to interact with it. Also, you have to add nodes in groups i.e. suppose you have 2 replicas per master, you need to add (horizontal scale) 3 nodes at a time (1 writer and 2 replica nodes).

  • @nat6106
    @nat6106 3 года назад +1

    Also important, the types. Redis doesn't have booleans for example, nor does it have support for geolocation pluggins like postgis with postgres

  • @amitkumargoldy
    @amitkumargoldy 3 года назад +5

    Nice video. We recenly did have to use redis for some use cases as the primary source of data. It can work for simpler use cases but falls apart when it comes to slicing and dicing the data. Imagine replacing the "students" table in postgres with data in redis. Say each record contains students name, age, and city. You want to be able to fetch all students whose name starts with "xyz" AND are b/w 12-14 years of age AND live in Vancouver. You will basically end up using 4 different data structures and and a lot of overhead. Store age as a sorted set where weight is the age and the value could be the all student ids. Then store city in another Hash where key is the city and values could be ids. and so on. And then try to fetch all ids and do an intersection in memory and then look up the object with that id. Managing and extending such a system will be a nightmare. :D

    • @madmanX1314
      @madmanX1314 3 года назад

      I had a similar requirement once and I ended up keeping the data in memory of the application itself which was performing way better than using redis while still being maintainable.

  • @aadill77
    @aadill77 2 года назад

    6:25 I am confused if it should be availability concern or reliability concern when the write fails with both master and slave replication?

  • @aneksingh4496
    @aneksingh4496 2 года назад

    Amazing amazing videos ....your content is very crisp and clear 👍👍 ... please keep on updating new videos ...

  • @yooscripts5947
    @yooscripts5947 Год назад

    Amazing in depth video ❤🎉

  • @prakashreddy9546
    @prakashreddy9546 3 года назад +6

    Not recommended , if there is a lot of data , you end up paying lot of money for redis compared to other DB's

  • @lexiaontube
    @lexiaontube 2 года назад

    Very useful, Thanks !

  • @neel3297
    @neel3297 3 года назад +2

    We used Redis a primary database for one high performant requirement

  • @phinance42
    @phinance42 3 года назад +5

    I use Redis as the only database for a toy project. I model relations as sets. (after all, the mathematical definition of a relation is expressed as a set, right?) It works and the performance is great. However, it's quite challenging to maintain data and indexes using only bare Redis' data structures (though possible with transactionned pipelines). I did it for fun, and it was. But, relying on SQL is much easier IMO!
    It's also possible to rely on "hexastore" with zsets to express any complex relations, however, I didn't need to for my app.

    • @PhilipAlexanderHassialis
      @PhilipAlexanderHassialis 2 года назад

      As soon as your data start conforming to a normalized or even semi-normalized form with standard data fields per set-kind / "entity", the argument for Redis as a primary DB goes out of the window. RDBMses are highly optimized for this kind of work and with the right kind of caching strategies and query optimizations, the "Redis as a primary DB" argument becomes laughable at best and punishable-by-flagellation at worst.

  • @dawsdep
    @dawsdep 3 года назад +1

    Hussein, I'd be interested in hearing your thoughts on FaunDB and thank you for covering Redis as a primary database too

  • @jocke8277
    @jocke8277 3 года назад +8

    Never used Redis but it sure looks interesting. Is it good for modelling relational data? What are the downsides to Redis compared to say Postgres?

    • @thenaman047
      @thenaman047 3 года назад +3

      You can say redis is a data structure driven database. For relational data, a lot of operations need to be performed based on the use case. Postgres and redis are very different for doing a direct comparison of features.
      Do a basic reading about redis, to get a good idea about it and think in this way "is it applicable in my application use case or not"

  • @michaelbitzer7295
    @michaelbitzer7295 3 года назад +1

    Would be intresting to hear some thoughts on keydb

  • @kunalmahajan7142
    @kunalmahajan7142 3 года назад +3

    But since we know that redis is an in memory database which means all the data will stored inside the RAM itself. Don't you think the pricing for this will be way higher?

    • @xelaswitch
      @xelaswitch 3 года назад +1

      Redis can actually persist to disk. Visit their site and you will be surprised.

  • @Prakashsharma-eh8uq
    @Prakashsharma-eh8uq 3 года назад +2

    Although it has Primary Database features however it cannot be used for highly OLTP applications due to its serializable trx isolation level

  • @benjaminkir
    @benjaminkir 3 года назад

    Since Redis is executing queries in single thread, why we even need optimistic locking?

  • @AparnaBushan
    @AparnaBushan Год назад

    I have a question, when we say it supports isolation , then does having watch violate it ? If my understanding about watch is correct, then watch will watch if there is any there operation that is trying to update the value I am referring, it will notify and probably fail the transaction. So meaning one transaction is knowing about the other transaction.
    Can you clarify ?

  • @siya.abc123
    @siya.abc123 3 года назад +6

    Dude Redis can even do geo stuff. Redis rocks!!!

    • @jeet987
      @jeet987 Год назад

      What about data loss? In memories have a huge danger of data loss in cloud

  • @sagarrout007
    @sagarrout007 3 года назад +1

    I didn’t know if redis can do so much…..but I felt like you’re the redis developer advocate 😀

  • @pdpro
    @pdpro 3 года назад +2

    I used redis as cache, good to know it can be used as dB also. However, is there any configuration to use it as hot, cold or glacier type?

  • @apusingh1967
    @apusingh1967 2 года назад

    in a multi master deployment, the purpose of which is to shard data, what if a master fails. Is there automatic failover to some replica?

  • @ultiumlabs4899
    @ultiumlabs4899 3 года назад +1

    I think redis drawback is the price. The same reason memory is split into CPU L1 cache, CPU L2 cache, main memory, and hard disk, price vs performance reason. any thoughts?

  • @burabura3861
    @burabura3861 3 года назад

    Great video Hussein. Thanks a lot. I just have one question though mate. At 4:25, there is just one word that my colleagues (Japan) can't make out.
    "The ?????? that you write ..... "
    What is the ?????? word? Please let me know, if you have the time. Thanks so much.

  • @kapssul
    @kapssul 3 года назад

    Hussein, can you schedule a video about limitations and performance benchmarking concerning (in-memory db vs buffer pool) since in both paradigm the memory is involved..

  • @mohanraj-kr9xg
    @mohanraj-kr9xg 3 года назад

    Hey Hussain what is your thoughts on GitHub copilat?

  • @rednafi
    @rednafi 3 года назад +2

    Whether Redis can be used as the primary database or not depends on what you need from your primary database.
    Redis is already better than a few other NoSQL DBs and heck, even "Postgresql is a better Mongo than Mongo".
    However, if your persistence requires RDBMS, then Redis is not that good of an option and honestly, it doesn't need
    to be. Redis is already awesome and can be used as a Swiss army knife while building your next application.
    PS. People who're complaining about the "advertisy" tone of the video should just stop. How else do you think
    he'll be able to pay for stuff and keep producing quality content?

  • @nafasm
    @nafasm 3 года назад

    Thanks Nasser Hussein

  • @mtnrabi
    @mtnrabi 3 года назад +1

    Can you explain how Isolation differs from Concurrency Control? It seems to me like Concurrency Control is part of Isolation

    • @Music_song_Musurmonov_Mehroj
      @Music_song_Musurmonov_Mehroj 3 года назад

      Isolation levels are related to the transaction you're executing.
      It helps you to isolate values being used during transaction from ones in actual database.
      Concurrency control is related to the values in database.

  • @nikhilsrivastava9120
    @nikhilsrivastava9120 3 года назад

    why is a cache considered costly compared to a primary database? if we store everything on redis, wouldn't the COGS overshoot?

  • @balu.92
    @balu.92 3 года назад

    So, will there be a RERN stack soon? 😁

  • @atulchahande4966
    @atulchahande4966 3 года назад

    the only down side is it doesn't have a query language.. which make a things much easy

  • @glennedgar5057
    @glennedgar5057 3 года назад

    Redos makes a good light weight event broker for micro services. This is particularly true at the edge.

  • @zetadoop8910
    @zetadoop8910 3 года назад

    How does keydb compare to redis? It has master + master + slaves configure option. I can write in Master1 and if it fails then I will write Master2. Will keydb sponsor next video?

  • @nicolabelli6928
    @nicolabelli6928 3 года назад +2

    Good content as always Hussein! You do not mention query fetures which are a key feature for a DB. For example how can I store a list of people in Redis and get only the people with age >18, I am supposed to get all keys of readis and cycle trough them in my application in order to filter them? How about paginating the results?

    • @peresypkin
      @peresypkin 3 года назад +2

      It is possible by means of sorted sets. Considering your example, you could add the records to a sorted set using the ZADD command redis.io/commands/zadd, where the score is the age and the member is the person ID, and then you could select a range utilising the ZRANGE command redis.io/commands/zrange. It basically means that you create indexes manually in Redis.

    • @thenaman047
      @thenaman047 3 года назад

      Redis is not your typical database, one needs to understand it's data structures and design their solutions around them.

  • @allanwind295
    @allanwind295 3 года назад +1

    "If you are using Redis in a very write-heavy application, while saving an RDB file on disk or rewriting the AOF log Redis may use up to 2 times the memory normally used." This means you data set has to be smaller than 50% of memory if using RDB. Point in time restore? I believe is no, other than restoring truncated AOF files. The documentation has always been awesome.

  • @prakharvijay8853
    @prakharvijay8853 3 года назад

    Please make a crash course for using Redis as a primary database

    • @aries185
      @aries185 3 года назад +1

      Check out Redis University

  • @mrcrazyenough007
    @mrcrazyenough007 3 года назад +1

    a new camera tech eh?

    • @_prothegee
      @_prothegee 3 года назад

      Looks more sharper, right

  • @martiruda
    @martiruda 2 года назад

    I work with in memory data models built in MSSQL and I have an amazing T-SQL experience thus far & only having tiny hiccups around querying data from external databases and combining datasets with the in memory tables. Can anyone recommend a good t-sql client for Redis?

  • @rishabhanand4270
    @rishabhanand4270 3 года назад +1

    High Quality.

  • @octanebd
    @octanebd Год назад

    It was 2013 that I built a tiny in-memory database and query system with Javascript. I lost interest in its development in couple of weeks as it seemed to me of the concept lacking serious applications. ... It was certainly not a good decision.

  • @MohammodnazmuSakiB
    @MohammodnazmuSakiB 3 года назад

    Redis is very feature rich, but that comes with a hight cost.

  • @samchitgopekar8530
    @samchitgopekar8530 3 года назад +1

    A primary database... that costs an arm and a leg

  • @phamnhuthai6847
    @phamnhuthai6847 3 года назад +1

    I built an inventory system with redis as primary database.
    It require a lot of skills and logic in programming.
    The first build, i have to delete whole database logic and start again.
    You should very well in reading document and take time think about it before coding

    • @ikemeneke
      @ikemeneke 2 года назад

      Pls I need guidance. I want to build system with redis as primary database

    • @phamnhuthai6847
      @phamnhuthai6847 2 года назад

      @@ikemeneke just start with simple online retail store website. You will learn a lot while building it.

  •  3 года назад +1

    Of course it can. But should we?

  • @esraaabdelaziz485
    @esraaabdelaziz485 3 года назад

    I don't think that redis can be used as a primary database cuz redis works at the rams what if the server is down would my data be lost, how even i can maintain my data if the server is down ?? I don't think that redis data persistence techniques is enough and I can't take a snapshot of the data every second

  • @rajeevsingh758
    @rajeevsingh758 3 года назад +1

    I think Redis team has gave you a script and you aren't allowed to say beyond that script. Any way nice video. Video title can be change to All Pros of a Redis in 12 minutes.

  • @missingfaktor
    @missingfaktor 3 года назад

    Does ElastiCache-managed Redis support all the features discussed in this video?

  • @rahuldeepattri9244
    @rahuldeepattri9244 3 года назад +12

    Didn't felt like your honest opinion..More like an advertisement.

  • @rafaelmatsumoto
    @rafaelmatsumoto 2 года назад

    The answer is probably yes, but that depends on how much are you willing to pay

  • @kaushikraina8138
    @kaushikraina8138 3 года назад +2

    Great video man. Keep making epic stuff
    Will appreciate if you can change 'master slave' to 'active passive' terminology

  • @md.fazlulkarim8847
    @md.fazlulkarim8847 3 года назад

    A few carefully written atomic Lua scripts is all we need to replicate all the most needed regular database features!

  • @ganeshdeshmukh8020
    @ganeshdeshmukh8020 3 года назад

    Ans:
    Yes, if it makes easy to do cache-invalidation.
    :)
    love you Hussain sir.

  • @jacocoetzee762
    @jacocoetzee762 3 года назад

    Dude great video with awe info. Let’s make it last longer by not talking about master & slave. It’s 2021.

  • @ElijahLynn
    @ElijahLynn 3 года назад

    Thanks!