duanmao2774 2013-10-27 16:00
浏览 104

PHP多线程cURL替代方案提出,但是它好吗?

Because PHP doesn't have multithreading capabilities I am trying to find a workaround to speed up a simple process.

The process is I am posting data to a webpage with various permutations in the post-data on each request. In a foreach loop I am checking each request response to see if a string exists using strspos. When it is found, it breaks and returns the page. There are around 1000 requests, and it takes bout 1 minute to complete or longer.

As I don't want to use additional libraries, my idea was to exec standalone scripts passing each permutation of post data (say 1000 processes). Each process will only write to a file if the string is found. And on the main script I will run a loop checking if file exists, when it does find that the file exists, can read the file for the post data that was correct.

It seems sound in theory, but I wanted to check if this is a ridiculous solution for a problem that has much simpler solutions!

Thanks.

  • 写回答

1条回答 默认 最新

  • duanbei7005 2013-10-27 16:09
    关注

    One solution is using process control library

    http://php.net/manual/en/book.pcntl.php

    I don't know if you have support for them installed

    评论

报告相同问题?

悬赏问题

  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图