Get the App
SLTechnology News&Howtos  ›  Database  › 

The method of storing data in Asynchronous redis queue

Shulou Source: shulou.com Published: 2022-06-01 04:03:24 10月02日 Update

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.

Tags: Data queue memory command pointer name array user details question business task content background that is situation button interface log cache Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Apple MariaDB Shulou Technology Docker