3

In my current task, when I selecting a large number of records and then changing their status or reassigning them, the system can slow to that point so user have to wait for some time to complete this operation.

So is there any way to put this process in queue so the process run in background and user can do their other tasks.

Thank you in advanced.

1

5 Answers 5

2

Yup... have a look at Gearman:

http://gearman.org/index.php?id=getting_started

http://php.net/manual/en/book.gearman.php

Alternativley, if you don't fancy that, I have used the principle of this excellent 4-part tutorial many times to great effect:

http://squirrelshaterobots.com/programming/php/building-a-queue-server-in-php-part-1-understanding-the-project/

Sign up to request clarification or add additional context in comments.

Comments

0

Use j-query ajax method and make user wait without making any actions.

Comments

0

You can choose from

  • Gearman

  • Beanstalkd

  • RabbitMQ

    Basically you can run any MessageQ system and then use STOMP(A standard protocol) to talk between processes.

1 Comment

stomp in php have many troubles(with 'ack'), if you need to write(no only read), then it will be easier to use AMQP protocol. at least with rabbit-mq
0

Yes, for sure. If you would like to keep php script doing it job in background, and let user to play with your site. All you need to do, is send headers :

header("Connection: close");
header("Content-length: $size");

Is it what you are looking for?

Comments

0

Need more information on how the queue is processed, you mean that the data that is being processed has nothing to do with the second process running after the first process? In that case I would run your script as

yourcommand > /dev/null 2>&1 &

this would let the process run in the background.

In the context of PHP, if it is speed that you are after, I would check if PHP has enough memory available. If yes, I would save the values in an array and use a foreach loop to manipulate data. Usually this works out faster.

More information is required.

Hari

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.