17. many client libraries
• might be TOO many
• the hit list...
• Java ==> spymemcached
• C ==> libmemcached
• Python, Ruby, etc ==>
• libmemcached wrappers
61. answer 1
• right on your web servers
• a great place to start, if you have extra
memory
62. servers
web app web app web app web app
memcached memcached memcached, memcached
RDBMS
63. add up your memory
usage!
• having memcached server swap == bad!
64. answer 2
• run memcached right on your database
server?
• WRONG!
65. answer 3
• run memcached on separate dedicated
memcached servers
• congratulations!
• you either have enough money
• or enough traffic that it matters
93. solution
• save sessions to memcached
• the first time, also save to RDBMS
• ideally, asynchronously
• on cache miss, restore from RDBMS
94. solution
• save sessions to memcached
• the first time, also save to RDBMS
• ideally, asynchronously
• on cache miss, restore from RDBMS
95. in the background...
• have a job querying the RDBMS
• cron job?
• the job queries for “old” looking session
records in the sessions table
• refresh old session records from
memcached
108. multigets
• they are your friend
• memcached is fast, but...
• imagine 1ms for a get request
• 200 serial gets ==> 200ms
109. a resultset loop
foreach product in resultset
c = memcached.get(product.category_id)
do something with c
110. 2 loops
for product in resultset
multiget_request.append(product.category_id)
multiget_response = memcachedClient.multiget(
multiget_request)
for c in multiget_response
do something with c