Exemplo n.º 1
0
function get_instance_util_data($game)
{
    define('TTL', 30 * 60);
    //cache expiry time for apc is 30min
    $key = "instance_util_data_{$game}";
    $instances_obj = apc_fetch($key, $success);
    if ($success) {
        return $instances_obj;
    } else {
        $instance_util_obj = new InstanceUtilAdapter($game);
        $instances_obj = array("instances" => $instance_util_obj->get_instances_detail_data(), "total" => $instance_util_obj->get_game_summary(), "dau" => $instance_util_obj->get_dau());
        apc_add($key, $instances_obj, TTL);
        return $instances_obj;
    }
}
function get_games_summary_info($games, $zc = 0)
{
    $reportDataCollector = new ReportCollector($GLOBALS['server_cfg']);
    $dataArr = array();
    $cost_per_user_min = 1000;
    foreach ($games as $game) {
        $instance_util_obj = new InstanceUtilAdapter($game);
        $data = $instance_util_obj->get_game_summary();
        if ($data["rps"] == 0 or $data["dau"] === NULL) {
            //dont show games whose data is unavailable
            continue;
        }
        $cost_per_user = round($data["cost"] / $data["dau"], 4);
        if ($cost_per_user > 0) {
            $cost_per_user_min = min($cost_per_user, $cost_per_user_min);
        }
        $slack = round(($data["count"] - $data["optimal_instance_count"]) * 100 / $data["count"], 2);
        $dataArr[$game] = array("count" => $data["count"], "rps" => round($data["rps"]), "cost" => $data["cost"], "dau" => $data["dau"], "dau_per_instance" => round($data["dau"] / $data["count"]), "cost_per_user" => $cost_per_user, "optimal_instance_count" => $data["optimal_instance_count"], "slack" => $slack);
        /*
         * Review Comment :- create a function for this 
         * not creating a function as the no of parameters are too many 
         * and creating a fn would not be helpful
         */
        if ($_GET['store_report'] == 'true') {
            // inserting data in the report instance_utilization table
            $data_utilization['game'] = $game;
            $data_utilization['total_instance'] = $data["count"];
            $data_utilization['DAU'] = $data["dau"];
            $data_utilization['DAU_per_instance'] = round($data["dau"] / $data["count"]);
            $data_utilization['optimal_instance_count'] = $data["optimal_instance_count"];
            $data_utilization['slack_per'] = $slack;
            $data_utilization['cloud_id'] = $zc;
            $reportDataCollector->insertInstanceUtilization($data_utilization);
        }
    }
    $dataArr = sort_by_dau($dataArr);
    global $server_cfg;
    if (isset($server_cfg["hostname"])) {
        $hostname = $server_cfg["hostname"];
    } else {
        $hostname = "*****@*****.**";
    }
    return $dataArr;
}
Exemplo n.º 3
0
    $game = $_GET["game"];
} else {
    $game = $game_list[0];
}
$game_cfg = load_game_config($game);
if (isset($game_cfg["cloud_name"]) && $game_cfg["cloud_name"] == "zcloud") {
    define("DAU_PI_GOOD", $server_cfg['dau_pi_good_zc']);
    define("DAU_PI_BAD", $server_cfg['dau_pi_bad_zc']);
} else {
    define("DAU_PI_GOOD", $server_cfg['dau_pi_good']);
    define("DAU_PI_BAD", $server_cfg['dau_pi_bad']);
}
define("NA", "<i>-- NA --</i>");
define("SLACK_GOOD", 15);
define("SLACK_BAD", 30);
$instance_util_obj = new InstanceUtilAdapter($game);
function get_game_status($dau)
{
    if ($dau >= DAU_PI_GOOD) {
        $status = "GREEN";
    } else {
        if ($dau >= DAU_PI_BAD) {
            $status = "ORANGE";
        } else {
            $status = "RED";
        }
    }
    $markup = "<b>Status:<sup>1</sup> </b><span style='background-color:{$status};'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp</span>";
    return $markup;
}
function format_dau_per_instance($dau)
Exemplo n.º 4
0
 public function computeSlack($values)
 {
     include_once "../report/instance-util-adapter.php";
     include_once "../report/report-collector.php";
     $return_array = $this->parse_inputs_computeSlack($values);
     if (!$return_array) {
         return false;
     }
     $game = $return_array['game_name'];
     if (!in_array($game, $this->server_cfg['game_list'])) {
         $this->status = 5;
         return false;
     }
     $dataArr = array();
     $slack_now = $return_array['slack_now'];
     $instance_util_obj = new InstanceUtilAdapter($game, $slack_now);
     $instances = $instance_util_obj->get_instances_breakup_data();
     $dau = $instance_util_obj->get_dau();
     //		$class_data = $instances["web"];
     $pool_slack = array();
     foreach ($instances as $class => $class_data) {
         foreach ($class_data as $pool => $data) {
             if ($data["count"] == null || $data["count"] == 0) {
                 //if instance count is 0, don't show in report
                 continue;
             }
             $dau_per_instance = round($dau / $data["count"]);
             $util = $this->get_util($data["util"]);
             $bottleneck = $data["util"]["bottleneck_key"];
             $underutilized = $data["util"]["underutil_key"];
             if ($bottleneck == "") {
                 $bottleneck = "-";
             }
             if ($underutilized == "") {
                 $underutilized = "-";
             }
             if ($util == NA) {
                 $optimal_count = NA;
                 $optimal_cost = NA;
                 $optimal_cost_year = NA;
                 $slack = NA;
                 $headroom = NA;
             } else {
                 $optimal_count = $data["optimal_instance_count"];
                 $optimal_count_factor = $data["optimal_count_factor"];
                 $optimal_cost = number_format($data["optimal_cost"]);
                 $optimal_cost_year = number_format($data["optimal_cost"] * 30 * 365);
                 $slack = number_format(($data["count"] - $data["optimal_instance_count"]) * 100 / $data["count"], 2, '.', '') . "%";
                 $headroom = $this->get_headroom($data["util"]["utilization"]) . "%";
             }
             $pool_slack[$pool]["slack"] = $slack;
             $pool_slack[$pool]["count"] = $data["count"];
             $pool_slack[$pool]["optimal_instance_count"] = $optimal_count;
             $pool_slack[$pool]["optimal_count_factor"] = $optimal_count_factor;
         }
     }
     $pool_slack = json_encode($pool_slack);
     echo $pool_slack . "\n";
     $this->status = 6;
 }