mohanraj nagasamy

Panamax Template for Couchbase 5 Node Cluster

Panamax is Docker Management for Humans. You can get started with simple steps described here. It provides a friendly interface for users of Docker, Fleet & CoreOS. With Panamax, you can easily create, share and deploy any containerized app no matter how complex it might be. You can linking (or stitching them) different docker images together and exposing them to outside world. You can start and stop docker containers everything within panamax web ui.

I have created “Panamax template for couchbase 5 node cluster”. Let’s see how simple it is to setup the cluster.

Utah Code Camp 2014: Notes

I went to Utah Code Camp 2014. It has happened at University of Utah with more than 850 attendees. The organizers were awesome as always. They planned 13 concurrent tracks with great schedule this time.

I want to capture some notes from the sessions I went to.

Conceptual Data Modeling by Tyler Young

Tyler talked about ORM tool – this not the tool you are thinking. It is about object-role modeling and how you can use this tool to do modeling and generate ER diagrams and SQLs for different DBs.

Introduction to HBase by Giri Vislawath

Giri talked about HBase overview. Slides

Building web apps with node.js by Scott Hillman

Scott went over Node.js’s event loop model. And explained why it is not good for CPU bound intensive tasks but it is great for IO bound tasks. Talked about npm. And why there is only one package manager (because they are awesome and no one wants yet an another one).

Talked about node developer work flow with tools like nodemon and node-supervisor.

Machine Learning the easy way with Weka by Alton Alexander

Weka is a tool that will give you easy and fast ML results. Programmed with all of the common ML algorithms, you can start to impress fast!. He went over the Weka tool GUI and some of the ML algorithms.

Ember.js Lessons Learned by Justin Ball

The slides are available here.

There is jQuery plugin as well.

And useful links

Java Performance

Notes from Java Performance by Charlie Hunt. Reference book by Charlie Hunt and Binu John.

Lesson 1: JVM Overview

  • From Java 7u21, there is server JRE available for UNIX 64 bit OSes. It has got it everything jdk has, except no browser plug-in, no auto updater.

  • Understand the major components of a modern Java Virtual Machine

    • HotSpot VM runtime
    • Garbage collector/ memory manager
      • Generational GC – it partitions the Java heap into two or more regions / generations
        • Young vs Old
      • Permanent Generation – Holds class data structures
        • In Java 8 – it has been eliminated in favor of a meta-space
    • JIT Compiler
      • Generates native byte code
      • Client mode
      • Server mode
      • Tiered – Default In Java 8 – enabled via -XX:+TieredCompilation
  • Runtime subsystem

    • -XX:+PrintFlagsFinal
    • -XX:+PrintGCDetails
  • Understand the memory management garbage collection (GC) subsystem
    • jvisualvm
      • Install plug-in visual GC
      • Install memory-pool plug-in from here
      • Once objects reaches 15 max tenuring, will promoted to old gen space
      • jTop
    • JIT compiler subsystem
      • Look at code cache from memory-pool plug-in for JIT compilation

Lesson 2: Collecting Performance Statistics

  • Understand the importance of a methodology
  • Understand which operating system metrics to monitor
    • Understand which operating system metrics to monitor: Monitor metrics on Windows. You can monitoring CPU, Memory, Network:

      1. GUI Tool: Performance Monitor
      2. CMD Tool: typeperf
    • Understand which operating system metrics to monitor: Monitor metrics on Linux

      1. GUI Tool: System Monitory in Ubuntu
      2. CMD tool: vm_stat mpstat -P ALL top
      3. Monitor the CPU Scheduler Run Queue use vmstat to monitor run queue
      4. Monitor High Voluntary Context Switching
        • Can indicate Java application that are experiencing lock contention
          • Makes it difficulties in scaling
        • Use pidstat to monitor (need sysstat package required)
          ex: pidstat -w -I -t -p <pid> <interval> Monitor network use nicstat Monitor disk/io use iostat
  • Understand what JVM metrics to monitor
    • Important JVM metrics:
    • Garbage collection: Use PrintGCDetails to log gc details you can also use -XX:+PrintGCDateStamps or -XX:+PrintGCTimeStamps – gives point and time when the gc has occurred use -Xloggc=/somepath/gc.log – to log gc log
    • Monitor app exectution time and stopped time
      • Use -XX:+PrintGCApplicationStoppedTime and -XX:+PrintApplicationConcurrentTime
    • Other to consider but not necessarily required
      • JIT compilation: -XX:+PrintCompilation, -XX:+PrintInlining – these flags are not generally used.
      • Fine tune JVM heap space sizes: -XX:+PrintTenuringDistribution, PrintAdaptiveSizePolicy (Paraller GC or G1 only)
    • Remote monitoring using jstatd
      • Requires a security manager and security policy file
    • App level metrics to monitor:
      • Begin and end time of a transaction
      • Observing app level JMX MBeans especially those that offer performance information
      • Java EE container stats:
        • Available JDBC connections
        • Active/Available Threads
        • Request arrival rate
        • Request response times
      • Build App level stats via MBeans. Example is on the book.

Lesson 3: Understand HotSpot JVM GC Logs

  • Understand how Parallel GC works
    • Understand Parallel GC logs
  • Understand how CMS GC works
    • Understand CMS GC logs
  • Understand how G1 GC works
    • Understand G1 GC logs

All of them produces totally different information


Lesson 4: Tune the HotSpot JVM Step-by-Step

  • Create a plan of attack
    • Throughput vs Latency vs Footprint
  • Understand the step-by-step process
  • Determine memory footprint size
  • Tune for latency / responsiveness: Tools to help visualize gc pause times: gchisto, censum from jclarity.com
  • Tune for throughput: -XX:+AggresiveOpts to turn on aggressive gc optimizations

More resources:

I would highly encourage to read the book or take the LiveLessons. Charlie Hunt is awesome!

Clojure Fundamentals

I haven’t this excited when I am learning programing languages. Clojure is very simple and powerful Lisp dialect on JVM.

You code as data in Clojure. So my personal feeling is that Lisp dialects should have been the go to programming language to develop multi-tenant applications like Workday, Salesforce. And to create rule engines. There has been some attempts made by clara-rules and mimir projects to create rule engines. We can store the Clojure code as data in any storage (ex: DB) and read into JVM memory as the semantics and the structures remain the same. It makes Clojure so powerful and elegant to work with.

I would like list some of the resources that I used to learn Clojure.

Interesting Project: Nashorn

I am going to cover some of the interesting or odd projects that are being targeted to run on jvm that I came across recently in this multi post blogs.

Nashorn:

Nashorn is an upcoming JavaScript engine, developed fully in Java 8 Language by Oracle. And open sourced to OpenJDK as part of jdk8. It also validates the InvokeDynamic (JSR-292) feature in JDK 7; leverage all new language and JVM features in JDK 8.

Blocks in Java Lang

We all love blocks in Ruby. Wouldn’t it be great if Java Lang had support for blocks? Well, Java Lang will support blocks/lambdas in jdk8, but in a limited way.

Until you get a chance to work with jdk8 for real blocks/lambdas, there is an old trick we can apply while creating/initializing an object. That is called the less known “Double Brace Initialization” java idiom. This just works for creating/initializing an object. You can’t apply this idiom in other places like you would in Ruby. But, this trick works in all the version of java as well including java 1.2

Browser Cache: How ETags Works in Rails 3 and Rails 4

Entity tags (ETags) are a mechanism that web/application servers and browsers use to determine whether the entity or component (images, scripts, stylesheets, page content etc) in the browser’s cache matches the one on the origin server.