Memcached:自动发现python对AWS Elasticache的支持? [英] Memcached: auto-discovery python support on AWS Elasticache?

查看:102
本文介绍了Memcached:自动发现python对AWS Elasticache的支持?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始使用AWS Elasticache与我的django网络应用程序。



我开始使用自动发现功能将缓存位置设置为唯一端点,但是似乎不起作用。



我使用pylibmc(1.2.2)和django-pylibmc-sasl(0.2.4)从python连接到memcached。



自动发现功能是否适用于这些客户端?如何启用?

解决方案

快速回答



django: django-elasticache



长回答



ElastiCache提供memcached界面,所以有三种使用方法:



1。 Memcached配置了位置=配置端点。



在这种情况下,您的应用程序
将随机连接到集群中的节点,缓存将使用不是最优的
路。在某一时刻,您将连接到第一个节点并设置项目。分钟后
您将连接到另一个节点,无法获取此项。

  CACHES = {
'default':{
'BACKEND':'django.core.cache.backends.memcached.PyLibMCCache',
'LOCATION':'cache.gasdbp.cfg.use1.cache.amazonaws .com:11211',
}
}



2。 Memcached配置了所有节点。



它将工作正常,memcache客户端将
在所有节点之间分离项目,并平衡客户端上的加载。您将
在添加新节点或删除旧节点后才会出现问题。在这种情况下,您应该
手动添加新节点,并且不要忘记在AWS上进行所有更改后更新您的应用程序。

  CACHES = {
'default':{
'BACKEND':'django.core.cache.backends.memcached.PyLibMCCache',
'LOCATION':[
'cache .gqasdbp.0001.use1.cache.amazonaws.com:11211',
'cache.gqasdbp.0002.use1.cache.amazonaws.com:11211',
]
}
}



3。使用django-elasticache。



它将连接到集群并检索所有节点的IP地址
,并配置memcached以使用所有节点。

  CACHES = {
'default':{
'BACKEND':'django_elasticache.memcached.ElastiCache',
'LOCATION':'cache-c.draaaf.cfg.use1.cache.amazonaws.com:11211',
}
}

设置与节点列表(django-elasticache)和
之间的区别只有一个配置端点(使用dns路由),您可以在
上看到此图:




I started to use AWS Elasticache with my django web app.

I started by setting the cache location to the unique endpoint using the auto-discovery feature, but it doesn't seems to work.

I'm using pylibmc (1.2.2) and django-pylibmc-sasl (0.2.4) to connect to memcached from python.

Does the auto-discovery feature work on these clients? How can I enable it?

解决方案

Quick answer

Yes for django: django-elasticache

Long Answer

ElastiCache provides memcached interface so there are three solution of using it:

1. Memcached configured with location = Configuration Endpoint.

In this case your application will randomly connect to nodes in cluster and cache will be used with not optimal way. At some moment you will be connected to first node and set item. Minute later you will be connected to another node and will not able to get this item.

CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache',
        'LOCATION': 'cache.gasdbp.cfg.use1.cache.amazonaws.com:11211',
    }
}

2. Memcached configured with all nodes.

It will work fine, memcache client will separate items between all nodes and will balance loading on client side. You will have problems only after adding new nodes or delete old nodes. In this case you should add new nodes manually and don't forget update your app after all changes on AWS.

CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache',
        'LOCATION': [
            'cache.gqasdbp.0001.use1.cache.amazonaws.com:11211',
            'cache.gqasdbp.0002.use1.cache.amazonaws.com:11211',
        ]
    }
}

3. Use django-elasticache.

It will connect to cluster and retrieve ip addresses of all nodes and configure memcached to use all nodes.

CACHES = {
    'default': {
        'BACKEND': 'django_elasticache.memcached.ElastiCache',
        'LOCATION': 'cache-c.draaaf.cfg.use1.cache.amazonaws.com:11211',
    }
}

Difference between setup with nodes list (django-elasticache) and connection to only one configuration Endpoint (using dns routing) you can see on this graph:

这篇关于Memcached:自动发现python对AWS Elasticache的支持?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆