我刚刚阅读了这篇Digital Ocean的文章 ,想知道最后一个例子中的拓扑结构是否可以用nginx来实现。
我对负载平衡器如何处理不在应用程序服务器之前的两个专用caching服务器感兴趣。 他们描述这样的过程:
我想负载均衡器应该在上游指令中有两个组:
upstream cachebackend { server cache-1.example.com; server cache-2.example.com; } upstream appbackend { server app-1.example.com; server app-2.example.com; }
然后从一个服务器指令:
location / { proxy_pass http://cachebackend; # if that one is a MISS, request this one: # proxy_pass http://appbackend; # and then save the response on the cachebackend # before returning it to the client }
我想知道如何告诉nginx遵循上面的步骤,或者如果可能的话。
谢谢 :)
Nginx可以同时进行负载平衡和caching,只需要使用proxy_cache_path指令configurationcaching区域,并使用proxy_cache_path将其分配给特定的server {}或location {} 。 所以,总结一下,如果使用nginx作为负载平衡器和caching,Digital Ocean架构看起来就是多余的。