xml ファイルから製品コード (データベース テーブルからも取得) を介して価格表と在庫リストを読み取ろうとしており、結果を MySQL テーブルに入れています。
xml ファイルからの応答または読み取り時間を除いて、すべて問題ありません。PHP スクリプト、データベース、および XML ファイルは同じサーバー上にあります。Apache access.log を調べたところ、開始後の PHP スクリプトは非常に迅速に読み取り (または応答) できることがわかりました。しかし、しばらくすると、1 分間に正確に 1 つしか読み取れません。
[...]
1.2.3.4 - - [09/May/2013:13:11:21 +0300] "GET /feeds/stock.xml HTTP/1.0" 200 16202 "-" "-"
1.2.3.4 - - [09/May/2013:13:11:21 +0300] "GET /feeds/price.xml HTTP/1.0" 200 82143 "-" "-"
1.2.3.4 - - [09/May/2013:13:11:21 +0300] "GET /feeds/stock.xml HTTP/1.0" 200 16202 "-" "-"
1.2.3.4 - - [09/May/2013:13:11:21 +0300] "GET /feeds/price.xml HTTP/1.0" 200 82143 "-" "-"
1.2.3.4 - - [09/May/2013:13:11:21 +0300] "GET /feeds/stock.xml HTTP/1.0" 200 16202 "-" "-"
1.2.3.4 - - [09/May/2013:13:11:21 +0300] "GET /feeds/price.xml HTTP/1.0" 200 82143 "-" "-"
1.2.3.4 - - [09/May/2013:13:11:21 +0300] "GET /feeds/stock.xml HTTP/1.0" 200 16202 "-" "-"
1.2.3.4 - - [09/May/2013:13:11:21 +0300] "GET /feeds/price.xml HTTP/1.0" 200 82143 "-" "-"
1.2.3.4 - - [09/May/2013:13:11:21 +0300] "GET /feeds/stock.xml HTTP/1.0" 200 16202 "-" "-"
1.2.3.4 - - [09/May/2013:13:11:21 +0300] "GET /feeds/price.xml HTTP/1.0" 200 82143 "-" "-"
1.2.3.4 - - [09/May/2013:13:11:21 +0300] "GET /feeds/stock.xml HTTP/1.0" 200 16202 "-" "-"
1.2.3.4 - - [09/May/2013:13:11:21 +0300] "GET /feeds/price.xml HTTP/1.0" 200 82143 "-" "-"
1.2.3.4 - - [09/May/2013:13:11:21 +0300] "GET /feeds/stock.xml HTTP/1.0" 200 16202 "-" "-"
1.2.3.4 - - [09/May/2013:13:11:21 +0300] "GET /feeds/price.xml HTTP/1.0" 200 82143 "-" "-"
1.2.3.4 - - [09/May/2013:13:11:21 +0300] "GET /feeds/stock.xml HTTP/1.0" 200 16202 "-" "-"
1.2.3.4 - - [09/May/2013:13:11:21 +0300] "GET /feeds/price.xml HTTP/1.0" 200 82143 "-" "-"
1.2.3.4 - - [09/May/2013:13:11:21 +0300] "GET /feeds/stock.xml HTTP/1.0" 200 16202 "-" "-"
1.2.3.4 - - [09/May/2013:13:11:21 +0300] "GET /feeds/price.xml HTTP/1.0" 200 82143 "-" "-"
1.2.3.4 - - [09/May/2013:13:11:21 +0300] "GET /feeds/stock.xml HTTP/1.0" 200 16202 "-" "-"
1.2.3.4 - - [09/May/2013:13:11:21 +0300] "GET /feeds/price.xml HTTP/1.0" 200 82143 "-" "-"
1.2.3.4 - - [09/May/2013:13:11:21 +0300] "GET /feeds/stock.xml HTTP/1.0" 200 16202 "-" "-"
1.2.3.4 - - [09/May/2013:13:11:21 +0300] "GET /feeds/price.xml HTTP/1.0" 200 82143 "-" "-"
1.2.3.4 - - [09/May/2013:13:11:21 +0300] "GET /feeds/stock.xml HTTP/1.0" 200 16202 "-" "-"
1.2.3.4 - - [09/May/2013:13:11:21 +0300] "GET /feeds/price.xml HTTP/1.0" 200 82143 "-" "-"
1.2.3.4 - - [09/May/2013:13:11:21 +0300] "GET /feeds/stock.xml HTTP/1.0" 200 16202 "-" "-"
1.2.3.4 - - [09/May/2013:13:11:21 +0300] "GET /feeds/price.xml HTTP/1.0" 200 82143 "-" "-"
1.2.3.4 - - [09/May/2013:13:11:21 +0300] "GET /feeds/stock.xml HTTP/1.0" 200 16202 "-" "-"
1.2.3.4 - - [09/May/2013:13:11:21 +0300] "GET /feeds/price.xml HTTP/1.0" 200 82143 "-" "-"
1.2.3.4 - - [09/May/2013:13:11:21 +0300] "GET /feeds/stock.xml HTTP/1.0" 200 16202 "-" "-"
1.2.3.4 - - [09/May/2013:13:11:21 +0300] "GET /feeds/price.xml HTTP/1.0" 200 82143 "-" "-"
1.2.3.4 - - [09/May/2013:13:12:22 +0300] "GET /feeds/stock.xml HTTP/1.0" 200 16202 "-" "-"
1.2.3.4 - - [09/May/2013:13:13:22 +0300] "GET /feeds/price.xml HTTP/1.0" 200 82143 "-" "-"
1.2.3.4 - - [09/May/2013:13:14:22 +0300] "GET /feeds/stock.xml HTTP/1.0" 200 16202 "-" "-"
::1 - - [09/May/2013:13:15:04 +0300] "GET / HTTP/1.1" 200 1007 "-" "Mozilla/5.0 (ISPConfig monitor)"
1.2.3.4 - - [09/May/2013:13:15:22 +0300] "GET /feeds/price.xml HTTP/1.0" 200 82143 "-" "-"
1.2.3.4 - - [09/May/2013:13:16:22 +0300] "GET /feeds/stock.xml HTTP/1.0" 200 16202 "-" "-"
1.2.3.4 - - [09/May/2013:13:17:22 +0300] "GET /feeds/price.xml HTTP/1.0" 200 82143 "-" "-"
1.2.3.4 - - [09/May/2013:13:18:22 +0300] "GET /feeds/stock.xml HTTP/1.0" 200 16202 "-" "-"
1.2.3.4 - - [09/May/2013:13:19:22 +0300] "GET /feeds/price.xml HTTP/1.0" 200 82143 "-" "-"
::1 - - [09/May/2013:13:20:03 +0300] "GET / HTTP/1.1" 200 1007 "-" "Mozilla/5.0 (ISPConfig monitor)"
1.2.3.4 - - [09/May/2013:13:20:22 +0300] "GET /feeds/stock.xml HTTP/1.0" 200 16202 "-" "-"
1.2.3.4 - - [09/May/2013:13:21:22 +0300] "GET /feeds/price.xml HTTP/1.0" 200 82143 "-" "-"
1.2.3.4 - - [09/May/2013:13:22:22 +0300] "GET /feeds/stock.xml HTTP/1.0" 200 16202 "-" "-"
1.2.3.4 - - [09/May/2013:13:23:22 +0300] "GET /feeds/price.xml HTTP/1.0" 200 82143 "-" "-"
1.2.3.4 - - [09/May/2013:13:24:22 +0300] "GET /feeds/stock.xml HTTP/1.0" 200 16202 "-" "-"
::1 - - [09/May/2013:13:25:03 +0300] "GET / HTTP/1.1" 200 1007 "-" "Mozilla/5.0 (ISPConfig monitor)"
1.2.3.4 - - [09/May/2013:13:25:23 +0300] "GET /feeds/price.xml HTTP/1.0" 200 82143 "-" "-"
1.2.3.4 - - [09/May/2013:13:26:23 +0300] "GET /feeds/stock.xml HTTP/1.0" 200 16202 "-" "-"
1.2.3.4 - - [09/May/2013:13:27:23 +0300] "GET /feeds/price.xml HTTP/1.0" 200 82143 "-" "-"
1.2.3.4 - - [09/May/2013:13:28:23 +0300] "GET /feeds/stock.xml HTTP/1.0" 200 16202 "-" "-"
1.2.3.4 - - [09/May/2013:13:29:23 +0300] "GET /feeds/price.xml HTTP/1.0" 200 82143 "-" "-"
::1 - - [09/May/2013:13:30:04 +0300] "GET / HTTP/1.1" 200 1007 "-" "Mozilla/5.0 (ISPConfig monitor)"
1.2.3.4 - - [09/May/2013:13:30:23 +0300] "GET /feeds/stock.xml HTTP/1.0" 200 16202 "-" "-"
1.2.3.4 - - [09/May/2013:13:31:23 +0300] "GET /feeds/price.xml HTTP/1.0" 200 82143 "-" "-"
1.2.3.4 - - [09/May/2013:13:32:23 +0300] "GET /feeds/stock.xml HTTP/1.0" 200 16202 "-" "-"
1.2.3.4 - - [09/May/2013:13:33:23 +0300] "GET /feeds/price.xml HTTP/1.0" 200 82143 "-" "-"
1.2.3.4 - - [09/May/2013:13:34:23 +0300] "GET /feeds/stock.xml HTTP/1.0" 200 16202 "-" "-"
::1 - - [09/May/2013:13:35:03 +0300] "GET / HTTP/1.1" 200 1007 "-" "Mozilla/5.0 (ISPConfig monitor)"
1.2.3.4 - - [09/May/2013:13:35:23 +0300] "GET /feeds/price.xml HTTP/1.0" 200 82143 "-" "-"
1.2.3.4 - - [09/May/2013:13:36:23 +0300] "GET /feeds/stock.xml HTTP/1.0" 200 16202 "-" "-"
1.2.3.4 - - [09/May/2013:13:37:23 +0300] "GET /feeds/price.xml HTTP/1.0" 200 82143 "-" "-"
1.2.3.4 - - [09/May/2013:13:38:23 +0300] "GET /feeds/stock.xml HTTP/1.0" 200 16202 "-" "-"
1.2.3.4 - - [09/May/2013:13:39:24 +0300] "GET /feeds/price.xml HTTP/1.0" 200 82143 "-" "-"
::1 - - [09/May/2013:13:40:03 +0300] "GET / HTTP/1.1" 200 1007 "-" "Mozilla/5.0 (ISPConfig monitor)"
1.2.3.4 - - [09/May/2013:13:40:24 +0300] "GET /feeds/stock.xml HTTP/1.0" 200 16202 "-" "-"
[...]
xml ファイルから価格を読み取る関数:
function get_price($product_id, $source='xml'){
$price = NULL;
$url = "http://www.mydomain.com/feeds/price.xml";
$xml = simplexml_load_file($url);
$Price = $xml->xpath("//PRODUCT[@CODE='". $product_id ."']");
return $price;
}
ストック xml を読み取る関数は非常に似ています。
すべての構成 (MySQL、PHP、Apache) はほぼデフォルトの構成であり、特別なことは何もありません。しばらくすると読み取り率が低下する理由がわかりません:(
サーバー仕様:
- CentOS リリース 6.4 (最終版)
- ISPConfig 3.0.5.2
- アパッチ/2.2.15 (Unix)
- MySQL 5.1.69
- PHP 5.3.3