PHP服务器负载判断
<?php
header("content-type:text/html;charset=utf-8"); // echo PHP_OS;exit;
// echo get_server_load();
var_dump(sys_getloadavg()); /*
$load = sys_getloadavg();
if ($load[0] > 80) {
header('HTTP/1.1 503 Too busy, try again later');
die('Server too busy. Please try again later.');
}
*/ // 建议最大负载不要超过3*N核,例如有16核(含8核超线程)则 16*3=48
function get_server_load() { if (stristr(PHP_OS, 'win')) { $wmi = new COM("Winmgmts://");
$server = $wmi->execquery("SELECT LoadPercentage FROM Win32_Processor"); $cpu_num = 0;
$load_total = 0; foreach($server as $cpu){
$cpu_num++;
$load_total += $cpu->loadpercentage;
} $load = round($load_total/$cpu_num); } else { $sys_load = sys_getloadavg();
$load = $sys_load[0]; } return (int) $load; }
PHP服务器负载判断的更多相关文章
- Linux 通过 load average 判断服务器负载情况
Linux中load average判断服务器负载情况 转载文章 http://www.111cn.net/sys/linux/56003.htm 写的比较详细,推荐看看.
- 排查nginx、tomcat内存和服务器负载之后
最近客户现在提出系统访问非常慢,需要优化提升访问速度,在排查了nginx.tomcat内存和服务器负载之后,判断是数据库查询速度慢,进一步排查发现是因为部分视图和表查询特别慢导致了整个系统的响应时间特 ...
- nginx配置实例及多服务器负载
目录 nginx配置实例 多服务器负载 nginx配置实例 nginx.conf worker_processes 1; events { worker_connections 1024; } htt ...
- LNMP笔记:安装 Xcache 缓存扩展,降低服务器负载
LNMP笔记:安装 Xcache 缓存扩展,降低服务器负载 2014/11/27 教程笔记 4,743 14 WordPress 精品主机推荐:恒创主机 | 阿里云(本站目前所用云主机) 倡萌 ...
- Nginx + tomcat服务器 负载均衡
Nginx 反向代理初印象 Nginx (“engine x”) 是一个高性能的HTTP和反向代理 服务器,也是一个IMAP/POP3/SMTP服务器.其特点是占有内存少,并发能力强,事实上nginx ...
- 高性能Nginx服务器-负载均衡
Location正则表达式 location的作用 location指令的作用是根据用户请求的URI来执行不同的应用,也就是根据用户请求的网站URL进行匹配,匹配成功即进行相关的操作. locatio ...
- 服务器负载均衡lvs(Linux Virtual Server)
服务器负载均衡lvs(Linux Virtual Server) 一.总结 LVS是Linux Virtual Server的简写,意即Linux虚拟服务器,是一个虚拟的服务器集群系统. 三.Linu ...
- 利用Nginx中的Upstream模块配置服务器负载均衡
1. 前言 nginx有一个最大的功能就是可以实现服务器的负载均衡,本篇博文就利用nginx中的upstream模块来配置一个简单的负载均衡.关于nginx的安装和配置文件可以查阅博文:windows ...
- 服务器负载过高问题分析-不是cpu高负载也不是IO负载如何处理(阿里 几乎是必考题)
关于top命令 经常问load average 参考:load average 定义(网易面试) jvm dump的使用 参考:Jvm dump jstack jmap jstat 介绍与使用(内存与 ...
随机推荐
- apue.h
[root@localhost unix_env_advance_prog]# cat apue.h #ifndef _APUE_H #define _APUE_H #define _XOPEN_SO ...
- Link List
At first, i prepared to go through <the introduction to algorithm> ,however , i found some par ...
- unix fopen和fopen_s用法的比较
在定义FILE * fp 之后,fopen的用法是: fp = fopen(filename,"w").而对于fopen_s来说,还得定义另外一个变量errno_t err,然后e ...
- cocos2dx 背景用小尺寸图片滚动填充的方法
直接上代码 在初始化方法中添加图片: bool BackGroundLayer::init() { frameCache=CCSpriteFrameCache::sharedSpriteFrameCa ...
- Algernon's Noxious Emissions POJ1121 zoj1052
One of the greatest alchemists of the lower Middle Renaissance, Algernon da Vinci (one of Leonardo's ...
- html笔记01:顺序和无序列表
<!DOCTYPE html> <html> <body> <li>Yellow <ul><li>Wet soil</li ...
- SqlServer高版本数据本分还原到低版本方法
最近遇见一个问题: 想要将Sqlserver高版本备份的数据还原到低版本SqlServer上去,但是这在SqlServer中是没法直接还原数据库的,所以经过一系列的请教总结出来一下可用方法. 首先.你 ...
- KindEditor编辑器, 利用ajax动态切换编辑器内容
// 后台成功返回数据后的js处理 KindEditor.remove('#content_id'); // 先移除之前创建的编辑器 var editor = KindEditor.create('# ...
- Halcon C++混合编程学习之Qt 实现检测焊接点
1 # include "HalconCpp.h" # include "HDevThread.h" # include <X11/Xlib.h> ...
- Adobe Edge Animate--关于全局变量和全局方法的定义
Adobe Edge Animate--关于全局变量和全局方法的定义 版权声明: 本文版权属于 北京联友天下科技发展有限公司. 转载的时候请注明版权和原文地址. BY:sonicxsxs 前文中有关音 ...