Reducing the burden to the database of the seven skills

The face amount of the hundreds of thousands of database data, how to ensure its stable operation?

One way is to burden the database.

Here are seven tips to offload database:

1. Cache

We can cache data directly into memory. For example the Map, the frame buffer may be used, some of the hot frequently used data stored in the cache, each time the user accesses, the data can be directly returned to the user in the cache, which can effectively reduce the pressure on the server. However, the cached data can be used, are generally not too high real-time requirements.

2. static pages

In fact, this can be regarded as another form of cache, the equivalent of directly related pages rendering results saved. In the Web project, the resources are divided into two categories, namely static and dynamic resources. The former can not go through the server process, will be able to return directly to the front-end browser, the browser can be displayed directly. While the latter need to go through server-side rendering, in order to return to the front.

In the actual project, the access speed of static resources is much higher than the dynamic resource, and dynamic resource bottlenecks often vulnerable server, database bottlenecks. Thus, for some infrequently updated or slow page update, developers can by static pages, save a dynamic resource for static resources, so that when the server needs to access, return directly to the static resources, you can avoid going database operations, thereby reducing the pressure in the database.

3. Database optimization

Many times the program runs slowly, not because of outdated equipment, but because the SQL database written too bad. To solve the problem of massive data, database optimization and certainly inevitable. Generally, the developer can optimize the SQL, optimization table structure, and a plurality of sub-table database partitions aspects like optimize the database.

4. The data separating hot

Data in the database, although huge amounts of data, but the data and all the data are not necessarily active data, such as user registration, user registration done some disappeared without a trace, and some users are in constant log in. Therefore, for two different users, developers can separate the active users, active users save only the data in the data table the main operation. Each time a user logs on, go to the main table view there is no record, so, log in directly, if not, go see the other tables. Is determined by a user login times within a certain time, it can be quickly separated hotspot data.

The consolidating database operations

In fact, the purpose of this program is to reduce the number of database operations, such as multiple insertions, developers can merge a SQL query to get more different conditions, if conditions allow, can also be combined into a single query, to minimize the operation of the database, reducing the consumption of the network, while also reducing the pressure on the database.

6. Distributed Database

After the separate read and write the database, potentially increasing the complexity of the code, it is generally required by a distributed database middleware, which can effectively improve the flexibility of the database, the database can always expansion, but also reduces the coupling of the code.

7. NoSQL and Hadoop

The introduction of NoSQL and Hadoop is one of the solutions. NoSQL breaking the old rules of a relational database table defined in the structure, field or the like, the user can be very flexible and convenient operation, by additionally features NoSQL plurality of memory blocks for storing data, such operation includes a natural advantage (fast). And you do not have to say Hadoop, big data processing tool.

to sum up:

Caching, static pages, database optimization, hot data separation, data merge operations, distributed databases, NoSQL and Hadoop, we generally do is use database optimization and caching techniques, such as the use redis.

Original Address:

https://www.ryanzoe.top/%e6%95%b0%e6%8d%ae%e5%ba%93/seven-skills-to-reduce-the-burden-of-database/

Guess you like

Origin www.cnblogs.com/ryanzheng/p/11294442.html