0
votes

Is there any solution to fix the localhost that runs too slow? I use XAMPP v 3.2.2.

I made highcharts with Yii 2.0, but when I try to load it http://127.0.0.1/yii2-app-basic/web/index.php?r=highcharts/index, localhost or 127.0.0.1 takes time more than 20 minutes to load the highchart. I have edited my

`httpd.conf.

I change

ServerName Localhost to ServerName 127.0.0.1:80.

I also have edited

my.ini.

I uncommented

bind-address="127.0.0.1"

I edited

config.inc.php

I change

$cfg['Servers'][$i]['host'] = 'localhost' to $cfg['Servers'][$i]['host'] = '127.0.0.1'

but localhost still being slow.

This is my highchart code in Yii 2.0

HighchartsController.php

<?php
namespace app\controllers;

use yii\web\Controller;
use app\models\Jeniskelaminreal;
use yii\helpers\Json;

class HighchartsController extends Controller
{
    public function actionIndex()
    {

        $masuk= Jeniskelaminreal::find();
        $awal = $masuk->orderBy('TahunMasuk ASC')->one()->TahunMasuk;
        $akhir = $masuk->orderBy('TahunMasuk DESC')->one()->TahunMasuk;
        // $data = $masuk->all();
        $arr_l = [];
        $arr_p = [];
        $tahun = [];


        for($i=$awal;$i<=$akhir;$i++){

                if($awal == $i){
                    $jum_l = count($masuk->where(['TahunMasuk'=>$awal,'JenisKelamin'=>'Perempuan'])->all());
                    $jum_p = count($masuk->where(['TahunMasuk'=>$awal,'JenisKelamin'=>'Laki-laki'])->all());

                }elseif($i > $awal && $i <= $akhir){
                    $jum_l = count($masuk->where(['TahunMasuk'=>$i,'JenisKelamin'=>'Perempuan'])->all());
                    $jum_p = count($masuk->where(['TahunMasuk'=>$i,'JenisKelamin'=>'Laki-laki'])->all());
                }
                array_push($arr_l,$jum_l);
                array_push($arr_p,$jum_p);
                array_push($tahun,$i);
                }               


        $data['tahun'] = json_encode($tahun);
        $data['data_p'] = json_encode($arr_p);
        $data['data_l'] = json_encode($arr_l);







        return $this->render('index',$data);
    }

    /*public function actionData()
    {
        return $this->render('data');
    }*/
}

index.php

<?php
use app\assets\HighchartsAsset;

HighchartsAsset::register($this);
$this->title = 'Highcharts Test';
?>


<div class="container">
      <div class="row">
              <div class="col-md-6 col-sm-6 col-xs-12">
                <div class="x_panel">
                  <div id="my-chart" style="min-width: 310px; height: 400px; margin: 0 auto"></div>



<?php $this->registerJs("
$(function () {
    $('#my-chart').highcharts({
        title: {
            text: 'Jenis Kelamin',
            x: -20 //center
        },

        xAxis: {
            categories: $tahun
        },
        yAxis: {
            title: {
                text: 'Jumlah'
            },
            plotLines: [{
                value: 0,
                width: 1,
                color: '#808080'
            }]
        },
        tooltip: {
            valueSuffix: ''
        },
        legend: {
            layout: 'vertical',
            align: 'right',
            verticalAlign: 'middle',
            borderWidth: 0
        },
        series: [{
            name: 'Laki-laki',
            data: $data_l
        }, {
            name: 'Perempuan',
            data: $data_p
        }]
    });
});
")?>
</div>
</div>

I think localhost becomes slow because I have tables that consist of many data records. So here I give you the information about the table that I joined.

I made view table "JeniskelaminReal". This is the query

CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `jeniskelaminreal`  AS  select 
`ipbmst_fakultas`.`Kode` AS `Fakultas`,
`ipbmst_departemen`.`Kode` AS `Departemen`,
`akdmst_mayor`.`Nama` AS `Mayor`,
`akdmst_mahasiswamagister1`.`NIM` AS `NIM`,
`ipbref_jeniskelamin`.`nama` AS `JenisKelamin`,
timestampdiff(YEAR,`ipbmst_orang`.`TanggalLahir`,now()) AS `Usia`,
`akdmst_mahasiswamagister1`.`TahunMasuk` AS `TahunMasuk` 
from (((((`akdmst_mahasiswamagister1` 
left join `akdmst_mayor` on((`akdmst_mahasiswamagister1`.`MayorID` = `akdmst_mayor`.`ID`))) 
left join `ipbmst_departemen` on((`akdmst_mayor`.`DepartemenID` = `ipbmst_departemen`.`ID`))) 
left join `ipbmst_fakultas` on((`ipbmst_departemen`.`FakultasID` = `ipbmst_fakultas`.`ID`))) 
left join `ipbmst_orang` on((`akdmst_mahasiswamagister1`.`NIM` = convert(`ipbmst_orang`.`NIMS2Key` using utf8)))) 
left join `ipbref_jeniskelamin` on((`ipbmst_orang`.`JenisKelaminID` = `ipbref_jeniskelamin`.`id`))) ;

ipbmst_fakultas consists of 21 rows data

enter image description here

ipbmst_departemen consists of 46 rows data

enter image description here

akdmst_mayor consists of 166 rows data

enter image description here

akdmst_mahasiswamagister 1 consists of 7232 rows data

enter image description here

ipbref_jeniskelamin consists of 3 rows data

enter image description here

and this is the table that consists of so many data ipbmst_orang consists of 70915

enter image description here

I'm really sorry if I put so many information here. What may I do to solve that problem? Thank you in advance

1

1 Answers

0
votes

is it working while opening other pages?

try changing listening port from 80 to 8080. and also try disableing Ipv6.