Is it possible to implement an operating system-level communication between HTTP requests?

Source: Internet
Author: User
Recently in the making of a thing, written in Python, WSGI interface, deployed in SAE, the SAE server should be nginx. Of course, the solution is not necessarily python, PHP can, but do not tell me to implement a server, now is Nginx, nginx ....

This is the case: there are two concurrent requests, which are recorded as a and b, and two threads for the server. A executes to half, blocks until B sends a signal to a, and a continues to execute.

There seems to be a pretty straightforward way to do this: Set a Boolean in the cache or database as a mutex. But when I block it, I need to constantly poll the database, which consumes too much resources. So I thought, there is no way to get the curve to the national salvation, to call the system (the system is probably Linux, that is pthread) mutex API it. If two requests the same process, then you may be able to save the address of the mutex to the database ... Well, I'm probably thinking a lot.

Do not use the dead loop (even +sleep) to poll, I would like anything.

Reply content:

Recently in the making of a thing, written in Python, WSGI interface, deployed in SAE, the SAE server should be nginx. Of course, the solution is not necessarily python, PHP can, but do not tell me to implement a server, now is Nginx, nginx ....

This is the case: there are two concurrent requests, which are recorded as a and b, and two threads for the server. A executes to half, blocks until B sends a signal to a, and a continues to execute.

There seems to be a pretty straightforward way to do this: Set a Boolean in the cache or database as a mutex. But when I block it, I need to constantly poll the database, which consumes too much resources. So I thought, there is no way to get the curve to the national salvation, to call the system (the system is probably Linux, that is pthread) mutex API it. If two requests the same process, then you may be able to save the address of the mutex to the database ... Well, I'm probably thinking a lot.

Do not use the dead loop (even +sleep) to poll, I would like anything.

Can I use Named pipes?

Check out the PHP official documentation Process Control extension Posix_kill is it possible?

=_=! Not too understand the meaning of the main, it may be said a and B run, a run to half do not run and then wait for B's notice to execute, is this the meaning?

If that's the point, I think you can split a into a ' and C ', a ' to accept the code before the B notification, C to accept the code after the B notification. A ' and B have finished executing and jump to C to execute the code. C code first to detect whether a ' and B processing content is complete, incomplete will stop running. Of course, the data processed is best stored with external storage. I think this should be the simplest way to implement it.

In addition, if it is SAE, do not do what he thought, the limit of the super-is not likely to let you touch the system-level interface and so on.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.