Learning cryptography
I have started learning cryptography using Go language.
I have started learning cryptography using Go language.
For Above-the-fold optimizations of Google pagespeed, there are a few relevant documents which I need to dig into and find out relevant ones. Below the fold beaconing for Split HTML Beaconing dependent optimizations Split HTML rewriter Detecting and fixing reflows Great design docs for mod_pagespeed are here.
Really busy with stuff. Not much exploration. Used EC2 for the first time. Amazing. The number of AMIs, the storage and security flexibility, the ease of use are all awesome. I have also been playing around with redis; has an awesome tutorial. Reminds me of etcd in some of the basic operations. Played around with nginx and its configuration. Almost every useful module is not provided by default. You just end up compiling anyways. Started reading about HyperLogLog.
Just for my reference, this is how I setup etcd on my ubuntu 12.04. $ curl 'http://go.googlecode.com/files/go1.2.1.linux-amd64.tar.gz' > go1.2.1.linux-amd64.tar.gz $ tar zxvf go1.2.1.linux-amd64.tar.gz $ tail -3 ~/.bashrc export GOROOT=~/go export GOBIN=~/go/bin export PATH=$PATH:~/go/bin $ go version go version go1.2.1 linux/amd64 $ git clone https://github.com/coreos/etcd $ cd etcd $ ./build # Blink your eyes and the build is done. :) # Golang is too good. Other than Apache Mesos, # etcd is the only piece of software which has # a dead-easy setup process. $ ./bin/etcd $ curl -L http://127.0.0.1:4001/v2/keys/mykey {"errorCode":100,"message":"Key not found","cause":"/mykey","index":1} $ curl -L http://127.0.0.1:4001/v2/keys/mykey -XPUT -d value="this is awesome" {"action":"set","node":{"key":"/mykey","value":"this is awesome","modifiedIndex":2, "createdIndex":2}} $ curl -L http://127.0.0.1:4001/v2/keys/mykey {"action":"get","node":{"key":"/mykey","value":"this is awesome","modifiedIndex":2,"createdIndex":2}} $ httperf --hog --server=127.0.0.1 --port=4002 --uri="/v2/keys/foo?value=test" --method=PUT --num-conn=500 --num-call=500 --rate=100 # The above load test produces 3100 updates per second. The full api is explained here.
Just for my reference, this is how I setup Apache Hive on my ubuntu 12.04. bash> tar zxvf hive-0.11.0-bin.tar.gz bash> export HADOOP_HOME=/home/hduser/hadoop/ bash> $HADOOP_HOME/bin/hadoop fs -mkdir /tmp bash> $HADOOP_HOME/bin/hadoop fs -mkdir /user/hive/warehouse bash> $HADOOP_HOME/bin/hadoop fs -chmod g+w /tmp bash> $HADOOP_HOME/bin/hadoop fs -chmod g+w /user/hive/warehouse # Somehow I could not run without using sudo. It kept # throwing some permission denied exception which I # could not fix in a short time. bash> sudo HADOOP_HOME=/home/hduser/hadoop ./bin/hive hive> create table test(id int, msg string); OK Time taken: 0.383 seconds hive> show tables; OK test Time taken: 0.061 seconds, Fetched: 1 row(s) hive> describe test; OK id int None msg string None Time taken: 0.35 seconds, Fetched: 2 row(s)
Just for my reference, this is how I setup mongodb on my ubuntu 12.04. bash> sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10 bash$ echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list bash> sudo apt-get update bash> sudo apt-get install mongodb-org bash> ls -lh /var/lib/mongodb total 81M drwxr-xr-x 2 mongodb nogroup 4.0K Apr 10 02:36 _tmp drwxr-xr-x 2 mongodb nogroup 4.0K Apr 10 02:36 journal -rw------- 1 mongodb nogroup 64M Apr 10 02:36 local.0 -rw------- 1 mongodb nogroup 16M Apr 10 02:36 local.ns -rwxr-xr-x 1 mongodb nogroup 5 Apr 10 02:36 mongod.lock bash> ls -lh /var/log/mongodb total 4.0K -rw-r--r-- 1 mongodb nogroup 2.3K Apr 10 02:37 mongod.log bash> ps aux | grep mongod mongodb 3106 2.1 1.4 357416 37048 ? Ssl 02:36 0:04 /usr/bin/mongod --config /etc/mongod.conf # Start mongo shell > use mydb switched to db mydb > a = { name : "manku-timma" } { "name" : "manku-timma" } > b = { age : 45 } { "age" : 45 } > mydb.testData.insert(a) 2014-04-10T02:46:07.610+0000 ReferenceError: mydb is not defined > db.testData.insert(a) WriteResult({ "nInserted" : 1 }) > db.testData.insert(b) WriteResult({ "nInserted" : 1 }) > show collections system.indexes testData > db.testData.find() { "_id" : ObjectId("53460605f93ad23879b22181"), "name" : "manku-timma" } { "_id" : ObjectId("53460608f93ad23879b22182"), "age" : 45 } > for (var i = 1; i <= 25; i++) db.testData.insert({ x : i }) WriteResult({ "nInserted" : 1 }) > db.testData.find() { "_id" : ObjectId("53460605f93ad23879b22181"), "name" : "manku-timma" } { "_id" : ObjectId("53460608f93ad23879b22182"), "age" : 45 } { "_id" : ObjectId("5346073af93ad23879b22183"), "x" : 1 } { "_id" : ObjectId("5346073af93ad23879b22184"), "x" : 2 } { "_id" : ObjectId("5346073af93ad23879b22185"), "x" : 3 } { "_id" : ObjectId("5346073af93ad23879b22186"), "x" : 4 } { "_id" : ObjectId("5346073af93ad23879b22187"), "x" : 5 } { "_id" : ObjectId("5346073af93ad23879b22188"), "x" : 6 } { "_id" : ObjectId("5346073af93ad23879b22189"), "x" : 7 } { "_id" : ObjectId("5346073af93ad23879b2218a"), "x" : 8 } { "_id" : ObjectId("5346073af93ad23879b2218b"), "x" : 9 } { "_id" : ObjectId("5346073af93ad23879b2218c"), "x" : 10 } { "_id" : ObjectId("5346073af93ad23879b2218d"), "x" : 11 } { "_id" : ObjectId("5346073af93ad23879b2218e"), "x" : 12 } { "_id" : ObjectId("5346073af93ad23879b2218f"), "x" : 13 } { "_id" : ObjectId("5346073af93ad23879b22190"), "x" : 14 } { "_id" : ObjectId("5346073af93ad23879b22191"), "x" : 15 } { "_id" : ObjectId("5346073af93ad23879b22192"), "x" : 16 } { "_id" : ObjectId("5346073af93ad23879b22193"), "x" : 17 } { "_id" : ObjectId("5346073af93ad23879b22194"), "x" : 18 } Type "it" for more > it { "_id" : ObjectId("5346073af93ad23879b22195"), "x" : 19 } { "_id" : ObjectId("5346073af93ad23879b22196"), "x" : 20 } { "_id" : ObjectId("5346073af93ad23879b22197"), "x" : 21 } { "_id" : ObjectId("5346073af93ad23879b22198"), "x" : 22 } { "_id" : ObjectId("5346073af93ad23879b22199"), "x" : 23 } { "_id" : ObjectId("5346073af93ad23879b2219a"), "x" : 24 } { "_id" : ObjectId("5346073af93ad23879b2219b"), "x" : 25 } > it no cursor bash> mongostat connected to: 127.0.0.1 insert query update delete getmore command flushes mapped vsize res faults locked db idx miss % qr|qw ar|aw netIn netOut conn time *0 *0 *0 *0 0 1|0 0 160m 511m 37m 0 # For a simple document insertion, I see about 2800 # inserts per second. Also about 500KBps of data flow. # Delete is instantaneous for very large number of # rows. > db.runCommand( ... { delete: "testData", deletes: [{q:{}, limit:0}]} ... ) { "ok" : 1, "n" : 409843 }
I used Pig to load data into hbase. # Download and extract pig # Download population data of India's villages from http://www.censusindia.gov.in/2011census/A-3_Vill/A-3%20MDDS_Release.xls # Use Libreoffice to convert the .xls to a .csv # Create a table called villages with a column family called population in HBase hbase> create 'villages', 'population' bash> export PIG_CLASSPATH=$PIG_/home/vagrant/hbase-0.94.18/hbase-0.94.18.jar:/home/vagrant/hbase-0.94.18/lib/*:pig-0.12.0-withouthadoop.jar:/home/hduser/hadoop/lib/*:$PIG_CLASSPATH # Load the csv file in Pig grunt> A = load 'file:///vagrant/village-population.csv' using PigStorage(','); # Compute (Name of village, Level of village in hierarchy) grunt> B = foreach A generate $4, $3; # Clean up data grunt> C = filter B $0 != '' and $1 != ''; # Save to HBase using name of the village as key and the level as value into population:level column grunt> store C into 'hbase://villages' using org.apache.pig.backend.hadoop.hbase.HBaseStorage('population:level'); # Compute (Name of village, Number of persons in village) grunt> B = foreach A generate $4, $6; # Clean up data grunt> C = filter B BY $0 != '' and $1 != ''; # Save to HBase using name of village as key and the number of persons as the value into population:persons column grunt> store C into 'hbase://villages' using org.apache.pig.backend.hadoop.hbase.HBaseStorage('population:persons'); # Get all the data hbase> scan 'villages' ROW COLUMN+CELL 'N' Thingdawl column=population:level, timestamp=1396879365983, value=SUB-DISTRICT 'N' Thingdawl column=population:persons, timestamp=139687960225 8, value=12108 ... Zunheboto Sadar column=population:level, timestamp=1396879365963, value=SUB-DISTRICT Zunheboto Sadar column=population:persons, timestamp=139687960225 6, value=13344 # Get all states, districts, sub-districts which # have a rural population of 10000 exactly :) hbase> import org.apache.hadoop.hbase.filter.CompareFilter hbase> import org.apache.hadoop.hbase.filter.SingleColumnValueFilter hbase> import org.apache.hadoop.hbase.filter.SubstringComparator hbase> import org.apache.hadoop.hbase.util.Bytes # EQUAL works. But any other kind of numeric # compare does not work. hbase> scan 'villages', {LIMIT => 10, FILTER => SingleColumnValueFilter.new(Bytes.toBytes('population'), Bytes.toBytes('persons'), CompareFilter::CompareOp.valueOf('EQUAL'), Bytes.toBytes('10000')), COLUMNS => 'population:persons' } I tried a simple numeric comparison and fought long and hard to get it right but it seems nigh impossible for today. My brain is also shutting down. Documentation seems really sparse. This link was the one ray of hope in the dark expanse of the internet. In terms of filters hbase is probably really immature and documentation is worse. Getting a few values can’t be this hard. A SQL layer on top of hbase seems necessary. The hbase shell syntax is too much of a pain and is too idiosyncratic.
Below are the steps I followed to get HBase up and running. # Download and extract hbase-0.94.18 into /home/vagrant/hbase-0.94.18 # Edit hbase-0.94.18/conf/hbase-site.xml to save data in /home/vagrant/hbase <configuration> <property> <name>hbase.rootdir</name> <value>/home/vagrant/hbase/hbase</value> </property> <property> <name>hbase.zookeeper.property.dataDir</name> <value>/home/vagrant/hbase/zookeeper</value> </property> </configuration> # Edit hadoop-metrics.properties for monitoring with ganglia dfs.class=org.apache.hadoop.metrics.ganglia.GangliaContext31 dfs.period=10 dfs.servers=239.2.11.71:8649 mapred.class=org.apache.hadoop.metrics.ganglia.GangliaContext31 mapred.period=10 mapred.servers=239.2.11.71:8649 jvm.class=org.apache.hadoop.metrics.ganglia.GangliaContext31 jvm.period=10 jvm.servers=239.2.11.71:8649 rpc.class=org.apache.hadoop.metrics.ganglia.GangliaContext31 rpc.period=10 rpc.servers=239.2.11.71:8649 # Add a column and some data hbase> create 'test', 'columnfamily' hbase> put 'test', 'rowkey1', 'columnfamily:column1', 'value1' hbase> put 'test', 'rowkey1', 'columnfamily:column2', 'value2' hbase> put 'test', 'rowkey2', 'columnfamily:column1', 'value3' hbase> put 'test', 'rowkey2', 'columnfamily:column2', 'value4' hbase> scan 'test' # Try out HBase-on-HDFS. HDFS is running locally listening on IP 10.0.2.15 <configuration> <property> <name>hbase.rootdir</name> <value>hdfs://10.0.2.15/user/hduser/hbase/hbase</value> </property> <property> <name>hbase.zookeeper.property.dataDir</name> <value>hdfs://10.0.2.15/user/hduser/hbase/zookeeper</value> </property> </configuration>
IPC patterns quick reference (from this book): Mutual exclusion (2 process, n process) Critical section (2 process, n process) Signaling (2 process, n process) Rendezvous (2 process, n process) Producer/Consumer Server/Client Database update/read The fundamental means of communication between processes: Message passing Shared memory
Just for my reference, this is how I setup ganglia on my ubuntu 12.04. # Install relevant packages $ sudo apt-get install ganglia-monitor gmetad ganglia-webfrontend # Edit /etc/ganglia/gmond.conf by setting the cluster attribute as below cluster { name = "local-cluster" owner = "manku-timma" latlong = "world" url = "http://127.0.0.1:9001/ganglia" } # List statistics being monitored $ telnet localhost 8649 # Modification to /etc/apache2/sites-available/default Alias /ganglia/ "/usr/share/ganglia-webfrontend/" <Directory "/usr/share/ganglia-webfrontend/"> Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch AllowOverride None Order allow,deny Allow from all </Directory> # Restart apache after config change $ sudo service apache2 restart # List statistics being stored $ telnet localhost 8651 # Location of stored statistics $ ls /var/lib/ganglia/rrds/unspecified/__SummaryInfo__ # In a browser access http://localhost/ganglia to view graphs. To configure hbase to report metrics: ...