I recently switched from a shared to dedicated host giving me alot more monitoring/control. I've been trying to debug an issue I've had since before I switched, very high memory usage. I think I've narrowed it down to a specific script that is a subscription to an instagram feed/api. It works in a codeIgniter framework.
This is a screenshot of my processes. Note the really high httpd memory values
Here's my controller in codeIgniter
class Subscribe extends CI_Controller {
function __construct() {
parent::__construct();
$this->instagram_api->access_token = 'hidden';
}
function callback()
{
//echo anchor('logs/activity.log', 'LOG');
$min_id = '';
$next_min_id = '';
$this->load->model('Subscribe_model');
$min_id = $this->Subscribe_model->min_id();
echo $min_id;
$pugs = $this->instagram_api->tagsRecent('tagg','',$min_id);
if($pugs){
if (property_exists($pugs->pagination, 'min_tag_id')) {
$next_min_id = $pugs->pagination->min_tag_id;
}
foreach($pugs as $pug) {
if(is_array($pug)) {
foreach($pug as $media) {
$url = $media->images->standard_resolution->url;
$m_id = $media->id;
$c_time = $media->created_time;
$user = $media->user->username;
$filter = $media->filter;
$comments = $media->comments->count;
$caption = $media->caption->text;
$link = $media->link;
$low_res=$media->images->low_resolution->url;
$thumb=$media->images->thumbnail->url;
$lat = $media->location->latitude;
$long = $media->location->longitude;
$loc_id = $media->location->id;
$date = new DateTime('2000-01-01', new DateTimeZone('Pacific/Nauru'));
$data = array(
'media_id' => $m_id,
'min_id' => $next_min_id,
'url' => $url,
'c_time' => $c_time,
'user' => $user,
'filter' => $filter,
'comment_count' => $comments,
'caption' => $caption,
'link' => $link,
'low_res' => $low_res,
'thumb' => $thumb,
'lat' => $lat,
'long' => $long,
'loc_id' => $loc_id,
);
$this->Subscribe_model->add_pug($data);
}
}
}
}
and here is the model....
class Subscribe_model extends CI_Model {
function min_id(){
$this->db->order_by("c_time", "desc");
$query = $this->db->get("pugs");
if ($query->num_rows() > 0)
{
$row = $query->row();
$min_id = $row->min_id;
if(!$min_id){
$min_id ='';
}
}
return $min_id;
}
function add_pug($data){
$query = $this->db->get_where('pugs', array('media_id'=>$data['media_id']));
if($query->num_rows() > 0){
return FALSE;
}else{
$this->db->insert('pugs', $data);
}
}
}
//============================EDIT========================//
I've converted some of the services over to fast-cgi and it seems to have brought my memory usage down significantly but I've noticed a bump in CPU. I was hoping that switching to a dedicated server would have far less headaches and make things much easier but it's been a nightmare so far. Affraid I've bit off more than I can chew.
Another fear of mine is adding some more domain names to the server. Will that add a new process that will run real high like the multiple php-cgi's running in the last image?
Here's my most recent outputs...