在部署到多个服务器时缓存和刷新缓存(Invalidating and refreshing cache on deployment to multiple servers)

编程入门 行业动态 更新时间:2024-10-27 07:27:44
在部署到多个服务器时缓存和刷新缓存(Invalidating and refreshing cache on deployment to multiple servers)

我正在使用Couchbase缓存。 有一个couchbase服务器。 我有多台服务器来托管应用程序,并对蓝绿部署策略进行了轻微修改,以在所有服务器上部署应用程序。 部署策略 - 考虑将前50%的服务器视为A,并将其视为B. 1.从ELB中分离出A,B仍然服务于这些请求。 2.在A上部署应用程序 3.将A重新连接到ELB。 4.从ELB分离B,但B有一些处理请求。 5.使缓存无效。 6.当B完成其挂起的请求时,新的请求转到A. 7.完成待处理的请求后,开始在B上部署。 8.在B上部署后,将B重新连接到ELB。

问题随着Couchbase服务器中的缓存而增加。 虽然B具有在旧代码上运行的挂起请求,但A全都设置为处理在新代码上运行的新请求。 缓存服务器在步骤5之后不包含缓存的数据。 但在步骤6中,B会根据旧代码将数据加载到缓存中。 如果A使用该缓存,该应用将在A上突破 如果在步骤6中,A将数据加载到缓存中,B使用该缓存的数据,则应用程序将再次在B上破解。 如何解决A和B同时服务请求的关键部分问题? 部署策略的任何变化也是受欢迎的。

I am using Couchbase cache. There is one couchbase server. I have multiple servers to host the app and follow a slight modification of the blue green deployment strategy to deploy app on all the servers. Deployment strategy - Consider first 50% servers as A and rest as B. 1. Detach A from ELB, B is still serving the requests. 2. Deploy app on A. 3. Reconnect A to ELB. 4. Detach B from ELB but B has some requests to process. 5. Invalidate cache. 6. New requests go to A while B completes requests that it had pending. 7. Post completing pending requests, start deployment on B. 8. Post deployment on B, reconnect B to ELB.

The problem rises with the cache in the Couchbase server. While B has pending requests that run on old code, A is all set to process new requests running on new code. The cache server contains no cached data after step 5. But in step 6, B will load data into cache according to old code. If A uses that cache, the app will break on A. If in step 6, A loads data into cache and B uses that cached data, the app will again break on B. How can I solve this crucial section problem where both A and B are serving requests simultaneously? Any change in deployment strategy is also welcome.

最满意答案

将缓存标签添加到缓存键(又名版本)可能是最常见的解决方案。 发布标签区分不同版本的API缓存的数据。 但是应该考虑到内存需求,因为内存使用量将翻倍。 另外,请记住删除旧版API的缓存,如果它们没有更多的接收请求。

Adding a release tag to the cache key (aka versioning) is probably the most common solution. The release tag differentiates between data cached by different versions of the API. But one should keep the memory demand in mind as the memory usage will be doubled. Also, remember to delete cache for older versions of the API if they are no more receiving requests.

更多推荐

本文发布于:2023-08-04 16:40:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1417878.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:缓存   多个   服务器   Invalidating   refreshing

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!