서버 점검 안내

dsclub은 서비스의 안정성과 성능 향상을 위해
매일 04시 30분에 정기 점검이 진행됩니다.

점검 시간: 오전 4시 30분 ~ 4시 35분

해당 시간 동안 일시적으로 서비스에 접속이 불가능하오니, 양해 부탁드립니다.

가능 동시 접속자 계산기 > 코딩 스토리

가능 동시 접속자 계산기

페이지 정보

작성자 profile_image tak2 (115.♡.171.219) 작성일 24-08-17 23:22 조회 173 댓글 0

본문

<?php
// 서버의 CPU 코어 수 가져오기
$cpu_cores = (int)trim(shell_exec("nproc --all"));
echo "CPU 코어 수: " . $cpu_cores . " (nproc --all 명령어 사용)\n";

// 서버의 메모리 용량 (MB) 가져오기
$memory_info = shell_exec("free -m");
preg_match('/Mem:\s+(\d+)\s+/', $memory_info, $matches);
$memory_mb = (int)$matches[1];
echo "서버 메모리 용량: " . $memory_mb . "MB (free -m 명령어 사용)\n";

// 네트워크 속도 측정 (예: eth0 인터페이스 사용)
$network_info = shell_exec("cat /sys/class/net/eth0/speed");
$network_speed_mbps = (int)trim($network_info);
echo "네트워크 속도: " . $network_speed_mbps . "Mbps (eth0 인터페이스 속도)\n";

// 한 사용자당 필요한 리소스 (CPU 코어, 메모리, 네트워크 대역폭)
$cpu_per_user = 0.05; // 한 사용자당 0.05 코어 필요
$memory_per_user = 0.01 * 1024; // 한 사용자당 0.01 GB 필요 (MB로 변환)
$network_per_user_mbps = 1; // 한 사용자당 1 Mbps 필요

// 최대 접속 가능 인원 수 계산
$max_users_cpu = floor($cpu_cores / $cpu_per_user);
$max_users_memory = floor($memory_mb / $memory_per_user);
$max_users_network = floor($network_speed_mbps / $network_per_user_mbps);

// 최소값을 선택하여 최종 접속 가능 인원 수 결정
$max_users = min($max_users_cpu, $max_users_memory, $max_users_network);
echo "최종 동시 접속 가능 인원 수: " . $max_users . "명\n";

// 현재 시간과 동시 접속 가능 인원 수 출력
echo date("Y-m-d H:i:s") . " - 현재 동시 접속 가능 인원 수: " . $max_users . "명\n";
?>
좋아요0 이 글을 좋아요하셨습니다
url 복사 카카오톡 공유 라인 공유 페이스북 공유 트위터 공유

등록된 댓글이 없습니다.

전체 269건
게시물 검색

접속자집계

오늘
27
어제
1,445
최대
4,271
전체
290,937