A preliminary study of NoSQL Redis database

Source: Internet
Author: User
Tags cassandra download redis memcached

I. The development requirements of the Web2.0 era after the 1.1 of NoSQL

With the rise of the internet Web2.0 website, the traditional relational database in coping with Web2.0 website, especially the super-large-scale and high-concurrency SNS type Web2.0 Pure dynamic website has appeared to be inadequate, exposing a lot of difficult to overcome problems:

(1) high concurrency and read-write requirements for databases

Web site based on user personalized information to generate dynamic pages in real-time and provide dynamic information, so basically can't use dynamic page static technology, so the database concurrency load is very high, often to achieve tens of thousands of reads and writes requests per second. The relational database is barely able to cope with tens of thousands of SQL queries, but with tens of thousands of requests for SQL write data, hard disk IO is already unbearable.

(2) The need for efficient storage and access to massive amounts of data

For the large-scale SNS website, the daily user generates a huge amount of user dynamics, taking foreign friendfeed as an example, one months to reach 250 million user dynamics, for the relational database, in a 250 million records of the surface of the SQL query, the efficiency is extremely low even intolerable.

(3) high scalability and high availability requirements for the database

In the Web-based architecture, the database is the most difficult to scale out, when the number of users and access to an application system is increasing, your database is not as simple as the Web server and application server to add more hardware and service nodes to expand performance and load capacity. For many websites that need to provide 7 * 24 hours uninterrupted service, it is very painful to upgrade and extend the database system, which often requires downtime maintenance and data migration, why can the database not be extended by constantly adding server nodes?

In the face of the above-mentioned " three high " demand, the relational database has encountered insurmountable obstacles, and for the Web2.0 site, many of the main features of the relational database are often useless, for example:

(1) database transaction Consistency Requirements

Many web real-time systems do not require strict database transactions, the requirements for read consistency is very low, and some occasions write consistency requirements are not high. Therefore, database transaction management becomes a heavy burden under the high load of database.

(2) The realistic and real time demand of the database

For a relational database, a query is made immediately after inserting a piece of data, and it is certainly possible to read the data. Does not require such high real-time nature.

(3) requirements for complex SQL queries, especially multi-table associated queries

Any large data volume of the Web system, are very taboo of multiple large tables of related queries, as well as complex data analysis types of complex SQL report query, especially the SNS type of Web site, from the requirements and product design perspective, to avoid the emergence of this situation. Often more than just a single table of primary key query, as well as single table simple conditional paging query, SQL function has been greatly weakened.

Therefore, the relational database is less suitable in these more and more application scenarios, and the non-relational database to solve this kind of problem arises . NoSQL is a generalized definition of non-relational data storage. It breaks the unification of long-term relational database and acid theory . NoSQL data storage does not require a fixed table structure (for example, stored as key-value pairs, its structure is not fixed, each tuple can have a different field, each tuple can add some of its own key-value pairs, so that it is not limited to fixed structure, can reduce some time and space overhead), There is usually no connection operation.

1.2 NoSQL's unparalleled features

The performance benefits of relational databases are unmatched in big data access, such as:

(1) easy to expand

There are a variety of NoSQL databases, but one common feature is the relationship-based nature of relational databases. there is no relationship between the data , so it is very easy to expand. Also invisible, at the level of architecture brings the ability to expand.

(2) large data volume, high performance

NoSQL databases have very high read and write performance, especially in the case of large data volumes. This is due to its non-relational nature, the database structure is simple.

(3) Flexible data Model

NoSQL can store custom data formats at any time without having to create fields in advance for the data to be stored. In the relational database, adding or deleting fields is a very troublesome thing. If it is a table with very large amounts of data, adding fields is simply a nightmare. This is especially true in the Web2.0 era of large data volumes.

(4) High Availability

NoSQL can easily implement a highly available architecture without compromising performance. For example, the Cassandra,hbase model can also be highly available by copying the model.

  In summary, the non-relational nature of NoSQL makes it the darling of the post-Web2.0 era, and it is a new revolutionary movement of the database to help the large Web2.0 website take off again.

Second, Redis's stand out

As applications increase in demand for high performance, NoSQL is increasingly rooted in the system architecture of each name enterprise. Today, there are many types of nosql products, such as Membase, MongoDB, Apache Cassandra, COUCHDB, and so forth. However, at home and abroad internet giants such as social giants such as Sina Weibo, media giant Viacom and picture-sharing leader Pinterest , and other companies have adopted the Redis as its NoSQL database choice, Where exactly is Redis? Can let so many famous enterprises for it and crazy.

According to the official statement, Redis is an open source, written in C, for "key/value" (key/value) type data-based distributed NoSQL database system, characterized by high performance , persistent storage , adapt to high concurrency of the application scenario . Therefore, it can be said that Redis is purely for the application, it is a high-performance Key-value database, and also provides a variety of language APIs (including our Big C #). Well, maybe we'll ask: What's the performance? The following is the official Bench-mark data:

the test completed 50 concurrent executions of 100,000 requests .  The set and get value is a 256-byte string.  Linux box is running Linux 2.6, which is X3320 Xeon 2.5 GHz.  Text execution uses the loopback interface (127.0.0.1). Result: The reading speed is 110,000 times/s, the write speed is 81,000 times/s . (Different server configuration performance varies, of course).

Similar to memcached, Redis supports storing more value types, including string (string), list (linked list), set (set), Zset (sorted set-ordered collection), and hash (hash type). These data types support Push/pop, Add/remove, and intersection-set and difference sets, and richer operations, and these operations are atomic. Based on this, Redis supports sorting in a variety of different ways. As with memcached, data is cached in memory to ensure efficiency. The difference is that Redis periodically writes the updated data to disk or writes the modification to the appended record file, and Master-slave (Master-Slave) synchronization is implemented on this basis (data can be synchronized from the primary server to any number of slave servers. From the server can be associated with other primary servers from the server. )。

Therefore, theemergence of Redis, to a large extent, compensates for the lack of memcached such key/value storage, in some cases can be a good complement to the relational database .

3. Redis Installation

The installation process for Redis is simple:

(1) Download Redis installation package Redis-3.2.12.tar.gz:https://redis.io/download

(2) Decompression: TAR-XZVF redis-3.2.12.tar.gz

(3) Installation: sudo make Prefix=/usr/local/redis install

(4) Copy the redis.conf configuration file to the installation directory: [[email protected] redis-3.2.12]# CP Redis.conf/usr/local/redis

(5) Link Redis database:

A preliminary study of NoSQL Redis database

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.