将用户重定向,如果服务器拥挤和繁忙使用PHP? [英] redirecting users if server is overcrowded or busy using php?

查看:138
本文介绍了将用户重定向,如果服务器拥挤和繁忙使用PHP?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能使用PHP将用户重定向到页面即busy.php 当服务器繁忙或者拥挤的,或者类似的东西?感谢:))

is it possible to use php to redirect users to page i.e. busy.php when the server is busy or overcrowded, or something similiar? thanks :))

推荐答案

您可以使用PHP内部函数如内存,让使用率的 http://php.net/manual/de/function.memory-get-usage.php 或访问一个shell脚本,为您提供了一些信息约服务器的当前负载。然后根据这些信息通过页眉设置一个重定向。

You could use PHP Internal Functions like memory-get-usage http://php.net/manual/de/function.memory-get-usage.php or access a Shell Script that gives you some kind of Information about the current load of the Server. And then depending on that Information set a Redirect via Headers.

但是,请记住,如果你的服务器发生故障时,最有可能的PHP脚本就不会被执行,也没有重定向会发生。因此,根据您的基础架构可以处理这种过度的辅助服务器(负载平衡器也许)。

However, Remember that if your server breaks down, most likely the PHP Script wouldn't be executed and no redirect would happen. So, depending on your Infrastructure you can handle this over a secondary Server (a Load-Balancer perhaps).

如果你能缩小崩溃的最可能的原因,尝试获取它在那里,例如,如果你的MySQL连接失败,访存,并指导用户到你的忙页。

If you can narrow down the most likely cause of a breakdown, try to fetch it there, for example if your MySQL Connection fails, fetch that, and direct the User to your "busy page".

这篇关于将用户重定向,如果服务器拥挤和繁忙使用PHP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆