Cache is a component that stores data to serve future requests faster. It provides performance benefits by storing frequently accessed data in memory for quick retrieval. There are different types of caches like CPU caches, browser caches, and database caches. Caching login information can improve performance by retrieving user profiles from cache instead of querying the database on every request. This reduces load on the database server. However, updating cached data whenever the database changes can be challenging and require techniques like retries, batch processing, and global locks to ensure consistency.
67. Don’t Try Update After didn’t Read DB
Value
Profile
- LastLoginTime
- UserName
- Host
- Name
68. Don’t Try Update After didn’t Read DB
Value
Profile
- LastLoginTime
- UserName
- Host
- Name
EVENT: Update Only LastLoginTime
69. Don’t Try Update After didn’t Read DB
Value
Profile
- LastLoginTime
- UserName
- Host
- Name
EVENT: Update Only LastLoginTime
Read Cache: User Profile
70. Don’t Try Update After didn’t Read DB
Value
Profile
- LastLoginTime
- UserName
- Host
- Name
EVENT: Update Only LastLoginTime
Read Cache: User Profile
Update Data & DB
Just Save Cache
71. Don’t Try Update After didn’t Read DB
Value
Profile
- LastLoginTime
- UserName
- Host
- Name
EVENT: Update Only LastLoginTime
Read Cache: User Profile
Update Data & DB
Just Save Cache
It Makes Race Condition
108. Memcached In Facebook
• Facebook and Google and Many Companies
• Facebook
– 하루 Login 5억명(한달에 8억명)(최신, 밑에는 작년 2010/04자료)
– 활성 사용자 7,000만
– 사용자 증가 비율 4일에 100만명
– Web 서버 10,000 대, Web Request 초당 2000만번
– Memcached 서버 805대 -> 15TB, HitRate: 95%
– Mysq server 1,800 대 Master/Slave(각각, 900대)
• Mem: 25TB, SQL Query 초당 50만번