PHP项目,有个功能越来越慢
怪我咯
怪我咯 2017-05-16 13:04:25
0
5
332

有个会员表越来越多会员,但是每次新增一个会员都会给前面的会员按一定规则算奖金啥的,反正越来越多的会员后,每增加一个会员时就会越来越慢(要计算的越来越多嘛),怎么处理这种场景啊。

怪我咯
怪我咯

走同样的路,发现不同的人生

reply all(5)
我想大声告诉你

You can add members first, and the bonus will be calculated according to a certain time range, such as settling on Monday, building a referral table, recording the related information of the last week, and then running a script to calculate the bonus once a week.

巴扎黑

1. Does this settlement occur during the registration step? If so, take out the settlement steps, write them into the table or message queue, and just do the registration process

2. But looking at the comments above about daily settlement, step 1 should be done. Then the entire settlement process should be executed at a fixed time point for all members who joined today (for example, at 1 o'clock in the morning). Slow down. It doesn’t matter, as long as the settlement is completed

为情所困

Check the table structure to see if it is designed and whether the index can be optimized. And so on

Peter_Zhu

Take out the settlement and run it separately. Write a planned task and run it every day. Or you can write the settlement on the first login of the new user.

曾经蜡笔没有小新

For this requirement, you can run the message queue.
The member profit sharing calculation message is first pushed to the message queue, and then a php script is written to receive the message and thrown into the cache, and then it is stored in the database during low business hours every day

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!