Determine the uniqueness of likes based on IP, device number or some unique identifier, use a cache such as redis to update, and then write it to the database asynchronously and synchronously. If the liker is notified asynchronously, the click will be treated as an event and placed in a queue. It can be processed uniformly.
Lock likes. When sending a request for likes, lock the like button to prevent users from clicking it
Directly feedback users' likes. Users are hard to perceive many details of this very simple operation. For a better user experience, you can directly display +1 the web style when giving a like, and then send a request to the backend. . The general like operation here is like this:
This is concurrency. It is impossible to remove all situations like this. Just introduce caching. Of course, you can do some global measures. If the number of clicks per second exceeds a warning, it will be similar to preventing some crawlers and a single IP. There is a click limit per unit time
Determine the uniqueness of likes based on IP, device number or some unique identifier, use a cache such as redis to update, and then write it to the database asynchronously and synchronously. If the liker is notified asynchronously, the click will be treated as an event and placed in a queue. It can be processed uniformly.
Lock likes. When sending a request for likes, lock the like button to prevent users from clicking it
Directly feedback users' likes. Users are hard to perceive many details of this very simple operation. For a better user experience, you can directly display +1 the web style when giving a like, and then send a request to the backend. .
The general like operation here is like this:
This is concurrency. It is impossible to remove all situations like this. Just introduce caching. Of course, you can do some global measures. If the number of clicks per second exceeds a warning, it will be similar to preventing some crawlers and a single IP. There is a click limit per unit time
Remove the button after liking it
Control the number of clicks, if there are too many clicks, you will be reminded