Briefly describe the difference between Redis and MySQL

  • 2021-09-11 21:43:12
  • OfStack

As we know, mysql is persistent storage, which is stored on disk. If retrieved, it will involve a fixed IO. In order to solve this bottleneck, cache appears, such as memcached (mc for short), which is used most now. First, the user accesses the mc, and if it misses, accesses the mysql, and then copies the data to the mc1 section like memory and hard disk 1.

Both redis and mc are cached and run in memory, which greatly improves the access speed of web access with high data volume. However, mc only provides a simple data structure, such as string storage; redis provides a large number of data structures, such as string, list, set, hashset, sorted and set, which makes it much more convenient for users. After all, it encapsulates one layer of practical functions and achieves the same effect at the same time. Of course, redis is used and mc is slowly abandoned.

The relationship between memory and hard disk, hard disk places main data for persistent storage, while memory is the part of data currently running. CPU accesses memory instead of disk, which greatly improves the running speed. Of course, this is based on the principle of localized access of programs.

Inference to redis+mysql, which is a mapping of memory + disk relationship, mysql is placed on disk and redis is placed in memory. In this way, web application only accesses redis every time, and only accesses Mysql if no data is found.

However, the usage of redis+mysql and memory + disk is preferably different.

The former is a main memory database, and the data is stored in memory, which is of course fast.

The latter is a relational database, which is powerful and slow to access data.

Like memcache, mongoDB and Redis, they all belong to No sql series.

It is not a type of thing, and the application scenario is not very 1, but it depends on your needs.

Summarize

The above is the whole content of this article about briefly describing the difference between Redis and MySQL. Interested friends can refer to the analysis of sentence execution sequence of sql and MySQL, several important MySQL variables, and a brief analysis of the difference between FIND_IN_SET () and IN in Mysql. If there are any shortcomings, please leave a message for correction. I hope it will be helpful to everyone.


Related articles: