high availability system cache and queue - write behind

22
High-Availability: cache and queue 2014-07-24 Truc Le - [email protected]

Upload: le-kien-truc

Post on 12-Jul-2015

209 views

Category:

Software


0 download

TRANSCRIPT

Page 1: High availability system cache and queue - Write behind

High-Availability: cache and queue

2014-07-24Truc Le - [email protected]

Page 2: High availability system cache and queue - Write behind

Executive Summary

• The objective of this presentation is fundamental web development method using the cache.

• Optimization code to reduce resource cost and make website faster.

• Amazon Web Services for Cache and Queue

2014-07-24 High-Availability: cache and queue

Page 3: High availability system cache and queue - Write behind

Outline• Cache

• Simple example & Benchmark

• Queue & Write behind

• Simple worker demo

• Amazon Web Services for Cache and Queue

• Scalability

2014-07-24 High-Availability: cache and queue

Page 4: High availability system cache and queue - Write behind

Caching

• Cache can help reduce database loads.

• Instead of going to the database, data can be loaded from in-memory cache

• Times faster than database.

2014-07-24 High-Availability: cache and queue

Page 5: High availability system cache and queue - Write behind

Simple implementation

2014-07-24 High-Availability: cache and queue

No cache

Page 6: High availability system cache and queue - Write behind

2014-07-24 High-Availability: cache and queue

Get cache

Page 7: High availability system cache and queue - Write behind

2014-07-24 High-Availability: cache and queue

Use & Set cache

Expired time 60 secondsSerialize and & Unserialize for object storage

Page 8: High availability system cache and queue - Write behind

Benchmark method

Tool : siegeAPI URL : 20

Deployment on AWSEC2 (ubuntu) : t2.microRDS (mysql) : db.t1.microElasticCache (redis) : cache.t1.micro

2014-07-24 High-Availability: cache and queue

Page 9: High availability system cache and queue - Write behind

Result

Concurrent User: 50 - Delay: 10 - Repeat: 2

Cache vs (No cache)Elapsed time : 20.13 secs ( 27.97)Response time : 0.93 secs ( 4.23 )Transaction rate : 4.97 trans/sec ( 3.58 )

2014-07-24 High-Availability: cache and queue

Page 10: High availability system cache and queue - Write behind

Result

Concurrent User: 100 - Delay: 10 - Repeat: 2

Cache vs (No cache)Elapsed time : 30.97 secs ( 27.10) ???Response time : 5 secs ( 3.84 ) ???Transaction rate : 6.46 trans/sec ( 7.38 ) ???

2014-07-24 High-Availability: cache and queue

Page 11: High availability system cache and queue - Write behind

Log details

2014-07-24 High-Availability: cache and queue

96 empty responses

Page 12: High availability system cache and queue - Write behind

Conclusion

- Too many connections (>32)- To increase max connections need larger RDSCache helps:● Save money● More concurrent user● Faster delivery

2014-07-24 High-Availability: cache and queue

Page 13: High availability system cache and queue - Write behind

What could be cached?

• Database query• Variable & Object• View page & Template• API

2014-07-24 High-Availability: cache and queue

Page 14: High availability system cache and queue - Write behind

Redis is more than cache

• It's a "NoSQL" key-value data stores• It's a data structures server

Applications: Counting stuff, Pub/Sub, Queues, Real time analysis, Leaderboards and related problems ...

2014-07-24 High-Availability: cache and queue

Page 15: High availability system cache and queue - Write behind

Queue & Write-Behind● Offload database writes● Spread writes out to flatten peaks● Consolidate multiple writes into fewer database writes● Being disconnected from the DB will let the frontend keep

running if the DB is down!

2014-07-24 High-Availability: cache and queue

Page 16: High availability system cache and queue - Write behind

2014-07-24 High-Availability: cache and queue

Architecture

Page 17: High availability system cache and queue - Write behind

2014-07-24 High-Availability: cache and queue

Compare with traditional

Page 18: High availability system cache and queue - Write behind

Running demo queue

2014-07-24 High-Availability: cache and queue

Page 19: High availability system cache and queue - Write behind

Amazon ElasticCache

• Saves administrative cost

• Provides replication features for the Redis engine

• Automatically detects and replaces failed nodes

• Availability Zone redundancy

2014-07-24 High-Availability: cache and queue

Page 20: High availability system cache and queue - Write behind

2014-07-24 High-Availability: cache and queue

Page 21: High availability system cache and queue - Write behind

Amazon Simple Queue Service

• Runs within Amazon’s high-availability data centers

• All messages are stored redundantly across multiple servers and data centers

• Unlimited number of services to read and write

• Unlimited number of messages at any time

• Inexpensive

2014-07-24 High-Availability: cache and queue

Page 22: High availability system cache and queue - Write behind

Scalability

2014-07-24 High-Availability: cache and queue