duanaoshu1989 2010-12-05 23:13
浏览 40

快速记录请求

I'm trying to test my PHP script that creates 48 cURL multi handles, each holding about 1500 requests, all executed in parallel. I'm trying to make sure that all requests are actually sent, and to do so, I'm logging the requests on my server. Here is my dump.php, which I make requests to, with my script, and it will log the request to a file:

<?php
ob_start();
echo $_SERVER["REQUEST_URI"];
$dump = ob_get_clean();
$log = "dump.txt";
$fh = fopen($log, 'a') or die("can't open file");
fwrite($fh, $dump . "

");
fclose($fh);

echo "Dump Completed";
?>

However, there is a slight problem of my quad core PC being able to fire off these requests at rate of about 1500 every 10 seconds, and most likely overloading my server as it tries to open the file at the same time. I've put a delay of 0.1 seconds between the sending of each request, but my server, I think still cannot open the file, dump the text, and close it before the next request arrives. As a result, my PHP file says that about 72k of requests were sent, but my server says that only about 14k were received. This could be due to my PHP program overloading my PC, or the port system, and some requests were never successfully sent, or my server isn't fast enough to handle 150 requests a second.

Any possible solutions to attempt to securely know that all my requests were sent? When my client uses the script, it is imperative that at least 99.5% of the requests are actually sent, and his server is powerful enough to handle that with no problem. I can't test it on his servers for security reasons, yet mine isn't powerful enough for me to simulate the working conditions.

  • 写回答

2条回答 默认 最新

  • drlnsli18864734 2010-12-06 02:33
    关注

    Ideally, i'd write these values to a key cache such as memcached instance and then eventually to a database/flat file with a single-threaded script. This will give you the speed of being able to keep up with requests, and also the ability to store the data to disk.

    Having said that, just using a database as a quick workaround would work.

    评论

报告相同问题?

悬赏问题

  • ¥15 csmar数据进行spss描述性统计分析
  • ¥15 各位请问平行检验趋势图这样要怎么调整?说标准差差异太大了
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 wpf界面一直接收PLC给过来的信号,导致UI界面操作起来会卡顿
  • ¥15 init i2c:2 freq:100000[MAIXPY]: find ov2640[MAIXPY]: find ov sensor是main文件哪里有问题吗
  • ¥15 运动想象脑电信号数据集.vhdr
  • ¥15 三因素重复测量数据R语句编写,不存在交互作用
  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?