排队mysql查询的最佳方法是什么?在速度方面

时间:2022-04-05 02:44:20

When a user submits a form on my site, I have to do a job based on the form which is essentially:

当用户在我的网站上提交表单时,我必须根据表单执行一项工作,基本上是:

  • Check for user locks (in redis, prevents user from doing naughty things), if no locks continue and put job queue lock in place, otherwise quit job and give error to user
  • 检查用户锁(在redis中,防止用户做顽皮的事情),如果没有锁继续并将作业队列锁定到位,否则退出作业并给用户带来错误

  • Update row/s in a mysql table, potentially delete some rows in the same table and do at least 1 insert (potentially across different tables)
  • 更新mysql表中的行,可能会删除同一个表中的某些行并至少执行1次插入(可能跨越不同的表)

  • remove job queue lock
  • 删除作业队列锁定

I would like to queue these jobs up as they come in, with the queue always processing new jobs that get put into it.

我希望在这些工作进入时将这些工作排队,队列总是会处理新工作。

I am using php and mysql. I have looked at gearman and also resque for php. Gearman seems like it might be overkill. And also I want to potentially be able to handle thousands of these jobs per second. So speed is important.

我正在使用php和mysql。我已经看过gearman并且还重新启用了php。 Gearman似乎有点矫枉过正。而且我希望每秒能够处理数千个这样的工作。所以速度很重要。

It's crucial that these jobs in the queue occur sequentially and in the order they come in. It would also be a bonus if every half a second I could insert a job to the front of the queue (it's a different job but kind of related).

至关重要的是,队列中的这些作业按顺序发生并按照它们进入的顺序发生。如果每半秒我可以将作业插入队列的前面(这是一项不同的工作,但有点相关),这也是一个好处。 。

I've never done anything like this before.

我以前从未做过这样的事。

1 个解决方案

#1


0  

Since you're already into PHP & Redis it looks like Resque may work for you.

既然你已经进入了PHP和Redis,看起来Resque可能适合你。

#1


0  

Since you're already into PHP & Redis it looks like Resque may work for you.

既然你已经进入了PHP和Redis,看起来Resque可能适合你。