nginx, asynchronous PHP, and headaches

Home Forums Languages PHP & MySQL nginx, asynchronous PHP, and headaches

Tagged: 

This topic contains 6 replies, has 2 voices, and was last updated by  Vera 1 year, 8 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #13960

    amphigory
    Participant

    I’m attempting to create a script to be as portable as possible and yet still have the capability of running cron jobs. I figured it would be easy enough to imitate a job by making the script send an asynchronous request back to itself, which would then run the job.

    It works like this:

    1. User, search engine, evil bot visits site.

    2. The database is checked for overdue jobs.

    3. If one is found, a POST request is sent to the necessary page using fsock or cURL. It doesn’t wait for a reply so the running job doesn’t affect the visitor (the jobs can end up taking a few minutes or more to run).

    4. After the job is done, it updates the database with the next scheduled time and a notification that the job is no longer running.

    Seems like it would work fine, because I have done it before. But now, after noticing that the jobs weren’t running the way they’re supposed to, I decided to check my logs. They’re filled with mysterious “499″ status codes. 499 doesn’t even exist in the HTTP spec, so I assume it’s some special code delivered by nginx. Google proved useless, simply stating that it’s a result of the client unexpectedly terminating the process.

    I can’t help but wondering if this is happening because I’m running nginx on Windows. Anyone have any ideas?

    #14873

    Vera
    Participant

    I found:

    special code 499 means client closed connection

    before nginx response

    on http://www.ruby-forum.com/topic/137312

    Perhaps one (or more) of your requests time out? Is there a way to set a larger time interval for a request? You know, like in php.ini you can set the max amount of seconds a script can run?

    #14874

    amphigory
    Participant

    I have the request timeout set for 30 seconds, but it’s sending 499 long before then (less than half a second). I suppose a good test case would be to install something like WordPress or Drupal on my server and see if the scheduled jobs in those are giving me 499s.

    #14875

    amphigory
    Participant

    So, it looks like even nginx is even sending a 499 error for WP’s cron jobs. Looks like it’s an issue of nginx+Windows and the way Windows handles events, because I know it was working correctly when I did it on nginx+Linux. Shame, I love nginx.

    #14876

    Vera
    Participant

    You could try a Linux VM, maybe? Or does it take up too much space. One of my colleagues said it took up too many resources (he had Win XP) so he couldn’t use it. I didn’t generally have issues with the VM on Win7.

    In case you’re interested, I used http://www.virtualbox.org/

    #14877

    amphigory
    Participant

    Space isn’t so much the problem in my situation as is CPU and memory. By some miracle my 4-year-old Intel Atom processor (1.6 GHz single core) can handle Dreamweaver, Photoshop, InDesign, Illustrator and 3 different browsers at the same time. :D

    I had a dual-boot of Ubuntu/Windows 7 on this, but it was getting to be such a pain to switch over to Windows just to use Photoshop and Illustrator (Wine apparently doesn’t work with my CS version). It’s too bad, because I really love gedit as an IDE.

    #14878

    Vera
    Participant

    ^ oh sorry, I mean to say too much memory. That was my colleague’s issue too, mainly Apache would freeze on him a lot, which in turn caused the VM to freeze as well. :

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.