Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with laravel while running a job #2

Closed
norrin77 opened this issue Sep 3, 2013 · 3 comments
Closed

Problem with laravel while running a job #2

norrin77 opened this issue Sep 3, 2013 · 3 comments
Assignees
Labels

Comments

@norrin77
Copy link

norrin77 commented Sep 3, 2013

Hi!

I'm not sure if this could be an issue but I cannot find any information about it, neither on the apache-php nor the laravel forums.

I'm running a job using your bundle and it takes about 5-6 seconds to complete. This job is just a loop of about 20 requests of an URI which returns a simple json response each time is called. Then I parse every response in turn.

Well, the problem is that while this job is running I can't make any concurrent request to any page of my laravel-based site. Actually, I can make the request but
I have to wait until the job has finished to get a response to the concurrent request.

I have tested in different environments (dev, production) and servers (apache, laravel built-in server) and the problem remains the same.

Thank you for any information or direction you can provide.

@ghost ghost assigned liebig Sep 3, 2013
@liebig
Copy link
Owner

liebig commented Sep 3, 2013

Hi Norrin,

thanks for your request. This issue sounds really strange and I will try to help you. Since PHP can handle multiple requests, running jobs and calling the website has to work at the same time. Somewhere in your code has to be something which doesn't work asynchronous. How do you make the 20 requests to the URI? Can you provide us an code snippet? And please remove Cron for a test: Just call your 20 requests to the URIs directly without Cron in a Route definition and test if you can make a request to any page of your laravel site. If this doesn't work either, it would not be a problem with Cron. But in this case, I will still try to help you.

Thank you.

@norrin77
Copy link
Author

norrin77 commented Sep 3, 2013

Hi again

Yes you are right. This problem is not related to your bundle. I've programmed the same job with crontab and it works flawlessly. Moreover, I've tested with two simple web pages (one with a loop taking a very long time) which are requested at almost the same time (first the one with the big loop) and the second request must wait to be processed.

It seems that Laravel is locking the session somehow and thus serializing the execution of multiple parallel requests. I'm trying with a different session driver (memcached) but I still can't figure out what is going on.

Thanks for your help and sorry for any inconvenience.

@norrin77 norrin77 closed this as completed Sep 3, 2013
@liebig
Copy link
Owner

liebig commented Sep 3, 2013

Hi Norrin,

I am glad to hear that this issue is not related to Cron. For making asynchronous requests with PHP have a look at this links:
https://bensmann.no/parallel-curl-php/
https://github.com/stil/curl-easy

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants