弹性beanstalk / Django Cache间歇性地显示错误的值

时间:2015-10-21 21:32:27

标签: django amazon-web-services elastic-beanstalk

我有一个部署到Elastic Beanstalk的站点 - 我已经将一些数据写入Django内存缓存,并且在检索它时我得到两个不同的值。

在我看来,有多个实例,但看着我的控制面板,似乎只有一个Web实例正在运行。 我在日志消息中输出值,我看到有多个PID。

[Wed Oct 21 14:21:34.922493 2015] [:error] [pid 14335] WARNING:root:Cached: After tomorrow, Back to the Future will take place entirely in the past.
[Wed Oct 21 14:21:35.133714 2015] [:error] [pid 14337] WARNING:root:Cached: Bacon and eggs is a day's work for a chicken and a lifetime achievement for a pig.
[Wed Oct 21 14:21:35.319643 2015] [:error] [pid 14337] WARNING:root:Cached: Bacon and eggs is a day's work for a chicken and a lifetime achievement for a pig.
[Wed Oct 21 14:21:35.521985 2015] [:error] [pid 14335] WARNING:root:Cached: After tomorrow, Back to the Future will take place entirely in the past.
[Wed Oct 21 14:21:35.690560 2015] [:error] [pid 14336] WARNING:root:Cached: Bacon and eggs is a day's work for a chicken and a lifetime achievement for a pig.

似乎在两个值/ pids之间随机切换。

我确定只有一个Web节点在运行 - 是否有某种方式在单个节点上运行多个应用程序实例?

1 个答案:

答案 0 :(得分:1)

您有一个带有单个Web服务器的EC2实例(默认情况下为Apache)。但是,Apache将创建多个工作进程,每个进程将运行Django应用程序的单独实例。当您向服务器发出请求时,其中一个工作进程可能会回答它,这就是您可以任意查看这两个值的原因。

如果您需要在整个应用程序中使用单个缓存,那么您最好在本地(对于单个EC2节点)或使用Amazon的ElastiCache服务运行Memcached或Redis。

相关问题