The microservice uses phprpc, but recently it was discovered that fsockopen, which phprpc relies on, has a serious blocking problem under high concurrency. Is there a good way to solve it?

WBOY
Release: 2016-07-06 13:51:18
Original
1150 people have browsed it

I use phprpc, but recently I found that fsockopen, which phprpc relies on, has a serious blocking problem under high concurrency. Is there a good way to solve it?

  • A large number of read operations are related to each user and must be real-time. How to solve this problem?

Reply content:

I use phprpc, but recently I found that fsockopen, which phprpc relies on, has a serious blocking problem under high concurrency. Is there a good way to solve it?

  • A large number of read operations are associated with each user and must be real-time. How to solve this problem?

Let’s try using yar

Message queue is the fundamental solution to concurrency problems

Someone mentioned message queue, but it seems that it is not suitable for scenarios with high real-time requirements and inability to be asynchronous.

I have never used phprpc. It is unknown whether it has performance problems.

But judging from the experience of other products, if the connection handle is opened for every request, there must be a congestion problem. When the intranet connection to mysql reaches a certain data level, you can see a relatively high connection delay, and the query process itself is not slow.

If this is the reason, yaf may also have such a problem. Long connections and connection pools are your research directions.

<code>用任务队列
1.新建一个数据表 去存放队列信息
2.利用linux上的定时任务去后台异步调用PHP /shell 脚本 去执行任务</code>
Copy after login

There is no research in this area, the poster can try: http://wiki.swoole.com/wiki/page/196.html

Please share your thoughts if you have any experience

Your rpc can’t solve the problem in real time. . . It should be using a long connection. . You should talk about your specific needs. I feel that your needs and solutions may not match

If you don’t have high real-time requirements, you can consider message queues.
You can also consider the swoole extension of php to see if the performance will be improved.

Thanks for the invitation. Recommended message queue

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template