Caching Strategies for an Erlang Based Web Stack

43 %
57 %
Information about Caching Strategies for an Erlang Based Web Stack
Technology

Published on March 7, 2014

Author: enriquepazperez

Source: slideshare.net

Description

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.

Caching in an Erlang HTTP stack Enrique Paz @quiquepaz 1/33

Introduction About Me • Software Architect • Passionate Erlang developer • Testing enthusiast • Love beautiful code! 2/33

Introduction What I won’t talk about Not Covered: • Client Side Caching • Caching Proxies • CDN Acceleration 3/33

Introduction About Spilgames 4/33

Introduction About Spilgames 5/33

Introduction About Spilgames 6/33

Why Caching? 7/33

Why Caching? For Performance • To avoid disk/DB access • To avoid calculations • To avoid resource bottlenecks 8/33

Why Caching? For Safety • To reduce backend load • To mitigate outages impact 9/33

Careful! Do Not Depend On Cache! 10/33

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

Choosing Your Caching System Considerations • Dataset & Entry size • Should it survive restart? Distribution VS replication 12/33

Choosing Your Caching System Considerations • Amount of different keys • Request & Update Frequency Validity & eviction strategies 13/33

Choosing Your Caching System Considerations • Caching Error Values If done, how to recover quickly? If not done, what about overload? 14/33

Choosing Your Caching System Two Proposals 15/33

Memcached + erl-memcache Good For • Not reinventing the wheel • Distributed caching • Caching outside the node • System Administrators 16/33

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

Memcached + erl-memcache How does it work? 18/33

Memcached + erl-memcache Used At Spilgames For • Minimizing disk/DB access in Spilgames Storage Platform • https://github.com/spilgames/erl-memcache 19/33

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

erl-cache How does it work? • gen_servers with protected ETSs • Per cache server stats • Periodic eviction • Auto refresh overdue entries 21/33

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

erl-cache Flexibility Configuration per server: • validity & eviction times • refresh_callback • wait_for_refresh • sync or async set & evict • is_error_callback • error_validity 23/33

erl-cache Flexibility 24/33

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

erl-cache Used At Spilgames For 26/33

erl-cache Used At Spilgames For 27/33

erl-cache Used At Spilgames For 28/33

Summing Up 29/33

Summing Up 30/33

Summing Up What We’ve Used • Poolboy for worker pools • Lager for logging 31/33

Summing Up What We’ve Contributed • http://github.com/spilgames/erl-memcache • http://github.com/spilgames/erl-cache • http://github.com/spilgames/erl-decorator-pt 32/33

Summing Up Questions? 33/33

Add a comment

Related presentations

Presentación que realice en el Evento Nacional de Gobierno Abierto, realizado los ...

In this presentation we will describe our experience developing with a highly dyna...

Presentation to the LITA Forum 7th November 2014 Albuquerque, NM

Un recorrido por los cambios que nos generará el wearabletech en el futuro

Um paralelo entre as novidades & mercado em Wearable Computing e Tecnologias Assis...

Microsoft finally joins the smartwatch and fitness tracker game by introducing the...

Related pages

Erlang Factory -- Caching Strategies for an Erlang Based ...

Erlang Factory -- Caching Strategies for an Erlang Based Web Stack ... Scaling Web Development: ... An Erlang-Based Elegant, ...
Read more

Erlang Factory SF Bay Area 2014

Caching Strategies for an Erlang Based Web Stack. Summary of the different caching techniques in a high traffic web architecture, including pros, cons and ...
Read more

Having the Answer Caching Strategies and Tips with H ...

Having the Answer Caching Strategies and Tips with H Hatfield ... Caching Strategies for an Erlang Based Web Stack - Duration: 35:41.
Read more

Erlang Central | Scalability & Multi-core

... the Scalability & Multi-core ... Caching Strategies for an Erlang Based Web Stack Erlang Factory — Caching Strategies for an Erlang Based Web Stack.
Read more

Erlang Factory SF Bay Area 2014

Erlang Factory is back to San ... Caching Strategies for an Erlang Based Web Stack Erlang Passionate ... Caching Strategies for an Erlang Based Web ...
Read more

TCASE Web based Instructional Strategies - Education

Share TCASE Web based Instructional Strategies. ... Effective TeachingPrinciple Web based Strategy ... Caching Strategies for an Erlang Based Web Stack
Read more

caching - How to cache over multiple nodes for scalability ...

For my web apps I've been writing my own data caching layer; ... How to cache over multiple nodes for scalability.
Read more

Web Stack | LinkedIn

View 2850 Web Stack posts, presentations, experts, and more. ... Network Engineer, Full Stack Web Developer. Greater Los Angeles Area. Defense & Space.
Read more