简体   繁体   English

如何在每个都有多个vCPU的多个Google App Engine实例之间共享缓存?

[英]How to share cache between multiple Google App Engine instances which each have multiple vCPUs?

SITUATION: 情况:

I am trying to implement caching for rate-limited third-party API requests my website needs to make. 我正在尝试为我的网站需要进行的限速第三方API请求实施缓存。

Apparently, basic solutions such as: 显然,基本解决方案包括:

https://www.npmjs.com/package/node-cache https://www.npmjs.com/package/node-cache

won't even share cache between CPUs, much less between instances ? 甚至不共享CPU之间的缓存,更不用说实例之间的共享了?

Is that correct ? 那是对的吗 ?

And if it is, how can I share cache between instances so that I have one unified cache for my website across instances ? 如果是的话,如何在实例之间共享缓存,以便在实例之间为我的网站提供一个统一的缓存?

After googling for a while, it seems Redis would be a solution. 经过一段时间的搜寻后,Redis似乎是一个解决方案。 But from what I gathered, I would have to host Redis on it's own dedicated instance for the cache to be unique across my website VM instances ? 但是从我收集的数据来看,我将不得不在它自己的专用实例上托管Redis,以使缓存在我的网站VM实例中是唯一的?

What if the instance hosting Redis is overloaded and also needs to be auto-scaled to multiple instances ? 如果托管Redis的实例过载并且还需要自动缩放到多个实例怎么办?


QUESTION: 题:

How can I implement shared cache between VM instances of my website ? 如何在网站的VM实例之间实现共享缓存?

You could add to your GAE application a 1st generation standard environment service which would: 您可以将第一代标准环境服务添加到您的GAE应用程序中,该服务将:

  • act as a caching service for your node.js (or other 2nd generation standard environment or flexible environment) service(s) and, under the hood, use itself the GAE memcache service , only available in those 1st gen standard environments. 充当您的node.js(或其他第二代标准环境或灵活环境)服务的缓存服务,并且在后台使用自己的GAE内存缓存服务 ,仅在那些第一代标准环境中可用。
  • maybe even make itself those rate-limited 3rd party API calls, it will probably be simpler to properly coordinate the cached results that way 甚至可以进行速率受限的第三方API调用,以这种方式正确协调缓存的结果可能会更简单
  • be configured for auto scaling to address the scalability concern 配置为自动缩放以解决可扩展性问题

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

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