Thats a scheme of my question:
Structure:
Client ServerA ServerB
Both ServerA and ServerB offer a REST Web Service (php and mysql). And what I’m looking for is:
Client (queries)-------> ServerA
| |
| |
| V
| <------------(response)-*-(queries) -----> Server B
//Client's petition | |
is finished | |
v v
markAsSent(petition)<------------
//if the petition fails, retry periodically
The server B only stores statistical data and is not needed for answer the client so I want to avoid the client wait the ServerA-to-ServerB petition delay.
How can I do it? Thanks
Enter the answer into a queue table in the database and then immediately return to the user.
Then, have server B asynchronously poll the queue (grab a row) and do whatever statistical processing you need.
Most likely you’ll just make server B run a
cronjob which runs a script that fetches & deletes a row out of the queue and processes it.