使用Docker-compose进行云部署中的分布式memcached(Distributed memcached in cloud deployment with Docker-compose)
我在我的开发环境中使用docker-compose。 我有一个简单的Web应用程序,它使用一个SQL数据库和一个memcached容器。
现在,如果有一天我想要投入生产,我应该怎么做才能让我的memcached实例真正分布?
如果我简单地扩展我的Docker-compose中指定的所有服务,我将最终拥有独立的memcached节点,而不是真正的集群。 我是否应该重新编写Docker-compose for prod env,以便我的每个服务都在它自己的Docker-compose yml文件中? 那么使用Docker-compose有什么好处? 我可以将每个服务部署为单独的Docker容器,并将其扩展到所需的数量。
在云部署中使用Docker-compose以及如何实现分布式集群设置的最佳实践是什么?
I am using docker-compose in my dev environment. I have a simple web application, which is using a sql database and a memcached container.
Now, if one day I would like to go to production, what should I do in order to have my memcached instance truly distributed?
If I simply scale up all the services specified in my Docker-compose, I will end up having independent memcached nodes, not really a cluster. Should I re-write my Docker-compose for prod env, so that I have each of my services in its own Docker-compose yml file? What are the benefits of using Docker-compose then? I just could deploy each service as individual Docker container scaled up to desired amount.
What are the best practices of using Docker-compose in cloud deployment and how to achieve distributed cluster setup?
原文:https://stackoverflow.com/questions/48420270
最满意答案
如果对
np.genfromtxt
使用names=True
选项,它将在.csv
的第一行中读取列名。例如:
import matplotlib.pyplot as plt import numpy as np # Make dummy csv file for this example from io import StringIO result_csv = StringIO(u""" xstuff, data1, data2, data3 0, 1, 2, 3 1, 1, 3, 4 2, 2, 1, 3 3, 1, 2, 5 """) # Read in csv. Use names=True to also store column headers per_data=np.genfromtxt(result_csv,delimiter=',',names=True) # Loop over columns. Here I assume you have the x-data in the first column, so skip that one for name in per_data.dtype.names[1:]: # Set the line's label to the column name plt.plot(per_data['xstuff'],per_data[name],label=name) # Add a legend plt.legend(loc=0) plt.xlabel ('x stuff') plt.ylabel ('y stuff') plt.title('my test result') plt.grid() plt.show()
If you use the
names=True
option tonp.genfromtxt
, it will read in the first line of the.csv
as the column names.For example:
import matplotlib.pyplot as plt import numpy as np # Make dummy csv file for this example from io import StringIO result_csv = StringIO(u""" xstuff, data1, data2, data3 0, 1, 2, 3 1, 1, 3, 4 2, 2, 1, 3 3, 1, 2, 5 """) # Read in csv. Use names=True to also store column headers per_data=np.genfromtxt(result_csv,delimiter=',',names=True) # Loop over columns. Here I assume you have the x-data in the first column, so skip that one for name in per_data.dtype.names[1:]: # Set the line's label to the column name plt.plot(per_data['xstuff'],per_data[name],label=name) # Add a legend plt.legend(loc=0) plt.xlabel ('x stuff') plt.ylabel ('y stuff') plt.title('my test result') plt.grid() plt.show()
相关问答
更多-
在Matplotlib中以最简单的方式在PyPlot中添加图例(Adding a legend to PyPlot in Matplotlib in the most simple manner possible)[2023-04-25]
为每个plot()调用添加一个label= ,然后调用legend(loc='upper left') 。 考虑这个例子: import numpy as np import pylab x = np.linspace(0, 20, 1000) y1 = np.sin(x) y2 = np.cos(x) pylab.plot(x, y1, '-b', label='sine') pylab.plot(x, y2, '-r', label='cosine') pylab.legend(loc='upper ... -
如何在高图中输入null然后在折线图中忽略它?(How to input null into highcharts and then ignore it in line graph?)[2023-08-12]
您可以使用connectNulls plotOptions:{ series:{ connectNulls:true } }, http://jsfiddle.net/7nfwe8mg/ You can use connectNulls plotOptions:{ series:{ connectNulls:true } }, http://jsfiddle.net/7nfwe8mg/ ... -
在渲染线条标签时,您只需要为鼠标悬停添加一个显示和隐藏它的事件侦听器。 因此,除了显示和隐藏您的标签之外,这里看起来一切都很好,再次您应该在鼠标悬停/鼠标移动时执行此操作。 这是我最近工作的一个例子: g.append('svg:circle') .attr('cx', function(){ return x(j.timestamp._d); }) .attr('cy', function(){ return y(j.value); }) .attr('r', 4) .at ...
-
我倾向于发现,如果我在多个geom中指定单个颜色,我做错了。 以下是我绘制数据的方法: ##Subset the necessary columns dd_sub = datos[,c(20, 2,3,5)] ##Then rearrange your data frame dd = melt(dd_sub, id=c("fecha")) 剩下的只是一个简单的ggplot命令: ggplot(dd) + geom_line(aes(x=fecha, y=value, colour=variable)) + ...
-
如果对np.genfromtxt使用names=True选项,它将在.csv的第一行中读取列名。 例如: import matplotlib.pyplot as plt import numpy as np # Make dummy csv file for this example from io import StringIO result_csv = StringIO(u""" xstuff, data1, data2, data3 0, 1, 2, 3 1, 1, 3, 4 2, 2, 1, 3 ...
-
从文档 : 句柄 :Artist的序列,可选 要添加到图例中的艺术家列表(线条,补丁)。 如果您需要完全控制图例中显示的内容并且上述自动机制不足,请将其与标签一起使用。 在这种情况下,手柄和标签的长度应该相同。 如果他们不是,他们被截断到更小的长度。 plt.plot返回一个列表line2D对象,这是你需要传递给plt.legend() 。 因此一个简化的例子如下: labels = ["Line 1", "Line 2"] lines1, = plt.plot([1,2,3]) lines2, = pl ...
-
R - 如何将图例标题添加到保存到变量的levelplot?(R - How to add legend title to levelplot saved to a variable?)[2024-03-08]
这不会直接回答您的问题,但它可能会改变工作流程,您可以使用colorkey参数为密钥添加标题。 它涉及调整draw.colorkey函数。 最简单的方法是以交互方式使用fixInNamespace fixInNamespace("draw.colorkey", "lattice") 在函数结束时将最后几行更改为 } if (!is.null(key$title)) { key.gf <- placeGrob(key.gf, textGrob(key$title, hjust ... -
从csv填充折线图(Populating a line graph from csv)[2021-07-30]
*更新。 此问题已得到解决。 事实证明,有很多事情在代码中触发了错误。 两个主要的事情(从提供的代码中看不到),即使它们被全局声明,变量也没有被全局传递,并且需要重命名列变量和数据变量。 *Update. This problem is resolved. As it turns out, there were multiple things that were triggering the error in the code. Two major things were (cannot be seen f ... -
多行matplotlib文本的对齐方式由关键字参数multialignment (有关示例http://matplotlib.org/examples/pylab_examples/multiline.html,请参阅此处)。 因此,您可以将图例的标题文本居中,如下所示: l = plt.legend(['Lag ' + str(lag) for lag in all_x], loc='lower right', title='hello hello hello \n worl ...
-
d3使用csv的折线图(d3 line graph using csv)[2023-09-01]
是的,你的过滤器是错误的。 您将数据包装在另一个[] ,这意味着过滤器仅在外部阵列上运行。 改为: svg.append("path") .datum(data.filter(function(d) { return d.partner == 'team1'; })) .attr("id", "line1") .attr("d", valueline); 这里的工作示例。 Yes, your filter is wrong. You are wrapping your data in anot ...