Why use Redis

Source: Internet
Author: User

Original address: http://igoder.iteye.com/blog/1969848

First explain some of the common concepts in software programming:
The abstract precedes the figurative. This abstraction is not an abstraction of nothingness, but a precursor to something that has not yet been differentiated into a figurative. When that precursor exists, the presence of precursors is degraded to the background and becomes an abstraction.
Structure is the complex of association and interaction.
An interface is a coupling point of a structure.
Architecture is a process from unstructured to structured.
Refactoring is the process from the old structure to the new structure.
In other words, the structure is the result of the architecture, and the architecture is a structured process.
It's wrong to hear people say that language is a tool. Language is not a tool, but it and tools are the extension of the brain. Language is a bridging between intelligence and tools.
It is like that human language is the communication medium between human and human, is the interface between man and tool, and programming language, but the change of human language to another symbol system, so programming language can be regarded as the human brain and computer communication medium.

All things in the world are of a hierarchical nature.
At the beginning, only programmers. Architects, project managers, and product managers are gradually differentiated from programmers, who are at the top of the project and must be familiar with the requirements at all levels, not just at the procedural level. And where the high-level existence, the structure of the control and integration of its core competencies. The structural adjustment here involves all levels, such as personnel structure, cost structure, technical structure, language structure and so on. That is to say, complex project structure is not only the structure of the program, but also the personnel, process, management and other levels of the structure.

Cap theory refers to the nature of three levels of things, three levels refers to data, systems, networks, briefly described as follows:
Consistency: Refers to the consistency of data.
Availability: Refers to the availability of the system.
Fault tolerance: Refers to the fault tolerance of the network.
This three layers of nested inclusion, interlocking, stability in order to reduce, and flexibility and complexity in turn, so the error rate is increased in turn. The lower the simpler, the more important, the more decisive. The network and the system are wrong and can be repaired, and if the data is wrong, it cannot be retrieved. This is in fact consistent and synchronized with the history of the database. So distributed systems allow occasional network problems, but need to ensure availability. Centralized systems that allow occasional availability problems, but need to ensure consistency.

In the words of the world, a long time will be divided into a long time will be combined.
And this world of things, but also in a form of differentiation and structure of the gradual evolution of the way.

The advent of nosql stems from the contradiction between data storage space and data access time.
The storage and access of traditional databases is centralized.
That is to say, where the data exists, go somewhere to access it.
The advantage of centralized mode is data stability, long life cycle, reliable, strong relationship, the disadvantage is that space extensibility is limited.
The representative of the centralized mode is the relational database.

The further differentiation of society makes IT systems also begin to differentiate.
The database also gradually differentiated from the relational database to different domains at different levels.
The behavior of netizens from the beginning of the read-only mode, gradually differentiated into read and write less patterns.
As traffic increases, IO-intensive access (primarily read-intensive) occurs, resulting in slower read times.
In order to improve the performance, the database caching technology is developed, which is mainly to separate the read operation of the database.

With the further development of web2.0, the productivity of Internet users increased, and the total amount of storage began to increase.
While there is still less read-write mode, the write volume has been greatly improved.
The original cache technology can not alleviate the write pressure, and the original space is limited by the hard disk, so began to appear the Sub-Library table, to achieve read and write separation.

Centralized-mode databases begin to diverge: a centralized, stable, and strongly relational structure that develops into a differentiated, fault-tolerant, weakly relational structure.
Data storage space and data access time are further separated.
That is where the data exists and where it is accessed. It is now the data or the old place (hard disk), but the access is in another place (such as memory, or another server). The goal is to shorten the IO path or detach IO for efficient access.

The differentiation of storage space leads to the differentiation of writing, and realizes the effect of space exchanging time. This extension is divided into two modes:
If the horizontal separation (the same level, space separation), such as master-slave replication, sub-database sub-table and other effects, so that read-write separation, IO promotion.
If the vertical separation (different levels, process separation), you can achieve database caching, distributed cache and other effects, can read and write separation, IO promotion.

Redis is first a whole, followed by a vertically separated product (separated from the hard disk into hard disk + memory), then horizontally separated (distributed).
It divides the storage space into two pieces from the inside, dividing the stored procedure into two steps.
And Memcached+mysql is two things that combine the two from the outside. Therefore, in the degree of fit, Redis must have more advantages.
As space is separated, the data begins to separate. Cold data sinks, hot data floats, and in order to keep the data consistent and synchronized, it must be ensured that the two remain in contact at the same time, allowing for immediate updating of data.
On the whole, Redis is a whole, and its overall effect and coherence is greater than the combined effect of m+m. The data synchronization of Redis is done in-house, it is direct synchronization, and m+m must be done by middleware, which is indirect synchronization.
Structurally, Redis's disk storage data is simpler than MySQL, and the memory structure is more diverse and flexible than memcached.
In terms of extensibility, because the Redis chassis is simple and stable, it has good extensibility, and the complexity of the upper layer allows Redis to adapt to more complex business scenarios.

The original industry thought that the m+m problem is:
1, maintenance trouble when expanding;
2, there is inconsistent data;
3, the hit rate drops under high volume data.

And Redis has basically no such problem, so Redis has a tendency to gradually replace memcached.

MySQL later launched a memcached plug-in, providing external interface compatible with the Memcached protocol, so that the two finally became a unified whole.
The memcached plugin can be seen as part of MySQL, so from a nosql point of view, MySQL can also be seen as a nosql one.
because the memcached plug-in toward MySQL, so that the memcached plug-in is also subject to MySQL, namely: memcached plug-in and MySQL more tightly unified, and its life cycle and living space by the constraints of MySQL, a wing is a loss of the loss , once MySQL hangs it also has to hang. Therefore, the introduction of the memcached plug-in, so that memcached presents a contraction of the situation, scalability by the limitations of MySQL.
Overall, the integrity and consistency of the memcached plugin has weakened the benefits of Redis.
Structurally, the memcached plug-in can take advantage of MySQL's own storage and replication, so the storage aspect is better than Redis, while the upper layer's memory structure and operation mode are still weaker than Redis.
From the extensibility, memcached plug-in and MySQL tightly, due to the heavy weight of the chassis MySQL itself, scalability is limited, so that the memcached plug-in distribution capabilities weakened some.

Comprehensive:
The more centralized the system, the more conservative the more closed, the higher the stability, the closer the connection, scalability and scalability is bound to be constrained.
The more open the system, the more differentiation and innovation of architecture, the lower the stability, the more loosely the connection, the scalability and scalability will inevitably gradually expand.
While the system is open and separated, in order to ensure the unity and coherence within the subsystem, it is necessary to maintain the internal contact between subsystems.
This allows modern systems and architectures to evolve in the direction of distribution and networking, spreading outward in a continuous way in a holistic, multi-system manner, as the universe expands.
From the logical structure (not the birth order), this expansion trend can be a simple example of the following:

MySQL--Mysql+handlersocket plug-in-mysql+memcached plug-in-Mysql+memcachedb and mysql+memcached

From the above visible, the system storage architecture from a strong association of the whole, toward a weak link of the individual differentiation, memory application step by step toward the direction of independence, gradually get rid of MySQL constraints, yearning for extreme freedom and flexibility, until memcached completely and MySQL isolation, Time and space are no longer subject to MySQL restrictions and must be indirectly linked by third-party tools to maximize scalability.
Due to the system differentiation, the connection between the system is further weakened, and the system is required to adopt more complex contact methods.
The more the differentiation, the more the middle node, the more complicated the contact way, the lower the stability, the more natural the fault, the greater the maintenance cost.


Redis, in a relatively simple and decentralized way, allows the process to continue.
So why Redis can be better than m+m, the reason is: one is simple structure, the second is the hard disk and memory together.
Because the structure is simple, it is convenient to expand, and because the hard disk and the memory are integrated, the data can be extended synchronously, and the maintenance is simpler.


...

Later will not regularly update the article, in succession, the differentiation process of the logical integrity and coherence some.

Why use Redis

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.