Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of storing data in Asynchronous redis queue

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Business requirements

The json data sent by the app client to the server interface is sent once a day and will be sent again after clearing the cache.

Business logic before the problem:

The php interface first converts json into an array to re-insert non-existent data into a large table.

The user already exists and the new id

Enter another table of details

The problem is:

When the user clears the cache due to special circumstances, the app sends json string into the library and the concurrency is high, which causes the CPU to soar to 88% and remain high.

Optimization ideas:

1. Asynchronous queue processing

2. Redis filtering (that is, only the first request of the day is processed)

3. Redis auxiliary storage app name (batch insert data app name table after verification)

4. Splicing, inserting and adding, such as in the details table

Solution:

1. Modify the API redis filter + such as list queue and store the result in redis

First of all, redis puts the previous historical data in the redis hash with the Chinese key name id as the key value.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report