Today start to look at Memcached.
Memcached [1][7] is a distributed in-memory key/value cache system. It is open source under the BSD license. The first version was written in Perl by Brad Fitzpatrick in May, 2003 for his website Live Journal (as one can notice, this site runs very fast). Then it was re-written in C by Anatoly Vorobey. It uses server-client architecture. Multiple servers don't talk to each other, the client hashes the key and chooses a target server to store the data. It's designed for unix/linux, but was ported to windows too. That's all about it.
Memcached homepage is at [1]. Here you can understand what it's about, and download it. There is a small wiki [6] that contains basic information about it. The current version is 1.4.20 as of July 2014.
== Install ==
1) To install from package (recommended, especially if you are deploying to multiple servers):
Ubuntu & Debian: apt-get install memcached
Redhat/Fedora: yum install memcached
FreeBSD/(Mac ?): portmaster databases/memcached
2) Although less recommended, you can install from source too:
First you will need libevent as pre-requisite:
Ubuntu: apt-get install libevent-dev
Redhat/Fedora: yum install libevent-devel
Then install memcached:
wget http://memcached.org/latest
tar -zxvf memcached-1.x.x.tar.gz
cd memcached-1.x.x
./configure [--prefix=/usr/local/memcached]
make && make test
sudo make install
== Run from console ==
memcached [-m 64] -p 11211
Here -m specifies the memory allocated, unit is MB. -p is the port used, and 11211 is the default.
-- Test --
You can test memcached using the telnet interface: telnet localhost 11211
Then these commands can be used [2][3][4]:
get [key]
set [key flag timeout size]
add [key flag timeout size]
replace [key flag timeout size]
append [key flag timeout size]
prepend [key flag timeout size]
incr [key int_value]
decr [key int_value]
delete [key]
flush_all [ |timeout]
stats [ |slabs|malloc|items|detail|sizes|reset]
version
verbosity
quit
An example console session is:
> telnet localhost 11211
Trying ::1...
Connected to localhost.
Escape character is '^]'.
version
VERSION 1.4.20
verbosity 10 # this will cause the server side echo telnet client input.
OK
stats
...
stats slabs
...
stats items
...
add mykey1 0 3600 5 # "mykey1" is the key, "0" is a 32-bit unsigne int flag, "3600" is expiration (seconds), "5" is data size.
12345 # this is the data you store at key "mykey1".
STORED
get mykey1
12345
END
quit
Connection closed by foreign host.
== Run as daemon ==
memcached -d
Or:
sudo service memcached stop
sudo service memcached start
sudo service memcached restart
Or:
sudo /etc/init.d/memcached start
sudo /etc/init.d/memcached stop
sudo /etc/init.d/memcached restart
Now if you run "top" command, you can see "memcached" in list of processes. You can run multiple versions of memcached using different ports. For more details, refer to [5] etc.
== Configuration of server, client and cluster ==
See [6].
== More things about using memcached, maintenance and development ==
See [6].
== Source code ==
The source code is available by instruction at [8] on its homepage [1]. A count of LOC on the current version is:
[./memcached/assoc.c] Lines: 293
[./memcached/assoc.h] Lines: 9
[./memcached/cache.c] Lines: 148
[./memcached/cache.h] Lines: 116
[./memcached/daemon.c] Lines: 89
[./memcached/globals.c] Lines: 25
[./memcached/hash.c] Lines: 21
[./memcached/hash.h] Lines: 14
[./memcached/items.c] Lines: 936
[./memcached/items.h] Lines: 37
[./memcached/jenkins_hash.c] Lines: 431
[./memcached/jenkins_hash.h] Lines: 15
[./memcached/memcached.c] Lines: 5646
[./memcached/memcached.h] Lines: 610
[./memcached/murmur3_hash.c] Lines: 124
[./memcached/murmur3_hash.h] Lines: 19
[./memcached/protocol_binary.h] Lines: 470
[./memcached/sasl_defs.c] Lines: 190
[./memcached/sasl_defs.h] Lines: 31
[./memcached/sizes.c] Lines: 29
[./memcached/slabs.c] Lines: 882
[./memcached/slabs.h] Lines: 49
[./memcached/solaris_priv.c] Lines: 44
[./memcached/stats.c] Lines: 375
[./memcached/stats.h] Lines: 8
[./memcached/testapp.c] Lines: 1967
[./memcached/thread.c] Lines: 854
[./memcached/timedrun.c] Lines: 102
[./memcached/trace.h] Lines: 71
[./memcached/util.c] Lines: 144
[./memcached/util.h] Lines: 33
[.] Total Lines: 13782
== Windows version ==
Memcached was designed for unix/linux. However, windows version is also available due to community support [9][10]. [11] is an example that seems no longer available. One major vendor seems to be North Scale labs, they first provide memcached for windows as a stand-alone application, then combines it into their NoSQL product MemBase, and finally combines into CouchBase [12].
References:
[1] http://memcached.org
[2] Memcached telnet command summary
[3] Memcache Telnet Interface
[4] github: memcached / doc / protocol.txt
[5] stackoverflow: stop and restart memcached server
[6] Memcached wiki
[7] Wiki: memcached
[8] Obtain memcached source
[9] memcached 1.4.4 Windows 32-bit binary now available!
[10] Memcached on Windows (x64)
[11] Installing Memcache on Windows
[12] http://www.couchbase.com/
Showing posts with label NoSQL. Show all posts
Showing posts with label NoSQL. Show all posts
Thursday, July 10, 2014
Thursday, June 26, 2014
Trying out mongoDB
Today I'm trying out mongoDB. MongoDB is an open source NoSQL document database.
Important resources:
http://www.mongodb.org - for any user to get to know it, and download
http://www.mongodb.org/downloads - download, manual (in html and pdf) is at the end of this page
http://docs.mongodb.org/ecosystem/drivers/ - mongoDB drivers for all languages
http://docs.mongodb.org/manual/reference/sql-comparison
http://www.mongodb.com - for enterprise users. Enterprise MongoDB Architecture.
Using MongoDB with ASP.NET Web API - need to install a mongoDB driver for .NET
Create a C# ASP.NET Application on Azure with MongoDB using the MongoLab Add-On
PHP manual on mongoDB - from installation to usage
Introduction to MongoDB for Java, PHP and Python Developers (May, 2012)
MongoDB partly obtain its performance from using memory mapped file. It supports easy replica for high up time. It keeps most important contents in memory and horizontally scale, shard automatically. It uses dynamic schema, and supports many programming languages and platforms. Its customers often have a cluster with over 100 nodes, some over 1000 nodes; data size ranges from TB to PB.
MongoDB installation package is self-contained and quite clean, in that it's a "green" software. The console is like MySQL or Python console in commands, and uses JavaScript as the query language. The comparable to MSSQL is: database - database, table - collection, row - document, column - field, index - index, table joins - embedded documents and linking, aggregate function - aggregation pipeline.
Installation on windows is recommended on Windows Server 2008 or above. Windows XP is not supported in MongoDB version 2.2 or above. Install as a windows service is easy. MongoVUE is a windows client, similar to PhpMyAdmin (actually, a web client instead of windows client) for MySql.
Important resources:
http://www.mongodb.org - for any user to get to know it, and download
http://www.mongodb.org/downloads - download, manual (in html and pdf) is at the end of this page
http://docs.mongodb.org/ecosystem/drivers/ - mongoDB drivers for all languages
http://docs.mongodb.org/manual/reference/sql-comparison
http://www.mongodb.com - for enterprise users. Enterprise MongoDB Architecture.
Using MongoDB with ASP.NET Web API - need to install a mongoDB driver for .NET
Create a C# ASP.NET Application on Azure with MongoDB using the MongoLab Add-On
PHP manual on mongoDB - from installation to usage
Introduction to MongoDB for Java, PHP and Python Developers (May, 2012)
MongoDB partly obtain its performance from using memory mapped file. It supports easy replica for high up time. It keeps most important contents in memory and horizontally scale, shard automatically. It uses dynamic schema, and supports many programming languages and platforms. Its customers often have a cluster with over 100 nodes, some over 1000 nodes; data size ranges from TB to PB.
MongoDB installation package is self-contained and quite clean, in that it's a "green" software. The console is like MySQL or Python console in commands, and uses JavaScript as the query language. The comparable to MSSQL is: database - database, table - collection, row - document, column - field, index - index, table joins - embedded documents and linking, aggregate function - aggregation pipeline.
Installation on windows is recommended on Windows Server 2008 or above. Windows XP is not supported in MongoDB version 2.2 or above. Install as a windows service is easy. MongoVUE is a windows client, similar to PhpMyAdmin (actually, a web client instead of windows client) for MySql.
Subscribe to:
Posts (Atom)
Blog Archive
-
▼
2026
(36)
-
▼
June
(19)
- C10K to C10M: from thread-per-connection model to ...
- Benchmark server performance
- Application server for php, python, java, node.js,...
- Application server for C++, Go and Rust
- Nginx as reverse proxy and load balancer
- Infrastructure running: nginx, apache, php, python...
- Flow chart of nginx+apache+uvcorn infrastructure
- Flow chart of apache+uvcorn infrastructure
- Uvicorn and Gunicorn
- What's deadsnakes PPA
- What's the optional lsb-core package
- Codex known logging bug
- Daemonsize a service
- Train text to image model, to generate images of c...
- Train a model based on OpenAI API
- Open port 8080 for WebSocket
- Add websocket support on Bluehost Ubuntu VPS for D...
- Install Claude Code on ubuntu VPS of Bluehost
- Install PostgreSQL on Mac
-
▼
June
(19)