简体   繁体   English

使用 Nginx 与 Redis 进行缓存,使用 Nginx 进行代理和负载平衡

[英]Cache using Nginx vs Redis, Proxy and Load balancing using Nginx

I am interested in widening my knowledge in designing large scale distributed systems.我有兴趣扩大我在设计大型分布式系统方面的知识。 I have come across the topics Cache and Proxy servers.我遇到了缓存和代理服务器的主题。 For Proxy servers we are using Nginx for example, and Nginx also has it's own Cache.例如,对于代理服务器,我们使用 Nginx,Nginx 也有它自己的缓存。 Now, what is the major difference between the cache inside Nginx and Redis?现在,Nginx 和 Redis 中的缓存之间的主要区别是什么? Particularly I read many articles regarding Proxy servers.特别是我阅读了许多关于代理服务器的文章。 I am not completely getting the point of these proxy servers.我没有完全理解这些代理服务器的意义。 Some articles do mention that load balancers, proxy and cache are done in Nginx itself, and some have separate servers for each.有些文章确实提到负载均衡器、代理和缓存是在 Nginx 本身中完成的,有些文章各自都有单独的服务器。 Could any one please elaborate these in a better way?有人可以以更好的方式详细说明这些吗? Thanks in advance.提前致谢。

They each serve their own purpose.他们每个人都有自己的目的。 NGINX could cache the static assets you have deployed and also responses from the backend servers depending on their cache-control settings. NGINX 可以缓存您已部署的 static 资产,还可以根据其缓存控制设置来自后端服务器的响应。 This would be useful for data that is being repeatedly downloaded, JS/HTML/image files, etc. It could also cache the HTTP response for identical requests that it receives.这对于重复下载的数据、JS/HTML/图像文件等很有用。它还可以缓存 HTTP 对其接收到的相同请求的响应。

However, in your application, you may decide that some data is is expensive to compute on-the-fly or will be repeatedly requested, so you decide to cache this data in Redis.但是,在您的应用程序中,您可能认为某些数据在运行时计算成本很高或将被重复请求,因此您决定将此数据缓存在 Redis 中。 This could be any data you choose, and not necessarily the entire API response for an HTTP request but even intermediary data where you don't want to hit your database but rather return results from your cache.这可以是您选择的任何数据,不一定是针对 HTTP 请求的整个 API 响应,甚至是您不想访问数据库而是从缓存中返回结果的中间数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM