Summary of the different caching techniques in a high traffic web architecture, including pros, cons and use cases for each solution. Representative issues spotted in some of the caching approaches will be shared as well.
11. Careful!
Do Not Depend On Cache!
Common pitfalls
• Caching layers
• Deployments and cold start misses
• Server maintenance (on caching pools)
• Cache flushing for debugging
11/33
12. Choosing Your Caching System
Considerations
• Dataset & Entry size
• Should it survive restart?
Distribution VS replication
12/33
13. Choosing Your Caching System
Considerations
• Amount of different keys
• Request & Update Frequency
Validity & eviction strategies
13/33
14. Choosing Your Caching System
Considerations
• Caching Error Values
If done, how to recover quickly?
If not done, what about overload?
14/33
16. Memcached + erl-memcache
Good For
• Not reinventing the wheel
• Distributed caching
• Caching outside the node
• System Administrators
16/33
17. Memcached + erl-memcache
How does it work?
erl-memcache
• Memcached
• Pool of tcp connections
• Memcached binary protocol
• Detailed memory management
• If local, memcached can be supervised
17/33
19. Memcached + erl-memcache
Used At Spilgames For
• Minimizing disk/DB access in Spilgames Storage Platform
• https://github.com/spilgames/erl-memcache
19/33
20. erl-cache
Good For
erl-cache
• In node caching (small datasets)
• Concurrency + long lived data
• Per key caching strategies
• Error awareness
• Non intrusive memoization
20/33
21. erl-cache
How does it work?
• gen_servers with protected ETSs
• Per cache server stats
• Periodic eviction
• Auto refresh overdue entries
21/33
22. erl-cache
How does it work?
• start_cache(Cache, DefaultOpts)
• set(Cache, Key, Value, Opts)
• stop_cache(Cache)
• evict(Cache, Key)
• get(Cache, Key, Opts)
• get_stats(Cache)
?CACHE( s1 , [ { w a i t _ f o r _ r e f r e s h , f a l s e } ] ) .
o p e r a t e ( I n p u t ) −>
{ ok , Output } = extra_complex_op ( I n p u t ) ,
Output .
22/33
25. erl-cache
Used At Spilgames For
• Avoiding inline expensive calculations
• Protecting the app running the bussiness logic
• https://github.com/spilgames/erl-cache
25/33