The invention discloses an application server call method and system based on Nginx. The method includes: using pre-written shell script to detect the running parameters of application server A, obtaining the running parameters of other application servers in the system when the running parameters are greater than or equal to the preset threshold, comparing and obtaining the most idle application server B of the other application servers, and determining that the running parameters of application server B are larger than those of application server A. The startup command is sent to the application server B to enable the shell script of the application server B to start the pre-deployed application on the application server B. The Nginx configuration of the application server A is modified by the shell script, and the preset percentage of access on the application server A is switched to the application server B by using the Nginx asynchronous non-blocking event handling mechanism. The invention can start the idle server to bear part of the access when the performance of the application server is reduced, so as to achieve the purpose of rational utilization of resources.
【技术实现步骤摘要】
一种基于Nginx的应用服务器调用方法及系统
本专利技术涉及服务器
,尤其涉及一种基于Nginx的应用服务器调用方法及系统。
技术介绍
Nginx是一款轻量级的Web服务器/反向代理服务器,已经在俄罗斯最大的门户网站——RamblerMedia(www.rambler.ru)上运行多年时间,同时俄罗斯超过20%的虚拟主机平台采用Nginx作为反向代理服务器,而在国内,淘宝、新浪博客、新浪播客、网易新闻、六间房、56.com、Discuz!、水木社区、豆瓣、YUPOO、海内、迅雷在线等多家网站使用Nginx作为Web服务器或反向代理服务器。而当多台服务器提供同一种应用访问服务时,往往存在,其中几台服务器的服务器请求过多,服务器应用性能大大降低,而其中的一服务器却空闲着的情况,导致服务器利用不充分,造成资源浪费的结果。
技术实现思路
本专利技术所要解决的技术问题在于提供了一种在服务器资源紧张、应用服务数据量突然大增的情况下能充分利用空闲资源提供服务,达到资源不浪费又合理解决应用服务性能问题的基于Nginx的服务器调用方法及系统。为解决上述技术问题,本专利技术采用以下技术方案:本专利技术一方面提供了一种基于Nginx的应用服务器调用方法,该方法包括:利用预先编写的shell脚本检测应用服务器A的运行参数,当运行参数大于等于预置阈值时,获取系统中其他应用服务器的运行参数,比较得到所述其他应用服务器中最为空闲的应用服务器B,并确定所述应用服务器B的运行参数大于所述应用服务器A的运行参数;其中,所述运行参数包括:CPU使用率、内存使用量及访问量;发送启动命令给所述应 ...
【技术保护点】
1.一种基于Nginx的应用服务器调用方法,其特征在于,该方法包括:利用预先编写的shell脚本检测应用服务器A的运行参数,当运行参数大于等于预置阈值时,获取系统中其他应用服务器的运行参数,比较得到所述其他应用服务器中最为空闲的应用服务器B,并确定所述应用服务器B的运行参数大于所述应用服务器A的运行参数;其中,所述运行参数包括:CPU使用率、内存使用量及访问量;发送启动命令给所述应用服务器B,以使应用服务器B的shell脚本启动应用服务器B上预先部署的同种应用;通过所述shell脚本修改所述应用服务器A的Nginx配置,利用Nginx异步非阻塞的事件处理机制将应用服务器A上预置百分比的访问量切换至所述应用服务器B,以调用应用服务器B处理所述预置百分比的访问量。
【技术特征摘要】
1.一种基于Nginx的应用服务器调用方法,其特征在于,该方法包括:利用预先编写的shell脚本检测应用服务器A的运行参数,当运行参数大于等于预置阈值时,获取系统中其他应用服务器的运行参数,比较得到所述其他应用服务器中最为空闲的应用服务器B,并确定所述应用服务器B的运行参数大于所述应用服务器A的运行参数;其中,所述运行参数包括:CPU使用率、内存使用量及访问量;发送启动命令给所述应用服务器B,以使应用服务器B的shell脚本启动应用服务器B上预先部署的同种应用;通过所述shell脚本修改所述应用服务器A的Nginx配置,利用Nginx异步非阻塞的事件处理机制将应用服务器A上预置百分比的访问量切换至所述应用服务器B,以调用应用服务器B处理所述预置百分比的访问量。2.根据权利要求1所述的一种基于Nginx的应用服务器调用方法,其特征在于,所述利用预先编写的shell脚本检测应用服务器A的运行参数包括:利用预先编写的shell脚本周期性地检测应用服务器A的运行参数。3.根据权利要求2所述的一种基于Nginx的应用服务器调用方法,其特征在于,所述利用Nginx异步非阻塞的事件处理机制将应用服务器A上预置百分比的访问量切换至所述应用服务器B之后还包括:当应用服务器A的访问量小于所述预置访问量时,利用所述shell脚本修改应用服务器A的Nginx配置,并发送停止命令给所述应用服务器B,以使应用服务器B在处理完所述预置百分比的访问量之后停止所述同种应用。4.根据权利要求1所述的一种基于Nginx的应用服务器调用方法,其特征在于,所述利用预先编写的shell脚本检测应用服务器A的运行参数之前还包括:启动所述shell脚本。5.根据权利要求1所述的一种基于Nginx的应用服务器调用方法,其特征在于,所述当运行参数大于等于预置阈值时包括:当所述CPU使用率大于等于预置使用率时;和/或当所述内存使用量大于等于预置使用量时;和/或当所述访问量大于等于预置访问量时。6.一种...
【专利技术属性】
技术研发人员:赵雁峰,赵善浮,项为平,邱小宁,王月华,陈育嘉,利俊杰,彭优,沈强,
申请(专利权)人:广东亿迅科技有限公司,
类型:发明
国别省市:广东,44
还没有人留言评论。发表了对其他浏览者有用的留言会获得科技券。