-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
547c270
commit e69f287
Showing
5 changed files
with
209 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Memcached\n", | ||
"\n", | ||
"## Mission statement\n", | ||
"* Memcached is a free and open-source in-memory key-value store.\n", | ||
"* It was originally developed by and for the LiveJournal website, back in the day.\n", | ||
"* It's almost a database, but not quite one. It differs in that it's not persistant. Memcached is allotted a certain amount of memory, and when that memory limit reached, to insert new values memcached starts deleting old values.\n", | ||
"* This deletion occurs using the simple \"Least Recently Used\", or **LRU**, **caching strategy** (in this context this is referred to as the **eviction mode**).\n", | ||
"* When you insert data into memcached that you want to access later, you cannot assume that it will still be there.\n", | ||
"* The tradeoff is that memcached is ridiculously fast, and has a simple, easy-to-understand architecture.\n", | ||
"* Memcached is thus meant to be used as a **caching layer**. Put it in front of your production database to speed up your queries!\n", | ||
"\n", | ||
"## Data model\n", | ||
"* Memcached uses a simple hash map log structured storage architecture (this is the simplest practical database architecture; see Chapter 3 notes for more).\n", | ||
"* Memcached supports clusters containing multiple nodes. A hash is computed on the data being inserted in order to determine which node the data gets sent to. Then the data is hashed again for storage.\n", | ||
"* This is a **shared nothing architecture**. The client knows the locations of the nodes, obviously, but the nodes know nothing about each other, and do not share any resources.\n", | ||
"* Memcached is an **in-memory data store**. The nodes are meant to be volatile memory resources.\n", | ||
"* There is no type support. A **word** in memcached is a byte.\n", | ||
"* As mentioned in the previous section, a least recently used caching strategy is used to purge old data when the service reaches its size limit.\n", | ||
"\n", | ||
"## Security\n", | ||
"* memcache emphasized brutal simplicity and efficiency. But in the case of security that simplicity apparently makes it emminently hackable.\n", | ||
"* Memcache uses a flat security model, with privileges applying to lots of things all at once. For example, if you have write access, you have all the write access; same with reads.\n", | ||
"* When deployed on an unsecured network, it's very easy for external actors to get to, inspect, and even modify a memcached service.\n", | ||
"* memcache over UDP is a particular problem. This feature was disabled by default eventually, but for a while you could access cache data for a lot of public websites apparently!\n", | ||
"* Since memcache has such lousy security you should implement your own security layer." | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.6.4" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Redis\n", | ||
"\n", | ||
"## Mission statement\n", | ||
"* Redis is a free and open source in-memory key-value store.\n", | ||
"* It is like a more advanced version of memcached, the subject of the previous section.\n", | ||
"* Redis stands for \"REmote DIctionary Server\".\n", | ||
"* It was originated by a guy at VMWare, and has since spun off twice to a dedicated maintainer in Redis Labs.\n", | ||
"* Like memcache it is designed to be blazing fast, and most often used as a cache layer.\n", | ||
"* Persistence to disc is configurable via either writing to a log or by dumping to disc (snapshotting) at regular intervals.\n", | ||
"* Thus Redis is great for blazing-fast, *mostly* consistent storage.\n", | ||
"* You can use it as a cache by disabling the persistance layer entirely (gotta go fast).\n", | ||
"\n", | ||
"## Data model\n", | ||
"* The Redis data model is very similar to the memcached one.\n", | ||
"* cluster config?\n", | ||
"* A word in Redis is a string. Interesting choice. Redis supports a variety of structures involving strings: hashes, lists, sets, sorted sets, bitmaps, hyperloglogs, and geospatials (via geohashes).\n", | ||
"\n", | ||
"\n", | ||
"* The cluster is managed as a sequence of masters and slaves.\n", | ||
"* When the network is fully operational, masters asynchronously send key-store modification traffic to the slaves, which replicate the data locally themselves.\n", | ||
"* If a network partition occurs (a timeout or something else), in order to heal, the slaves will ask the master for first a \"partial synchronization\", where all of the missed updates are batched in one send, and then if that is not possible (due to a high volume of updates not recieved) request a \"full synchronization\", which requires a much slower backup-and-push on the past of the master.\n", | ||
"* This synchronization configuration has high performance, but also high latency, fitting the Redis philosophy perfectly.\n", | ||
"* You can optionally request synchronous replication to a specific number of nodes. However in the case of a failover, in some cases it's still possible to lose that update. Redis is not for persistance!\n", | ||
"* A master can have multiple slaves.\n", | ||
"* Slaves can be connected to one another. This will traffic data replications against one another in exactly the same manner as the master-slave traffic.\n", | ||
"* Replication is non-blocking on the master side, except in the case of a failure requiring full synchronization to recover from.\n", | ||
"* It is lightly blocking on the slave side: by default slaves will serve using the old copy of the dataset, but there is a brief period when the slave must switch to the new dataset version (delete old data, insert new data) where it blocks.\n", | ||
"* Why replicate at all? Reliability, for one thing, but additionally because slaves can be used to farm off long-running requests.\n", | ||
"* Since slaves are full dataset replicas, this architecture is obviously insufficient for large data volumes, as it results in a lot of duplicate data!\n", | ||
"* High-availability and automatic clustering are available via a few different feature staple-ons." | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.6.4" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |