Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/251.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 负载平衡和APC_Php_Load Balancing_Apc - Fatal编程技术网

Php 负载平衡和APC

Php 负载平衡和APC,php,load-balancing,apc,Php,Load Balancing,Apc,我对一个场景感兴趣,其中为PHP应用程序提供服务的Web服务器使用负载平衡器进行设置 负载平衡器后面将有多个带有APC的Web服务器。所有请求都必须通过负载平衡器,然后负载平衡器将其发送到其中一个web服务器进行处理 我知道memcached应该用于分布式缓存,但我认为在每台机器上都有APC缓存,比如应用程序配置和其他对象在任何服务器上都不会不同,这将产生更好的性能 此应用程序还有一个管理员区域。还可以通过负载平衡器(例如,site.com/admin)访问它。在这种情况下,,如何调用apc\u

我对一个场景感兴趣,其中为PHP应用程序提供服务的Web服务器使用负载平衡器进行设置

负载平衡器后面将有多个带有APC的Web服务器。所有请求都必须通过负载平衡器,然后负载平衡器将其发送到其中一个web服务器进行处理

我知道memcached应该用于分布式缓存,但我认为在每台机器上都有APC缓存,比如应用程序配置和其他对象在任何服务器上都不会不同,这将产生更好的性能


此应用程序还有一个管理员区域。还可以通过负载平衡器(例如,site.com/admin)访问它。在这种情况下,,如何调用
apc\u clear\u cache
清除所有服务器上的apc对象缓存?

在您的网络外部,您有一个公共IP,用于将所有请求路由到负载均衡器,该均衡器分配负载循环,因此在外部,您不能一次一个请求清除每个服务器上的缓存,因为您不知道在任何给定时间使用的是哪一个。但是,在您的网络中,每台机器都有自己的内部IP,可以直接调用。知道了这一点,你可以做一些有趣/奇怪的事情,在外部工作

我喜欢的一个解决方案是能够点击一个URL并完成所有类似的事情。如果你也喜欢,请继续阅读。请记住,如果您愿意,您可以对此进行身份验证,以便您的管理员可以点击此按钮,或者以您保护它的方式进行操作

您可以创建逻辑,从外部发出一个请求以清除所有服务器上的缓存。无论哪台服务器收到清除缓存的请求,都将使用相同的逻辑与所有服务器对话以清除其缓存。这听起来很奇怪,有点像弗兰肯斯坦,但假设我们有3台服务器内部都有IPS10.232.12.1、10.232.12.2、10.232.12.3,那么逻辑是这样的:

1) All servers would have two files called "initiate_clear_cache.php" and "clear_cache.php" that would be the same copies for all servers.

2) "initiate_clear_cache.php" would do a file_get_contents for each machine in the network calling "clear_cache.php" which would include itself
for example: 
file_get_contents('http://10.232.12.1/clear_cache.php');
file_get_contents('http://10.232.12.2/clear_cache.php');
file_get_contents('http://10.232.12.3/clear_cache.php');

3) The file called "clear_cache.php" is actually doing the cache clearing for its respective machine.

4) You only need to make a single request now such as http://www.mywebsite/initial_clear_cache.php and you are done.

让我知道这是否适合你。我在.NET和Node.js中做过类似的操作,但还没有在PHP中尝试过,但我确信概念是相同的。:)

这似乎更适合于或..您可能想在serverfault.com上问这个问题。