Is it possible to implement OS-level communication between http requests?

Source: Internet
Author: User
Recently, I was working on something. I wrote it in python and deployed the wsgi interface in sae. The server of sae should be nginx. of course, the solution may not be python or php, but never tell me to implement a server. Now it's nginx and nginx .... the situation is as follows :... recently, I was working on something. I wrote it in python and deployed the wsgi interface in sae. The server of sae should be nginx. of course, the solution may not be python or php, but never tell me to implement a server. Now it's nginx and nginx ....

The situation is as follows: two concurrent requests are recorded as A and B, which are two threads for the server. A is half executed and blocked until B sends A signal to.

It seems that there is a very intuitive method: Set a Boolean in the cache or database and use it as mutex. however, when I block the database, I need to poll the database constantly, which consumes too many resources. so I thought, is there a way to save the country and call the mutex API in the system (the slag wave system is probably Linux, or pthread. if two requests are sent to the same process, you may be able to save the mutex address to the database ...... okay, I thought about it too much.

Do not use an endless loop (even if + sleep) for Round-Robin. I will do everything.

Reply content:

Recently, I was working on something. I wrote it in python and deployed the wsgi interface in sae. The server of sae should be nginx. of course, the solution may not be python or php, but never tell me to implement a server. Now it's nginx and nginx ....

The situation is as follows: two concurrent requests are recorded as A and B, which are two threads for the server. A is half executed and blocked until B sends A signal to.

It seems that there is a very intuitive method: Set a Boolean in the cache or database and use it as mutex. however, when I block the database, I need to poll the database constantly, which consumes too many resources. so I thought, is there a way to save the country and call the mutex API in the system (the slag wave system is probably Linux, or pthread. if two requests are sent to the same process, you may be able to save the mutex address to the database ...... okay, I thought about it too much.

Do not use an endless loop (even if + sleep) for Round-Robin. I will do everything.

Can I use a named pipe?

Can posix_kill in the process control extension in PHP official documents be checked?

===! I don't understand the subject too well. It may be that A and B run together. A does not run until half of it is executed and then waits for B's notification to be executed. Does that mean that?

In this case, I think you can split A into two parts: a' and C. A' is the code before receiving B notification, and C is the code after receiving B notification. After running a' and B, the system jumps to C to execute the code. C code first needs to check whether the content processed by a' and B is complete. if the content is incomplete, it stops running. Of course, the processed data should be stored in external storage. I think this should be the simplest implementation method.

In addition, if it is SAE, you should not think about it. If there are too many limits, it is unlikely that you will be exposed to system-level interfaces.

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.