NoSQL Why to use the Nosql_ database other

Source: Internet
Author: User
Tags hash memcached database sharding

NoSQL in 2010, big and small web site in the pursuit of high-performance high reliability, involuntarily chose NoSQL technology as a priority. At the beginning of this year, the Infoq Chinese station was fortunate enough to invite Mr. Sun Li of Phoenix to share his experiences and experience in NoSQL.

It is a great honor to be invited to open up such a column on NoSQL in Infoq, Infoq is a technical media I very much respect, and I also hope to use INFOQ to promote the development of NoSQL in China and hope to join with my interested friends. The NoSQL column series will first introduce NoSQL, then explain how to apply nosql to their own projects in the appropriate scenario, but also appropriate analysis of some successful cases, I hope that the successful use of NoSQL experience to provide me with some clues and information.

NoSQL concept

With the rapid development of web2.0, the non relational and distributed data storage have been developed rapidly, they do not guarantee the acid characteristics of relational data. The concept of NoSQL was put forward in 2009. The most common explanation for NoSQL is "non-relational", and "not only SQL" is also accepted by many people. (The term "NoSQL" was first used in the name of a lightweight relational database in 1998.) )
NoSQL is the most used Key-value storage, of course, there are other document-type, column storage, graph database, XML database and so on. Before the NoSQL concept was presented, these databases were used in a variety of systems, but were rarely used in Web applications. such as CDB, QDBM, BDB database.

Bottleneck of traditional relational database

Traditional relational database has a good performance, high stability, history test, and the use of simple, powerful, but also accumulated a lot of success stories. In the Internet domain, MySQL has become the absolute front of the king, no exaggeration to say that MySQL for the development of the Internet has made outstanding contributions.
In the 90 's, the number of visits to a website is generally small, with a single database can be easily dealt with. At that time, more static web pages, dynamic interaction type of the site is not many.
In the last 10 years, the website began to develop rapidly. Hot forums, blogs, SNS, micro-blog gradually lead the trend of the field of the Web. In the initial stage, the flow of the forum is actually not very large, if you contact the network earlier, you may remember that time there are text-type storage forum procedures, you can imagine the general forum of how much traffic.

Memcached+mysql

Later, with the increase in traffic, almost most of the Web sites using MySQL architecture began to have performance problems on the database, and Web programs were no longer focused on functionality, but were also pursuing performance. Programmers are starting to use caching techniques to ease the pressure on the database, optimizing the structure and indexing of the database. The beginning of the more popular is through file caching to alleviate database pressure, but when the traffic continues to increase, many web machines through the file cache can not be shared, a large number of small file caches also bring a relatively high IO pressure. At this time, memcached will naturally become a very fashionable technology products.
As an independent distributed caching server, Memcached provides a shared high performance caching service for multiple Web servers, and expands the Memcached caching service based on the hash algorithm on the memcached server. Then there is the consistency hash to address the drawbacks of increasing or decreasing the cache invalidation caused by the cache server. At that time, if you go to the interview, you say you have memcached experience, certainly will add points.

MySQL master-slave read and write separation

Because of the increased write pressure on the database, memcached can only alleviate the reading pressure of the database. Reading and writing focus on a database to overwhelm the database, most sites began to use master-slave replication technology to achieve read and write separation to improve read-write performance and read Library scalability. MySQL's Master-slave model became standard at this time of the site.

Sub-table Library

As the web2.0 continues to develop at a high speed, in the memcached cache, MySQL master-slave replication, read and write separation based on the MySQL Main library write pressure began to appear bottlenecks, and the continuous increase in data volume, because MyISAM use table lock, in high concurrency will appear serious lock problem, a large number of high concurrency mysq Application starts using the InnoDB engine instead of MyISAM. At the same time, it is popular to use the sub-table to alleviate the problem of the expansion of write pressure and data growth. This time, the sub-table has become a hot technology, is a hot interview problem is also the industry's hot technical issues discussed. Also at this time, MySQL introduced a less stable table partition, which also gives the technical strength of the general company brought hope. Although MySQL launched the MySQL cluster cluster, but because there are few successful cases on the Internet, performance can not meet the requirements of the Internet, but the high reliability provides a very big guarantee.

MySQL's extensibility bottleneck

In the Internet, most MySQL should be IO-intensive, in fact, if your MySQL is CPU-intensive, then it is possible that your MySQL design has a performance problem, need to optimize. MySQL application development is becoming more and more complex and more and more challenging in the high data volume and concurrency environment. It is necessary to grasp the rules of the Sub-table database. Although powerful companies such as Taobao have developed transparent middleware layers to mask the complexity of developers, they cannot avoid the complexity of the entire architecture. The fader of the sub-Library is faced with the problem of expansion at a certain stage. There is also the need for change, may require a new way of the library.
MySQL database also often stores some large text fields, resulting in a very large database table, in the database restore time to cause very slow, it is not easy to quickly restore the database. For example, 1000 4KB size text is close to the size of 40GB, if you can save this data from MySQL, MySQL will become very small.
Relational databases are powerful, but they are not a good response to all of your application scenarios. MySQL's scalability is poor (requires complex technology to achieve), large data under IO pressure, table structure changes difficult, is the current use of MySQL developers face problems.

Advantages of NoSQL

Easy to expand

There are a variety of NoSQL databases, but a common feature is to remove the relational characteristics of relational databases. There is no relationship between the data, so it's very easy to expand. Also invisible, at the architectural level to bring the ability to expand.

Large amount of data, high performance

The NoSQL database has very high read and write performance, especially in large data volumes, and also performs well. This is due to its relationship, the structure of the database is simple. General MySQL use query cache, each table update cache failure, is a large granularity of cache, in response to the frequent application of web2.0 interaction, Cache performance is not high. and NoSQL Cache is a record-level, is a fine-grained cache, so nosql on this level will be much higher performance.

A flexible data model

NoSQL you can store a custom data format at any time without creating a field for the data that you want to store. And in the relational database, adding and deleting fields is a very troublesome thing. If it's a very large amount of data, adding fields is a nightmare. This is particularly evident in the web2.0 era of large data volumes.

Highly Available

NoSQL can easily implement highly available architectures without impacting performance. For example, the Cassandra,hbase model can also be used to achieve high availability through replication models.

Summarize

The emergence of the NoSQL database makes up for some deficiencies in relational data (such as MySQL), which in some respects can greatly save development cost and maintenance cost.
Both MySQL and NoSQL have their own characteristics and use of the application scene, the close combination of the two will bring new ideas for the development of web2.0 database. Let relational databases focus on relationships, and NoSQL focus on storage.

Reference reading

nosql:http://nosql-database.org/
NoSQL's introduction on the wiki: Http://en.wikipedia.org/wiki/NoSQL
NoSQL Related blog: http://nosql.mypopescu.com/
NoSQL Related blog: http://blog.nosqlfan.com/
Sina Weibo nosql Micro Group: http://q.t.sina.com.cn/127870

About the author

Sun Li, currently in charge of the development of the bottom group in Phoenix. Worked for Sohu and Ku6. Years of Internet experience and program development, a wealth of experience in the development of distributed search engines, high concurrency, large data Web Site System architecture optimization, high availability, scalability, distributed system caching, database sharding, etc., and experience in operation and maintenance monitoring and automation control. Author of Open source project Phplock,phpbuffer. Recently developed a NoSQL database storage Inetdb, is a NoSQL database enthusiasts. His Sina microblog is: http://t.sina.com.cn/sunli1223
Thank Zhang Kai for the planning and proofreading of this 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.