php 5.3 - XML parsing slows down -
i trying read pricelist , stocklist via product code (that comes database table too) xml files , puts result mysql table.
everything ok except response or read time xml files. php script, database , xml file on same server. after in apache access.log saw php script after started can read (or response) quickly. after while reads 1 per minute:
[...] 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 "-" "-" [...]
the function reads price xml file:
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; }
the function read stock xml similar.
all configurations (mysql, php, apache) default configurations, nothing special. have no idea why read rate goes down after while :(
server specs:
- centos release 6.4 (final)
- ispconfig 3.0.5.2
- apache/2.2.15 (unix)
- mysql 5.1.69
- php 5.3.3
dont use http file,just call file directly
use code
$url = "feeds/price.xml";
you can use code file in feeds directory , result in $price variable
$price = ""; foreach (glob("feeds/*.xml") $filename) { //getting xml files feeds direcotry $xml = simplexml_load_file("feeds/".$filename); $price .= $xml->xpath("//product[@code='". $product_id ."']"); } print_r($price);
Comments
Post a Comment