当 App Engine (Java) 启动新实例时,如何确保任务队列 Memcache cron 在它们之间共享?
这是一个问题,我的应用程序在站点上偶尔会遇到 CPU 限制峰值,其中几乎所有工作都是由于 cron 任务而完成的,该任务每小时频繁运行以调用重新填充内存缓存的任务队列。
最近,该网站的流量激增,导致多个实例启动。
然而,令我惊讶的是,尽管只有不到 1% 的 CPU 使用率与流量峰值有关,但那几天我还是不得不降低 Memcache 任务的频率。 (此应用程序中完成的 99% 的工作是 (a) 在内存缓存任务队列中和 (b) 在客户端 JavaScript/JSON 逻辑中)。
我想知道的是,启动的其他实例是否都需要自己的 Memcache 任务队列,也许这就是为什么我看到与那些天重新填充 Memcache 的任务队列相关的 CPU 使用率要高得多的原因 - 任务实际上是为每个实例单独执行的?
如果是这样,我如何确保任务队列及其填充的 Memcache 在实例之间共享(如果可能的话)?
This is a problem where my app experiences occasional CPU limit peaks on a site in which almost all of the work is done as a result of a cron task which runs frequently every hour to call a task queue which repopulates the memcache.
Recently the site received a large spike in traffic resulting in multiple instances being spun up.
However, to my surprise, I had to reduce the frequency of the Memcache task during those days even though less than 1% of the CPU usage was related to the traffic spike. (99% of the work done in this app is (a) in the memcache task queue and (b) in client-side JavaScript/JSON logic).
What I'm wondering is whether the additional instances that were spun up all require their own Memcache task queues and perhaps this is why I saw a much higher CPU usage related to the task queue that repopulates the memcache during those days - the task was actually being executed separately for each of the instances?
If so, how can I ensure that the task queue - and the Memcache that it populates - is shared across the instances - if this is possible at all?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
任务队列和memcache都是全局的。您可能以某种取决于实例数量的方式将任务排入队列,因此您启动了比应有的任务更多的任务 - 如果没有看到您的代码,就不可能说这一点。
The task queue and memcache are both global. It's likely that you were enqueueing the task in some fashion that depended on the number of instances, so you were starting more tasks than you should've - it's impossible to say without seeing your code.