I have 3 web services that are providing me data for my hotel booking engine. It is taking too long if I run them sequentially. Therefore I wanted to run them using threads, but I am not sure if php threading will support this and if it is safe, since all 3 processes that will handle the web service will read and write into shared tables.
Can anyone advise me on how should I proceed?
1
The problem your describing is complicated. Using your approach, you are going to run into problems with reading and writing data to the database. I know your question wasn’t about the validity of your solution, but I feel it is unnecessarily complicated. Could you elaborate a bit on why your solution is necessary for solving this problem?
Here is an example of the kind of problems you will run into: https://stackoverflow.com/questions/2199559/what-are-concurrency-conflicts
I think a simpler approach should be explored. I suggest making one service call to retrieve and another to save all the information. This is the preferred way to have clients and servers communicate because it minimizes problems such as the one you are describing.
Implementing the solution will require the following:
- Write a Retrieve web service to call from your page
- Retrieve web service will make 1 call to the database to retrieve all your data
- Write a Save web service to save information
- Save web service will make 1 call to the database to save all your data
I don’t know PHP, so I can’t write any code or refer you to any PHP specific resources to help.
1