当前位置:网站首页>Differences between redis and mongodb
Differences between redis and mongodb
2022-07-25 10:32:00 【colours starry sky】
MongoDB More like MySQL, Support field Indexes 、 The cursor operation , Its advantage lies in the powerful query function , Good at query JSON data , It can store a lot of data , however Unsupported transaction .
Redis It's open source (BSD The license ) Of , Data structure storage system in memory , It can be used as a database 、 Caching and message middleware . It supports multiple types of data structures , Such as character string (strings), hash (hashes), list (lists), aggregate (sets), Ordered set (sorted sets) And scope query , bitmaps, hyperloglogs and Geographical space (geospatial) Index radius query . Redis Built in Copy (replication),LUA Script (Lua scripting), LRU Driving events (LRU eviction), Business (transactions) And different levels of Disk persistence (persistence), And pass Redis sentry (Sentinel) And automatic Partition (Cluster) Provide high availability (high availability)
Memory management mechanism
Redis All data is in memory , Write to disk regularly , When there is not enough memory , You can choose the specified LRU Algorithm delete data .
MongoDB Data exists in memory , from linux System mmap Realization , When there is not enough memory , Just put the hotspot data in memory , Other data is on disk .
Persistence mode
mongodb All of the data is actually stored on the hard disk , All data to be operated passes through mmap Mapping to an area of memory .
then ,mongodb Modify the data in this area , Avoid the piecemeal operation of the hard disk .
as for mmap Content on flush To the hard disk is the operating system , therefore , If ,mongodb After modifying the data in memory ,mmap data flush Before going to the hard disk , The system is down , The data is lost .
(mmap System calls are not designed solely for shared memory . It itself provides a different way of accessing ordinary files , Processes can operate on ordinary files like read and write memory .
mmap The system call enables the process to realize shared memory by mapping the same common file . After the normal file is mapped to the process address space , The process can access files just as it can access normal memory , No need to call . read(),write() Wait for the operation .mmap It doesn't allocate space , Just map the file to the address space of the calling process , Then you can use memcpy Wait for the operation to write the document , without write() 了 . Use... After writing msync() Synchronize , What you write is saved in the file . But there is no way to increase the length of the file in this way , Because the length to map is calling mmap() It's time to decide .)
redis:
It is a real in memory database .
Supported data structures
Redis The data structure supported is rich , Include hash、set、list etc. .
MongoDB The data structure is relatively simple , But support rich data expression , Indexes , Most similar to relational databases , The supported query languages are very rich .
Data volume and performance
When there is enough physical memory ,redis>mongodb>mysql
When physical memory is not enough ,redis and mongodb Will use virtual memory .
In fact, if redis To start virtual memory , It's obvious to either add memory , Or you change the database .
however ,mongodb Dissimilarity , as long as , Business guarantees , Read write ratio of hot and cold data , Make the hot data in physical memory ,mmap Less exchange .
mongodb Still guaranteed performance .
performance
Both of them have high performance , It should not be a bottleneck .
reliability
Both support persistence .
Transaction support
Redis Transaction support is weak , It can only guarantee the continuous execution of each operation in the transaction
mongodb Unsupported transaction
边栏推荐
- PyTorch 代码模板 (CNN)
- Angr (II) -- angr_ ctf
- 2021 京东笔试总结
- Yiwen society, three necessary packet capturing tools for hackers
- Angr (IX) -- angr_ ctf
- Angr(五)——angr_ctf
- Research summary of voice self-monitoring pre training model CNN encoder
- Idea overall font size modification
- FRP reverse proxy deployment
- Mysql5.7 master-slave database deployment (offline deployment)
猜你喜欢

Pytorch tensor list is converted to tensor list of tensor to tensor using torch.stack()

Attention is all you need paper intensive reading notes transformer

Upgrade glibc 2.29 checking LD_ LIBRARY_ Path variable... Contains current directory error solution
构建 Dompteur 容器问题小记

Add CONDA virtual environment env to the Jupiter kernel

Set up lnmp+discuz Forum

Deadlock event of thread pool

复现 ASVspoof 2021 baseline RawNet2

6.shell之正则表达式

Angr(六)——angr_ctf
随机推荐
Angr (x) - official document (Part1)
Swing component
bug要素
[untitled]
Principle of struct2
5.这简单的 “echo” 用法隔壁小孩能不会吗!
6.PXE结合Kickstart原理和配置实现无人值守自动装机
for循环:水仙花案例
3. Believe you can understand! Circular statements and functions of shell scripts, arrays, bubble sorting
测试基本概念
平凡人的一生的意义是什么?
Use of mongodb
8. SHELL file processing Three Musketeers sed
js 哈希表 02
存储、计算、分布式存储篇(收集整理适合小白)
Virtual private line network deployment
Set up lnmp+discuz Forum
Small knowledge of common classes
存储、计算、分布式虚拟化篇(收集整理适合小白)
Angr(一)——安装