Portal Home > Knowledgebase > Articles Database > Excessive RAM usage with Facebook like script!


Excessive RAM usage with Facebook like script!




Posted by John-e5, 01-16-2011, 10:36 PM
Hello WHTers, I'm writing this topic to get some advice on a server issue. My friend has a fairly new webpage (around one week online) that uses a Facebook like script (this is how they're called) to display particular Facebook statuses and the webpage interacts with Facebook as there are "Like" buttons on every status for users to click on (and then this is displayed on their Wall, in the known "USER likes link "STATUS" at "OURWEBSITE" manner). These statuses are displayed on the index page in a two column layout. There are round 40 statuses (4 lists of 10) with corresponding "Like" buttons which also show how many users already clicked on them, all of these on a single page dynamically loaded. The script reads a table with statuses from the database and creates/pulls from Facebook the corresponding like buttons. It uses opengraph meta tags on in order to pass the data to Facebook (when a user hits a Like button). Each user can submit his status by writing it directly on the site. This is stored in a database and next time the page loads in might come up. Also, on Facebook, if someone clicks on the "USER likes link "STATUS" at "OURWEBSITE", a page is loaded which shows the liked status in the header and below some extra statuses-likes which also pull/send data to Facebook. Most of the traffic come from Facebook as you imagine and not from direct visits to the domain. The script also uses jQuery and Facebook's recommendation plugin. The site is stored in an account on my friends reseller package in a shared server with other resellers, with 4GB of memory in total. cPanel reports ram usage at 13% max, 8% average, ie around 330MB on average and 500+ on maximum load! The TOS allow only 2% of RAM to be used by any account on the server. So, we either have to lower this value or move. Server hardware specs: Xeon X3220 @2.40GHz, 4GB RAM. Software versions installed: Apache 2.2.13, php 5.2.9 and MySQL 5.0.91-community. The site's traffic stats from yesterday are: My friend tried today to add caching to the whole operation but the RAM usage stays the same (got some extra traffic though, it might have been balanced by this). He also added some extra code to clean the RAM (php-wise, unset(), mysql_free_result(), etc) after each output. That didn't help much either I think. Now... Before we try to get suggestions for VPS/Dedi or something, I want first to ask, do you know if Facebook interaction is causing this stress on the server? I'm trying to find out if this doesn't have to do with the server or our resources, but with the software behind it. Perhaps pulling and sending data to Facebook is quite stressful for the server? Do you have experiences with this? Basically, the "data" are the "Like" buttons. They are created, then next to each other its diplayed how many times they have been clicked (this is pulled from Facebook) and if you click on it this action is also being sent over to Facebook (counter goes +1 and the logged user has this posted on his/her wall). Any thoughts? Last edited by John-e5; 01-16-2011 at 10:49 PM.

Posted by fabin, 01-16-2011, 11:20 PM
I guess, the entire facebook interaction is developed using javascript, which isn't server side script. So the server shouldn't use any extra resources because of it.

Posted by sitekeeper, 01-16-2011, 11:35 PM
Are you sure this is your sites "ram" usage or could it be the whole servers usage?

Posted by plumsauce, 01-16-2011, 11:39 PM
Install the software at home. Reboot. Take a memory reading. Start software. Take a memory reading. Run the software. Take a memory reading.

Posted by raffo, 01-17-2011, 12:10 AM
Can do also by linux tool like top, htop, free, vmstat.. by Shell and using SSH, can use it by remote.. so at home or by remote is egual, at home have only less connection. Shure! Facebook load a lot the clients computer for this reason. But they save a lot of loads.. he just need to make a very big cache in the mysql clustering.

Posted by John-e5, 01-17-2011, 09:21 PM
Hello guys. Thanks for your answers. I have forwarded them to my friend. Now... He told his host to give him SSH access in order to check for himself, but they don't allow that. He sent some support tickets requesting a 'top' copy-paste result. He was informed that while 'top' doesn't show stats over a period of time, they did see some processes at that time like: PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 3029 testuser 17 0 20576 2992 2476 R 0.5 0.1 0:00.01 /usr/bin/php /home/testuser/public_html/like.php 3891 testuser 17 0 0 0 0 Z 9.6 0.0 0:00.05 [php] 9.6% above is CPU usage btw, not RAM which is the main problem. Still an interesting fact as cPanel doesn't report any issue with CPU usage at all (I seriously doubt that cPanel shows stats correctly in our case anyway). Well, as it seems there must be some bad programmed code there. From my understanding, parent processes create child processes and continue to run without waiting for childs to signal ending, thus leaving the child parent-less and still holding resources. Do you think this explains the situation? I remind you that it's excessive RAM usage, using a not so complex script. With the stats below the RAM used was 330MB on average and around 500MB max. Number of visits: 4299, Pages: 8374, Hits: 35310, Bandwidth: 1.48 GB Can [php] really create such problem on the server? Thanks for your time, anything you could tell us will help Last edited by John-e5; 01-17-2011 at 09:25 PM.

Posted by Hostify Networks, 01-17-2011, 11:30 PM
That stats in cPanel are for the entire server. Anyway, your host allows you to use only 82mb of ram? Definitely time to move to somewhere with more realistic limitations. Basically any shared host should be able to handle you friend's site.

Posted by John-e5, 01-18-2011, 01:13 AM
He currently manages a reseller package with some clients in it. He set up a client-like account in his own package for himself in order to host the site we're talking about. Now, is there any way to see the CPU/RAM usage for the reseller package and not the entire server? By the way, speaking with percentages just messes everything up, because now that I think of the situation I'm not sure if the percentages we're talking about apply to the total server memory or if they're just percetanges of the... percetange (of the total RAM) that he is allowed to use in the first place I will have him go to WHM and report memory usage from the server info and service status in real MBs to realize if there is really an issue here. Thanks again.

Posted by Hostify Networks, 01-18-2011, 01:20 AM
The host will be able to tell you how many resources the account is using by looking in the Daily Process Log in WHM. If they're not complaining about it, I wouldn't worry about it. Just remember to take regular backups.



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
lfd: LOCAL RELAY (Views: 641)
Need help with arrays! (Views: 582)