About how to use php multithreading to process highly concurrent search requests! Multi-thread concurrent search for php gearman
I use php for android as the backend. now, androdi has a search function, that is, entering keywords for search. I plan to write two methods to jointly process high-concurrency search requests. The first method receives the POST keyword from the mobile phone and stores it in the message queue created by redis. The second method is used to retrieve keywords from the message queue for search and then return the search results. However, the address of the post keyword on the mobile phone is the address of the first method, so you can only receive the value returned by the first method. However, I am using the second method to process the search function. how can I return the search results to my mobile phone? So I think of multithreading, but php does not support multithreading. I heard that gearman can implement a method similar to multithreading. how can I do this?
Reply to discussion (solution)
From the process you described, you still use the traditional instant query method.
No matter how clever you are, the user will always wait for the query results to occupy the connection
If the request keyword is received, the cached result is immediately returned (if the keyword is not cached, it is directly queried and cached)
Store the keyword to the queue for update check.
The question token just saw in dewen! My answer is to use an open source search engine system.
From the process you described, you still use the traditional instant query method.
No matter how clever you are, the user will always wait for the query results to occupy the connection
If the request keyword is received, the cached result is immediately returned (if the keyword is not cached, it is directly queried and cached)
At the same time, this keyword is stored in the queue for check and update, but how to deal with high concurrency in real-time search? Do you have any suggestions?