SlideShare uma empresa Scribd logo
1 de 29
Baixar para ler offline
Amazon ElastiCache
Andy Dai andy@dorm7.com
2013/10/9
13年10月9⽇日星期三
What is Cache?
IF x is in the cache:
return x
ELSE
generate x
save x to cache
return x
13年10月9⽇日星期三
Cache in Web
given a URL, try finding that page in the
cache
if the page is in the cache:
return the cached page
else:
generate the page
save the generated page in the cache
return the generated page
13年10月9⽇日星期三
memcached
13年10月9⽇日星期三
memcached
• Memcached is an in-memory key-
value store for small chunks of
arbitrary data
13年10月9⽇日星期三
memcached
• Memcached is an in-memory key-
value store for small chunks of
arbitrary data
• 其實沒啥好講的...
13年10月9⽇日星期三
redis
13年10月9⽇日星期三
redis
•Redis is an open source, BSD licensed,
advanced key-value store. It is
often referred to as a data
structure server
13年10月9⽇日星期三
redis
•Redis is an open source, BSD licensed,
advanced key-value store. It is
often referred to as a data
structure server
•什麼是 data structure server?
13年10月9⽇日星期三
基本款
• SET key value
• GET key
• INCR key
• EXPIRE key time
• TTL key
13年10月9⽇日星期三
LIST
• LPUSH/RPUSH key element
• LPOP/RPOP key
• LRANGE key start stop
13年10月9⽇日星期三
SET
• SADD key element
• SREM key element
• SISMEMBER key element
• SMEMBERS key
• SUNION key1 key2
• SINTER key1 key2
13年10月9⽇日星期三
SORTED SET
• ZADD key score value
• ZRANGE key start stop
13年10月9⽇日星期三
PUB/SUB
• SUBSCRIBE key
• PUBLISH key value
13年10月9⽇日星期三
redis 太超過了!
13年10月9⽇日星期三
One More Thing...
13年10月9⽇日星期三
redis Persistence
• RDB - snapshot
• AOF - logs every write operation
• 參考 http://redis.io/topics/persistence
13年10月9⽇日星期三
Scaling - Memcached
• Cluster
• Node
NODE2
NODE1
CLUSTER1
AZ1
NODE2
NODE1
CLUSTER2
AZ2
13年10月9⽇日星期三
Scaling - redis
• Read Replication Across AZ
MASTER
CLUSTER1
AZ1
SLAVE
CLUSTER1
AZ2
13年10月9⽇日星期三
AWS 幫你...
• Deploy
• Manage
• Elastic
• Secure
13年10月9⽇日星期三
DEMO 一下
13年10月9⽇日星期三
PRICING
• http://aws.amazon.com/elasticache/pricing/
• 其實不算超貴...
13年10月9⽇日星期三
結論
13年10月9⽇日星期三
結論
• 調整你的程式之前先想想看 Cache
13年10月9⽇日星期三
結論
• 調整你的程式之前先想想看 Cache
• 調整你的 DataBase 之前先想想看 Cache
13年10月9⽇日星期三
結論
• 調整你的程式之前先想想看 Cache
• 調整你的 DataBase 之前先想想看 Cache
• 換掉你的 DataBase 之前先想想看 Cache
13年10月9⽇日星期三
結論
• 調整你的程式之前先想想看 Cache
• 調整你的 DataBase 之前先想想看 Cache
• 換掉你的 DataBase 之前先想想看 Cache
• redis 這麼棒有機會就用一下吧
13年10月9⽇日星期三
如果上了 Memory
Cache 還是不夠力...
13年10月9⽇日星期三
USEVarnish
• http://blog.disqus.com/post/62187806135/
scaling-django-to-8-billion-page-views
• 45k req/s -> 15k req/s
13年10月9⽇日星期三

Mais conteúdo relacionado

Mais de Andy Dai

Grpc + python.key
Grpc + python.keyGrpc + python.key
Grpc + python.keyAndy Dai
 
該怎麼樣(認真的)部署你的 Python Web 應用程式?
該怎麼樣(認真的)部署你的 Python Web 應用程式?該怎麼樣(認真的)部署你的 Python Web 應用程式?
該怎麼樣(認真的)部署你的 Python Web 應用程式?Andy Dai
 
Power UP your CLI
Power UP your CLIPower UP your CLI
Power UP your CLIAndy Dai
 
Search search search
Search search searchSearch search search
Search search searchAndy Dai
 
Django channels
Django channelsDjango channels
Django channelsAndy Dai
 
Django Third party packages
Django Third party packagesDjango Third party packages
Django Third party packagesAndy Dai
 
Practical django secuirty
Practical django secuirtyPractical django secuirty
Practical django secuirtyAndy Dai
 
總之來講講 Search
總之來講講 Search總之來講講 Search
總之來講講 SearchAndy Dai
 
Python web meetup 11 18
Python web meetup 11 18Python web meetup 11 18
Python web meetup 11 18Andy Dai
 
Django in heavy load environment
Django in heavy load environmentDjango in heavy load environment
Django in heavy load environmentAndy Dai
 
電腦不只會幫你選土豆,還會幫你選新聞
電腦不只會幫你選土豆,還會幫你選新聞電腦不只會幫你選土豆,還會幫你選新聞
電腦不只會幫你選土豆,還會幫你選新聞Andy Dai
 
用 Python 打造你自己的 summly
用 Python 打造你自己的 summly用 Python 打造你自己的 summly
用 Python 打造你自己的 summlyAndy Dai
 
Tradeoffs of replacing core components
Tradeoffs of replacing core componentsTradeoffs of replacing core components
Tradeoffs of replacing core componentsAndy Dai
 
Django deploy
Django deployDjango deploy
Django deployAndy Dai
 
Build your own trello witihin 100 LOC (with Meteor)
Build your own trello witihin 100 LOC (with Meteor)Build your own trello witihin 100 LOC (with Meteor)
Build your own trello witihin 100 LOC (with Meteor)Andy Dai
 
Boost your django admin with Grappelli
Boost your django admin with GrappelliBoost your django admin with Grappelli
Boost your django admin with GrappelliAndy Dai
 

Mais de Andy Dai (17)

Grpc + python.key
Grpc + python.keyGrpc + python.key
Grpc + python.key
 
該怎麼樣(認真的)部署你的 Python Web 應用程式?
該怎麼樣(認真的)部署你的 Python Web 應用程式?該怎麼樣(認真的)部署你的 Python Web 應用程式?
該怎麼樣(認真的)部署你的 Python Web 應用程式?
 
Power UP your CLI
Power UP your CLIPower UP your CLI
Power UP your CLI
 
Search search search
Search search searchSearch search search
Search search search
 
Django channels
Django channelsDjango channels
Django channels
 
Django Third party packages
Django Third party packagesDjango Third party packages
Django Third party packages
 
Practical django secuirty
Practical django secuirtyPractical django secuirty
Practical django secuirty
 
總之來講講 Search
總之來講講 Search總之來講講 Search
總之來講講 Search
 
Python web meetup 11 18
Python web meetup 11 18Python web meetup 11 18
Python web meetup 11 18
 
Django in heavy load environment
Django in heavy load environmentDjango in heavy load environment
Django in heavy load environment
 
電腦不只會幫你選土豆,還會幫你選新聞
電腦不只會幫你選土豆,還會幫你選新聞電腦不只會幫你選土豆,還會幫你選新聞
電腦不只會幫你選土豆,還會幫你選新聞
 
用 Python 打造你自己的 summly
用 Python 打造你自己的 summly用 Python 打造你自己的 summly
用 Python 打造你自己的 summly
 
Tradeoffs of replacing core components
Tradeoffs of replacing core componentsTradeoffs of replacing core components
Tradeoffs of replacing core components
 
Dynamo db
Dynamo dbDynamo db
Dynamo db
 
Django deploy
Django deployDjango deploy
Django deploy
 
Build your own trello witihin 100 LOC (with Meteor)
Build your own trello witihin 100 LOC (with Meteor)Build your own trello witihin 100 LOC (with Meteor)
Build your own trello witihin 100 LOC (with Meteor)
 
Boost your django admin with Grappelli
Boost your django admin with GrappelliBoost your django admin with Grappelli
Boost your django admin with Grappelli
 

ElastiCache