Translate

Monday, December 2, 2013

DevOps Notes



Notes on DevOps: Continuous Delivery & Continuous Deployment
1)      Imbibing agile methodologies – Use of agile and other development processes and methodologies
2)      Lowered time to market – Demand for an increased rate of production releases from application and business unit stakeholders
3)      Proven benefit of virtual infrastructure – Wide availability of virtualized and cloud infrastructure from internal and external providers
4)      Automated configuration – Increased usage of data center automation and configuration management tools
5)      Measuring strategy for effectiveness of DevOps : http://zeroturnaround.com/labs/how-to-measure-the-effectiveness-of-implementing-devops/
6)      Impact of application release
a.       Reduced changed scope – small scope for each iteration
b.      Increased release co – ordination – bridging the communication gap between dev à ops and ops à dev
c.       Increased automation – repeatability of deployment
7)      Reason of conflict between Development & Operations Teams
a.       Development teams are more focused on releasing new functional requirement early which specifically revolves around business requirement. They use operating environment which are attuned to rapid & flexible options to produce outcome faster. The team are usually ignorant of the distributed runtime environment which hosts the application for production use
b.      Operations teams are focused towards guarantying NFR and therefore resistant to bring in new changes often that may question the existing NFR
8)      Solution
a.       Better release planning
b.      Better release co – ordination
c.       Better deployment automation
9)      Measurement of ROI for DevOps
a.       Mean Time Between Failure (MTBF)
b.      Mean Time to Recover
c.       Mean Time to Rollback
d.      How many issues (changes/feature adds) got resolved in period x?  Deliveries / time
e.      # deployments to prod : # incidents created
f.        Tie a cost of incidents to a % of revenue (an example given was, if the cost of incidents is <3% of revenue, then they're doing a good job, and should focus more on quicker delivery) “size” of deployment
g.       Cost of Deployment = time to deploy * people involved or waiting
h.      Length of cycle time (# of features in a period of time) vs # of outages
i.         Amount of dev time spent on features vs bug fixes
j.        DevOps “Karma” measurements –
                                                               i.      Measuring happiness of people – avg team member smileys / month   :) vs :(
                                                             ii.      Ability to attract key people / retaining top talent
                                                            iii.      Dilbert count – it was suggested that more dilbert comics are posted on cubicle walls = a worse environment to work in.  This was countered by the argument that a sarcastic environment can still be highly effective and enjoyable.
k.       # of bugs that come out of a release
l.         Visibility of app status (latency, # hits)
m.    # of early catches – incidents that were prevented due to having the people
n.      % “value” releases vs % “internal” releases (where an internal release = bug fixes or eliminating technical debt to helps ensure everything runs smoothly
o.      “Ripple Effect” – # changes coming out of development that required an operational procedure or tooling change (dev –> ops), then measure the amount of time that developers spent helping operations people (ops –> dev)
p.      Planned vs Unplanned Changes (visible ops guys say that the number of unplanned changes should be zero)… possible to measure # of system logons
q.      Ability to value IT staff’s value (“I saved the company x $$”)
r.        What’s the cost of moving a unit of value from development to the end user? Seen as a manufacturing process: when you know that value, you know whether it’s worth it to pay more to get it out faster
10)   Solution space
a.       Automated infrastructure
b.      Shared version control
c.       One step build
d.      One step deployment
e.      Feature flags and branches
f.        Private beta
g.       Bucket testing
h.      Dark launches
i.         Shared metrics
j.        Logs (build, deployment, alert)
k.       Communication pointer
                                                               i.      What metrics will change
                                                             ii.      Risks involved
                                                            iii.      Signs that something is going wrong
                                                           iv.      Contingencies available
l.         Respect + Trust + Healthy attitude about failure + Avoiding blame
11)   Levers (CI)
a.       Build tool specific optimization and templating
b.      Version control support
c.       Unit test strategies
d.      Integration, Functional, Load & Performance Testing (*TaaS ?? & Formation)
e.      Code quality analysis
f.        Issue management
g.       Technical Documentation
h.      Alert & Notification
i.         Reports
12)   Levers (CD)
13)   CloudForge
a.       Top focus area
                                                               i.      Source code management
                                                             ii.      Agile dev tools
                                                            iii.      Build
                                                           iv.      Testing
                                                             v.      Deployment tool & framework
                                                           vi.      Application monitoring
                                                          vii.      File storage
14)   Jenkins Integration Opportunity
a.       VCS
b.      Build Tool
c.       Test Framework
d.      Programming Platform
e.      Static Analysis
f.        Code coverage
g.       Notification
h.      Virtual Machine








Saturday, October 15, 2011

Class Loading

Basic
  • Class loaders are responsible for loading classes into the Java Virtual Machine (JVM). 
  • There are two important concepts around Class Loader paradigm. Isolation & Delegation. 
  • Isolation guarantees that class loaded by class loader 1 is not equal to the same class loaded by class loader 2. Also a parent class loader is unable to "see" a class loaded by child class loader. 
  • A class loader verifies the class cache to return an already loaded one. If it does not find one, as par delegation model it first asks its parent to load a class before it starts to load the class on its own
  • Bootstrap class loader is primordial one that loads core system classes from the boot class path
  • This is extended by extension classloader that loads classes from jre/lib/ext directory
  • This is extended by System class loader that loads classes found on the CLASSPATH environmenal variable. This is also the class loader returned by the ClassLoader.getSystemClassLoader() method.Any custom class loaders are expected to extend System class loader

Loading step by step
  • Class Loading is a step by step process. There are three stages for a class loading to happen. These are loading, linking and initializing.
  • During loading raw bytes are located and read into JVM. Basic memory structure is assigned to the attributes, methods and other referenced classed
  • During linking three smaller tasks happens sequentially, first bytecode is verified to ascertain that it is a valid bytecode, then at the "class preparation" stage appropriate data structure for the fields, method and implemented interfaces are defined, finally at "resolving" stage all other classes that are referenced by the field, interface, superclass, method signature and local variable are loaded.
  • During initialization all static variables are initialized to default value and static blocks are executed
  • Implicit vs Explicit loading
  • Explicit loading is loading a class via Class.forName or classLoader.loadClass method
  • Implicit loading is loading of a class on being referenced as discovered during the resolving sub task of  linking phase as mentioned earlier
Class Loading - Exception
  • ClassNotFoundException is the most common type of class loading exception. It occurs during the loading phase. The Java specification describes ClassNotFoundException as follows:
Thrown when an application tries to load in a class through its string name using:
o    The forName() method in class Class.
o    The findSystemClass method() in class ClassLoader.
o    The loadClass() method in class ClassLoader.
but no definition for the class with the specified name could be found.
By throwing a ClassNotFoundException, the class loader informs you that the bytecode required to define the class is simply not present in the locations where the class loader is looking for it.
  • NoClassDefFoundError is thrown when a class is not found during implicit classloading. This happens when a class was present during the compilation of the target class but now unavailable when the target class is getting loaded at run time. This missing class can be required as an argument to the method call or used with the new operator.
  • ClassCastException is when code tries to cast an object to a sub class of which it is not an instance of
  • UnstatisfiedLinkError is being thrown when a native library is not found while loading
  • ClassCirculatoryError is being thrown when there exists a circulatory class hierarchy. This usually happen in complex systems during resolving stage
  •  ClassFormatError happens during verification sub stage of linking phase when the binary data that represents the class is found to be malformed
  • Problems faced during class loading
    • Classpath related : if following two paths are supplied to the URLClassLoader namely /a/b/c & /a/b/c/ then the class loader assumes that the first path refers to a jar and the second path refers to a directory
    • Class visibility: A class loader can only see classes to which it has direct or indirect reference. In delegation model it turns out that the class loader in question will be able to see what its parent has loaded but not its child
    • Overriding loadClass() : in case it requires manually invoking loadClass method following code should be written by the custom classloader
public Class loadClass(String name) throws ClassNotFoundException {
    Class c = null;
    try {
        c = getParent().loadClass(name);
    } catch (ClassNotFoundException e) {
    }
    if(c == null)
        c = findClass(name);
    return c;
}
Instead of using getParent.loadClass() have had we been invoking loadClass directly exception would have been thrown as parent class loaders are never invoked and therefore system classes are not being loaded
However this implementation has a drawback as loadClass always tries to load a class instead of verifying if that exists in the cache. This is why the method should be modified such that instead of initializing variable c to null, findLoadedClass method is invoked which first verifies the cache to return an already loaded instance
    • Garbage collectors monitor the lookup tables associated with the classloader to figure out which class can be garbage collected. However if a classloader itself is garbage collected, that classed it loaded are lost as well