자유게시판

제목 http2를 적용했더니....
글쓴이 테러보이 작성시각 2018/01/05 14:36:04
댓글 : 9 추천 : 1 스크랩 : 0 조회수 : 10603   RSS
테러보이

마음이 편해졌습니다. ㅎㅎ

뭐... 딱히 바뀐게 눈에 보이지도 않고 하는 서비스도 없지만 뿌듯하네요~

https://z9n.net

크롬에서 적용 여부 확인은

https://chrome.google.com/webstore/detail/http2-and-spdy-indicator/mpbpobfflnpcgagjijhmgnchggcjblin

를 이용하시면 편합니다 ㅎㅎ

 다음글 DB 네이밍... (6)
 이전글 Happy New Year 2018 (3)

댓글

한대승(불의회상) / 2018/01/05 15:59:40 / 추천 0

아직은 뭐가 다른지 모르겠어요. ㅋㅋㅋㅋ

 

이현재 / 2018/01/05 19:56:07 / 추천 0
아무것도 설정 안 해놓은 빈 페이지 상태에서도 20퍼 정도 빨랐는데, 대충 확인한거라 정확한 수치는 아닐거에요.
테러보이 / 2018/01/06 14:06:38 / 추천 0

@한대승

저두요 ㅎㅎㅎ

테러보이 / 2018/01/06 14:07:19 / 추천 0

@러즈

20퍼센트나 빨라지나요? 엄청나군요 ㅎㅎ

 

http://test.z9n.net/bm.php

https://z9n.net/bm.php

이렇게는 빠른지 모르겠네요 ㅎㅎㅎ

 

<?php

/**
 * PHP Script to benchmark PHP and MySQL-Server
 *
 * inspired by / thanks to:
 * - www.php-benchmark-script.com  (Alessandro Torrisi)
 * - www.webdesign-informatik.de
 *
 * @author odan
 * @license MIT
 */
// -----------------------------------------------------------------------------
// Setup
// -----------------------------------------------------------------------------
set_time_limit(120); // 2 minutes

$options = array();

// Optional: mysql performance test
//$options['db.host'] = '127.0.0.1';
//$options['db.user'] = 'root';
//$options['db.pw'] = '';
//$options['db.name'] = 'test';
// -----------------------------------------------------------------------------
// Main
// -----------------------------------------------------------------------------
// check performance
$benchmarkResult = test_benchmark($options);

// html output
echo "<!DOCTYPE html>\n<html><head>\n";
echo "<style>
    table {
        color: #333; /* Lighten up font color */
        font-family: Helvetica, Arial, sans-serif; /* Nicer font */
        width: 640px;
        border-collapse:
        collapse; border-spacing: 0;
    }

    td, th {
        border: 1px solid #CCC; height: 30px;
    } /* Make cells a bit taller */

    th {
        background: #F3F3F3; /* Light grey background */
        font-weight: bold; /* Make sure they're bold */
    }

    td {
        background: #FAFAFA; /* Lighter grey background */
    }
    </style>
    </head>
    <body>";

echo array_to_html($benchmarkResult);



$start = get_time();
/*
수행할 내용
*/
$end = get_time();
$time = $end - $start;
echo '<br/>'.number_format($time, 20).'초 걸림';

echo "\n</body></html>";
exit;

// -----------------------------------------------------------------------------
// Benchmark functions
// -----------------------------------------------------------------------------

function test_benchmark($settings)
{
    $timeStart = microtime(true);

    $result = array();
    $result['version'] = '1.1';
    $result['sysinfo']['time'] = date("Y-m-d H:i:s");
    $result['sysinfo']['php_version'] = PHP_VERSION;
    $result['sysinfo']['platform'] = PHP_OS;
    $result['sysinfo']['server_name'] = $_SERVER['SERVER_NAME'];
    $result['sysinfo']['server_addr'] = $_SERVER['SERVER_ADDR'];

    test_math($result);
    test_string($result);
    test_loops($result);
    test_ifelse($result);
    if (isset($settings['db.host'])) {
        test_mysql($result, $settings);
    }

    $result['total'] = timer_diff($timeStart);
    return $result;
}

function test_math(&$result, $count = 99999)
{
    $timeStart = microtime(true);

    $mathFunctions = array("abs", "acos", "asin", "atan", "bindec", "floor", "exp", "sin", "tan", "pi", "is_finite", "is_nan", "sqrt");
    for ($i = 0; $i < $count; $i++) {
        foreach ($mathFunctions as $function) {
            call_user_func_array($function, array($i));
        }
    }
    $result['benchmark']['math'] = timer_diff($timeStart);
}

function test_string(&$result, $count = 99999)
{
    $timeStart = microtime(true);
    $stringFunctions = array("addslashes", "chunk_split", "metaphone", "strip_tags", "md5", "sha1", "strtoupper", "strtolower", "strrev", "strlen", "soundex", "ord");

    $string = 'the quick brown fox jumps over the lazy dog';
    for ($i = 0; $i < $count; $i++) {
        foreach ($stringFunctions as $function) {
            call_user_func_array($function, array($string));
        }
    }
    $result['benchmark']['string'] = timer_diff($timeStart);
}

function test_loops(&$result, $count = 999999)
{
    $timeStart = microtime(true);
    for ($i = 0; $i < $count; ++$i) {

    }
    $i = 0;
    while ($i < $count) {
        ++$i;
    }
    $result['benchmark']['loops'] = timer_diff($timeStart);
}

function test_ifelse(&$result, $count = 999999)
{
    $timeStart = microtime(true);
    for ($i = 0; $i < $count; $i++) {
        if ($i == -1) {

        } elseif ($i == -2) {

        } else if ($i == -3) {

        }
    }
    $result['benchmark']['ifelse'] = timer_diff($timeStart);
}

function test_mysql(&$result, $settings)
{
    $timeStart = microtime(true);

    $link = mysqli_connect($settings['db.host'], $settings['db.user'], $settings['db.pw']);
    $result['benchmark']['mysql']['connect'] = timer_diff($timeStart);

    //$arr_return['sysinfo']['mysql_version'] = '';

    mysqli_select_db($link, $settings['db.name']);
    $result['benchmark']['mysql']['select_db'] = timer_diff($timeStart);

    $dbResult = mysqli_query($link, 'SELECT VERSION() as version;');
    $arr_row = mysqli_fetch_array($dbResult);
    $result['sysinfo']['mysql_version'] = $arr_row['version'];
    $result['benchmark']['mysql']['query_version'] = timer_diff($timeStart);

    $query = "SELECT BENCHMARK(1000000,ENCODE('hello',RAND()));";
    $dbResult = mysqli_query($link, $query);
    $result['benchmark']['mysql']['query_benchmark'] = timer_diff($timeStart);

    mysqli_close($link);

    $result['benchmark']['mysql']['total'] = timer_diff($timeStart);
    return $result;
}

function timer_diff($timeStart)
{
    return number_format(microtime(true) - $timeStart, 3);
}

function array_to_html($array)
{
    $result = '';
    if (is_array($array)) {
        $result .= '<table>';
        foreach ($array as $k => $v) {
            $result .= "\n<tr><td>";
            $result .= '<strong>' . htmlentities($k) . "</strong></td><td>";
            $result .= array_to_html($v);
            $result .= "</td></tr>";
        }
        $result .= "\n</table>";
    } else {
        $result = htmlentities($array);
    }
    return $result;
}
function get_time() {
    list($usec, $sec) = explode(" ", microtime());
    return ((float)$usec + (float)$sec);
}

 

변종원(웅파) / 2018/01/06 15:12:54 / 추천 0

저도 적용해봐야겠네요. 

이제 서포트모드에서 메인개발모드로 전환을 해야할 시점이라... ^^

테러보이 / 2018/01/06 15:33:49 / 추천 0
@웅파
인증서는 letsencrypt 가 최고더군요 ㅎㅎㅎ
kaido / 2018/01/07 14:40:53 / 추천 0

20% 수준 아닙니다 ㅎㅎ

SSL적용 기준으로 10배 가까이 빨라집니다 ㅎㅎ

국내에는 인프라가 빨라서 체감이 20% 수준이지, 국외에서 PING 테스트 해보면 비교 대상이 아닙니다 

최적의 스피드를 위해서는 http2 & ssl 적용에 맞게 퍼블리싱도 맞춰줘야 합니다.

이현재 / 2018/01/07 20:31:37 / 추천 0
빈페이지 기준이었고, 이것저것 넣다보면 카이도님 이야기처럼 국내에서도 사이트에 따라 두 배 이상도 차이납니다. 어느정도 보급되고 있으니 도입해서 쓰는게 좋겠죠. 저기에 amp기반으로 하니 속도는 정말 마음에 들더군요.
테러보이 / 2018/01/07 20:40:06 / 추천 0
@kaido 속도 개선이 어마무시하군요!
@러즈 오호! 다른 방법으로 테스트 해봐야겠네요 ㅎㅎ