XML via FTP and Memcache slowing my PHP site down all of a sudden....starting today -


i have below php on site.

$xml = $my_memcache->load('the_xml'); if(empty($xml)){         $username = 'username';         $password = 'password';         $host = 'ftp.thirdpartysite.co.uk';         $file = 'file.xml';         $xml = file_get_contents("ftp://$username:$password@$host/$file");          $my_memcache->save( $xml, 'the_xml' , array(), '1800' );  }  $php_array = $this->parsexml($xml);  $html = $this->gatherhtml($php_array); return $html; 

it looks memcache key/value. if doesnt find key ftp contents , save memcache 5 minutes. want 1 user having users every 5 mins. lastly parses xml php array using 'parsexml()' function, turns php array html using 'gatherhtml()' , returns this.

it has been working long time has started making site slow. have not changed code long while. have load balanced on 2 servers , outgoing bandwidth on internal switch has shot up. have checked load , low no dos attack average under max threads.

any ideas please (ftp, memcache, php, xml) ?

hmmm
if nothing on dns or network layer sounds off third party, in instance xml file.
if xml has increased in size it's possible on 1mb max size of memcache value now. source here. recommend checking via ftp client filezilla (or via command line).

if file above 1mb below happening.

website slow:
if case not every user not not find key in cache, hammer memcache try , store it, every time fail file large , have wait memcache timeout before completing users page request.

bandwidth high:
notice use memcache, possibly have node on each web server? if true data might trying write across both memcache nodes possibly causing spikes in bandwidth on internal switch. confirm try using tcpdump check if memcache culprit of high bandwidth.

#tcpdump -vvxxs 1500 -i bond0 'port 11211' 

substitute bond0 whatever call nic.

possible solution:
try parsing xml first , once have need write/store in memcache. should ensure keeping under 1mb value max size memcache.

$php_array = $my_memcache->load('the_php'); if(empty($php_array)){         $username = 'username';         $password = 'password';         $host = 'ftp.thirdpartysite.co.uk';         $file = 'file.xml';         $xml = file_get_contents("ftp://$username:$password@$host/$file");          $php_array = $this->parsexml($xml);          $my_memcache->save( $php_array, 'the_php' , array(), '1800' ); }   $html = $this->gatherhtml($php_array); return $html; 

no idea if thats right hope helps


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -