About how to use php multithreading to process highly concurrent search requests!

Source: Internet
Author: User
Tags php multithreading
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?

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.