Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What's the difference between es and redis?

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you what is the difference between es and redis, I believe that most people still do not understand, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

The difference between es and redis

Redis

Redis is now the most popular key-value database. It was released in 2009 with MongoDB, and it is also a database masterpiece of the early big data era.

The biggest feature of Redis is, of course, the simplicity and high performance that key-value storage brings. The so-called key-value storage means that each record contains only one Key for querying data, and the corresponding value for storing data, just like house numbers and households in real life, without the complex concepts necessary in conventional databases such as tables and fields, and all queries only rely on key values.

Therefore, the key-value database is the simplest data structure in the database, and thanks to this simple structure, coupled with the fact that Redis will load all data into memory, Redis can get much higher read and write performance than conventional databases such as MongoDB. Of course, the function of Redis is not so simple as key-value storage. Compared with its key-value predecessor Memcached,Redis, it also supports data persistence, list, set and other data structures, and some column functions such as master-slave replication and backup, so Redis can definitely be called the most comprehensive and easy-to-use model in key-value database.

Redis's key-valule storage brings performance advantages, but it also brings a lot of limitations to complex queries. Due to the castration of important features such as data tables and fields, and all queries rely on key, Redis can not provide complex query functions such as multi-column query and section query that conventional databases have.

At the same time, because Redis needs to store data in memory, which greatly limits the amount of data that Redis can store, which also determines that Redis is difficult to be used in application scenarios with large data scale.

Redis sacrifices the functions of data tables and complex queries in conventional databases, resulting in a great improvement in performance. It is especially suitable for those application scenarios that require high read and write performance, simple data table structure (key-value, list, set, etc.) and simple query conditions.

If your datasheet structure is complex and you often need to do some complex query operations, you'd better use MongoDB or SQL honestly.

ElasticSearch

ES, which was released a year later, may be less well-known than MongoDB and Redis, but ES's reputation in the search engine field is definitely strong. Compared with other high-end database products, ES has a lot of losers.

Shay Banon, the founder of ES, used to be an unemployed loser programmer who created ES to make it easier for his wife to search recipes when he had nothing to do (not ES at the time, of course). Unexpectedly, inadvertently inserted willow into shade, the achievement of today's most popular search engine database, sure enough, the girl is the biggest driving force for programmers to work!

ES has also set up its own Elastic company, which has received hundreds of millions of dollars in financing, and the failed programmer Shay Banon has already counterattacked into CEO and reached the pinnacle of his life. After reading this story, have you programmers begun to imagine the day when you become CEO and marry Bai Fumei?

The feature of ES, as its name suggests, is search. Strictly speaking, ES is not a database, but a search engine, and all aspects of ES are designed around search. ES supports full-text search. Here is a brief explanation of what full-text search is: for data such as "I work for an Internet company in Beijing", if the keywords such as "Beijing", "Internet" and "work" can hit this data, this is full-text search. Baidu and Google, which you use every day, belong to full-text search.

It is worth mentioning that ES's full-text search also has good support for Chinese (there are many kinds of Chinese word separators alone), which can absolutely meet the full-text search needs of most people in China. In addition to searching, ES will automatically index all fields for you to achieve high-performance complex aggregate queries, so as long as the data stored in ES, no matter how complex aggregate queries can get good performance, and you no longer have to worry about how to build a variety of complex indexes.

After talking so much about the advantages of ES, do you think ES is absolutely omnipotent?

Unfortunately, no, ES also has many disadvantages, the most obvious of which are unmodifiable field types, low write performance, and high hardware resource consumption. As mentioned earlier, ES will automatically build an index for you, although this will bring a lot of benefits to full-text search and aggregate queries and save you the hassle of building an index, but this feature will also cause a lot of problems.

ES needs to pre-establish the type information of each field in the Mapping,Mapping before creating the field, and ES needs to build the appropriate index for the field according to the Mapping. Because of this Mapping, fields in ES can no longer be modified once they are created.

(for example, if you forgot to add a full-text search to a field in your datasheet, you want to add it temporarily, but the table has been built and has a lot of data, what should I do? Sorry, you can only delete the whole datasheet and rebuild it again! )

Therefore, ES is higher than MySQL in data structure flexibility but far inferior to MongoDB. The disadvantages of ES are not only these. Automatic indexing affects the write performance of ES, which is significantly lower than that of MongoDB.

For the same data, ES takes up significantly more storage space than MongoDB (can you build so many indexes without taking up space? ), the consumption of hardware resources is also very strong. 64GB memory + SSD is basically standard under a large amount of data, which can be regarded as an aristocratic service in the database, so if your boss is very stingy, you should be careful about the choice of ES!

ES's full-text search feature makes it a powerful tool for building search engines. In addition, the fact that ES supports complex aggregate queries makes ES very suitable for data analysis.

In fact, ES has specially made its own ELK suite to provide you with an one-stop service from log collection to data visualization and analysis, which is definitely a sharp weapon for building a high-end data analysis platform.

However, the high cost and low write performance of ES also determine that it is not suitable for those scenarios where the data value is not high, the write performance is required, the amount of data is large and the cost is limited.

The above is all the content of what is the difference between es and redis. Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report