In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
This series of articles are translated from "50 Tips and Tricks for MongoDB Developers". I can't find the Chinese version for the time being. Anyway, I have been studying mongodb deeply recently, so I just want to translate it. On the one hand, enhance the effect of our own learning, on the other hand, let the big family to experience what we mongodb users need to pay attention to.
First of all, I declare that my English level is not too high, and some English translation into Chinese can not find suitable words to express, so the original English words may appear in the article, or the translation in some places will be a little blunt, that is to say, there will be literal translation. The main purpose of translating this book is for everyone to learn and explore. If there is any inaccuracy in translation, or if there is a more accurate translation, please point out that I will correct it in time. Thank you in advance.
Tip#21.Minimize disk access
Minimize the number of disk accesses
Accessing data from RAM is fast, while accessing data from disk is a bit slow. Therefore, most optimization techniques are based on minimizing the number of disks accessed.
Fuzzy matching
Reading data from disk is 1 million times slower than reading data from memory.
Most disk (rotary) hard drives can access data within 10 milliseconds, and then access data from memory in only 10 nanoseconds (depending on what kind of hard drive you use and what kind of memory you use. Here we just make a rough estimate). This means that the ratio of disk access time to RAM access time is 1 millisecond / 1 nanosecond. 1 millisecond is 1 million 1 nanosecond, so accessing disk is 1 million times more than accessing memory.
You can test sequential access to the disk by running the following command on Linux.
Sudo hdparm-t / dev/hdwhatever
It may not return accurate measurements, just as mongodb uses random reads and writes, but you can still see what your machine can do.
What can we do? Here are two simple solutions:
Use SSD
SSD (solid state derives solid state drives) are much faster than rotary hard drives in many ways, but they are smaller, more expensive, difficult to erase safely, and still cannot be compared to the speed of reading from memory. Not to prevent you from using SSD, they can work well with mongodb, but it's not a panacea.
Add more RAM
Adding more RAM means less access to the disk. However, at some point, your data may not be suitable for RAM.
So the question becomes: how do we store T bytes, or even P's own data, on disk? How to write such an application that frequently accessed data is already in memory and moves data from disk to memory as little as possible?
If the way you access data is real-time and random, you will need a lot of RAM. However, most applications are not like this, accessing recent data is more frequent than accessing old data, some users are more active than others, and some regions have more users than other regions. Such applications should be designed to keep specific data in memory and rarely access the disk directly.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.