Get the App
SLTechnology News&Howtos  ›  Database  › 

How to solve the MySQL synchronization delay

Shulou Source: shulou.com Published: 2022-05-31 21:26:13 09月11日 Update

This article shows you how to solve the MySQL synchronization delay, the content is concise and easy to understand, can definitely brighten your eyes, through the detailed introduction of this article, I hope you can get something.

1: apply the solution

In development, assuming that the delay exists, it must be rigorous for the core business, such as the article queue. If you cannot get the article information from the slave database, should you post the queue again or query from the master database to minimize the impact of the delay? of course, the complexity of the design increases.

If you rely heavily on caching, it is more difficult to solve how to prevent cached information from being dirty.

2: lighten the burden

Mysql cannot be added, deleted, changed or checked. To keep the amount of data under control, I like to delete data without affecting the application. A solution that seems to be very low is actually very effective.

Try to reduce slow queries. In the past, synchronization delays were caused by queries, but not this time, but by a large number of queue updates and inserts, such as full push to users every day, long-term high concurrent writes, and synchronization is inevitable. therefore, it is necessary to control the amount of concurrent writes and updates.

3: choose the right solution

Mysql is used as storage as much as possible, because large-scale queries and updates are not its advantage, so non-core businesses can consider redis and mongodb, especially queue solutions. Mysql is not recommended, or there are multiple solutions.

4: split

Limited by the mechanism of mysql itself, the parallel replication ability can be improved by upgrading the mysql version. Or use multiple libraries or even multiple mysql instances according to different scenarios to prevent core services from being affected.

On the one hand, the service can be decoupled, on the other hand, it is easy to expand. This is also one of the solutions to divide and rule.

5: load balancing

Sometimes it is found that there is no delay in some slave library, just one delay. You can remove this slave library through strategy, but you must be aware that this is only a temporary solution, and a large number of delays indicate that the problem may already be serious.

The above is how to solve the MySQL synchronization delay. Have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Tags: Delays solutions synchronization queues queries articles impacts updates business information content can be passed through multiple skills data cores for example knowledge caching Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Shulou Tech Info OPPO Reno Redmi MySQL