How are redis queue tasks performed?

concurrency problems can be solved with locks, such as optimistic locks and pessimistic locks, but when you see many references to using redis queues, what is the whole process like?
whether it is like this: if you receive a request in the
API, push the task parameters to the redis queue, and then you need to execute the processing queue task. Does this operation keep querying the redis queue and execute it as soon as you find a task?
if 1000 requests are concurrently, Since it"s a queue, isn"t it a long time to wait for the last one to finish?

Sep.23,2021

Isn't

queue a first-in, first-out data format? The principle of his implementation is to forcibly convert multithreading to single threading to avoid some of the problems caused by concurrency.
I have used two scenarios so far

    During the
  1. operation, you need to request a third-party interface, such as sending email and address coding, or if it takes a long time, I will execute it asynchronously, which is actually performing a queue processing task, so that the user will not be aware of it.
  2. this logic: when a user clicks and buys, I will put him in the queue, such as snapping up 1000 units. If there are 1000 units in the queue (usually it will float a bit), I will directly return to the page that has been snapped up. Within 1000, I will return a waiting page, and then let the user jump again after the background processing is completed using methods such as websocket. Generally speaking, at the current computing level, this process takes 3 seconds.

in fact, queue task is a way to optimize the user experience and reduce the difficulty of background processing. You can deal with it directly in the logic, but you can solve the concurrency problem. You also need to solve the problem of false death of the page when it takes a long time to execute the task, and the browser timed out and the third party returned an error. It's not that it can't be solved. It's annoying. I just tried it at first and almost dropped the keyboard.

Menu