Simple Cache Architecture
charsyam@naver.com
What is Cache?
Cache == Speed
Disk Accessing
is too late
Operation Time
is too long
Client
Business
Object
Memory
Disk
ClientClientClient
Client
Business
Object
Distributed
Cache
DB
ClientClientClient
Connect via
Business Object
Don’t Connect
Client between
DB directly
Distributed
Cache
Consistent Hashing
Proxy
Server
Server
Server
Server
Server
User Request
K = 10000 N = 5
Origin
Proxy
Server
Server
Server
Server
Server
User Request
K = 10000 N = 4
FAIL : Redistribution about 2000 Users
Proxy
Server
Server
Server
Server
Server
User Request
K = 10000 N = 5
RECOVER: Redistribution about 2500 Users
A
Add A,B,C Server
A
B
Add A,B,C Server
A
B
C
Add A,B,C Server
A
B
C
1
Add Item 1
A
B
C
1
2
Add Item 2
A
B
C
1
2
3
4
5
Add Item 3,4,5
A
B
C
2
3
4
5
Fail!! B Server
A
B
C
1
2
3
4
5
Add Item 1 Again -> Allocated C Server
A
B
C
1
2
3
4
5
1
Recover B Server -> Add Item 1
A
B
C
Real Implementation
A+1
A+2
A+3B+1
B+2
C+1
C+2
A+4
C+3
B+3
Mistake
A
DB Cache
B
Normal Step
1. A:DB:W 2. A:Cache:W3. B:DB:W
4. B:Cache:W
A
DB Cache
B
Race Condition Step
1. A:DB:W 3. B:Cache:W2. B:DB:W
4. A:Cache:W
Solution?
Global Lock?
CAS?
Thank You!
Upcoming SlideShare
Loading in …5
×

Simple cache architecture

893 views

Published on

Published in: Technology
5 Comments
4 Likes
Statistics
Notes
No Downloads
Views
Total views
893
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
14
Comments
5
Likes
4
Embeds 0
No embeds

No notes for slide

Simple cache architecture

  1. 1. Simple Cache Architecture charsyam@naver.com
  2. 2. What is Cache?
  3. 3. Cache == Speed
  4. 4. Disk Accessing is too late
  5. 5. Operation Time is too long
  6. 6. Client Business Object Memory Disk ClientClientClient
  7. 7. Client Business Object Distributed Cache DB ClientClientClient
  8. 8. Connect via Business Object
  9. 9. Don’t Connect Client between DB directly
  10. 10. Distributed Cache
  11. 11. Consistent Hashing
  12. 12. Proxy Server Server Server Server Server User Request K = 10000 N = 5 Origin
  13. 13. Proxy Server Server Server Server Server User Request K = 10000 N = 4 FAIL : Redistribution about 2000 Users
  14. 14. Proxy Server Server Server Server Server User Request K = 10000 N = 5 RECOVER: Redistribution about 2500 Users
  15. 15. A Add A,B,C Server
  16. 16. A B Add A,B,C Server
  17. 17. A B C Add A,B,C Server
  18. 18. A B C 1 Add Item 1
  19. 19. A B C 1 2 Add Item 2
  20. 20. A B C 1 2 3 4 5 Add Item 3,4,5
  21. 21. A B C 2 3 4 5 Fail!! B Server
  22. 22. A B C 1 2 3 4 5 Add Item 1 Again -> Allocated C Server
  23. 23. A B C 1 2 3 4 5 1 Recover B Server -> Add Item 1
  24. 24. A B C Real Implementation A+1 A+2 A+3B+1 B+2 C+1 C+2 A+4 C+3 B+3
  25. 25. Mistake
  26. 26. A DB Cache B Normal Step 1. A:DB:W 2. A:Cache:W3. B:DB:W 4. B:Cache:W
  27. 27. A DB Cache B Race Condition Step 1. A:DB:W 3. B:Cache:W2. B:DB:W 4. A:Cache:W
  28. 28. Solution?
  29. 29. Global Lock?
  30. 30. CAS?
  31. 31. Thank You!

×