Tuesday, March 21, 2017

Memory in Java

Type of Memory

1) Heap Memory
2) Non Heap Memory
3) Memory Pool- Eden Space
4) Memory Pool- Survivor Sapce
5) Memory Pool- Tenured Space
6) Memory Pool- Meta Space
7) Memory Pool- Code Cache

The Heap and the Nursery
Java objects reside in an area called the heap. The heap is created when the JVM starts up and may increase or decrease in size while the application runs. When the heap becomes full, garbage is collected. During the garbage collection objects that are no longer used are cleared, thus making space for new objects.
The heap is sometimes divided into two areas (or generations) called the nursery (or young space) and the old space. The nursery is a part of the heap reserved for allocation of new objects. When the nursery becomes full, garbage is collected by running a special young collection, where all objects that have lived long enough in the nursery are promoted (moved) to the old space, thus freeing up the nursery for more object allocation. When the old space becomes full garbage is collected there, a process called an old collection.
The reasoning behind a nursery is that most objects are temporary and short lived. A young collection is designed to be swift at finding newly allocated objects that are still alive and moving them away from the nursery. Typically, a young collection frees a given amount of memory much faster than an old collection or a garbage collection of a single-generational heap (a heap without a nursery).

Reference:

Monday, March 20, 2017

Unix Command : EXPORT

export is a built-in command of the bash shell  It is used to mark a shell variable for export to child processes.

Example-
# .bash_profile
JAVA_HOME="/java/jdk"

export PATH JAVA_HOME
When you execute a program the child program inherits its environment variables from the parent. For instance if $HOME is set to /root in the parent then the child's $HOME variable is also set to /root.
This only applies to environment variable that are marked for export. If you set a variable at the command-line like
$ FOO="bar"
That variable will not be visible in child processes. Not unless you export it:
$ export FOO
You can combine these two statements into a single one in bash (but not in old-school sh):
$ export FOO="bar"
Here's a quick example showing the difference between exported and non-exported variables. To understand what's happening know that sh -c creates a child shell process which inherits the parent shell's environment.
$ FOO=bar
$ sh -c 'echo $FOO'

$ export FOO
$ sh -c 'echo $FOO'
bar

Friday, March 17, 2017

Clustering vs Load Balancing

High Availability
Does Your Organization Need High Availability Clustering?

Availability can be measured relative to "100% operational" or "never failing." Have you ever heard someone refer to "five 9s"? This is a metric that refers to system availability by the number of "9s." One 9 is 90% uptime, two 9s are 99%, three 9s are 99.9%, etc. Four-9 uptime would mean that your system has less than one hour of downtime per year. Five 9s are currently considered the entry point for high availability solutions. "Five 9s (which represents 5.39 minutes of annual downtime) would be considered the Holy Grail of high-availability for distributed systems," 


What is load balancing?
The concept of load balancing is a simple one: spreading the work that a computer needs to do across multiple machines. However, the implementation of this idea can be quite complex. A number of vendors offer load balancing solutions that are implemented in different ways. You may have heard about Windows Load Balancing Service (WLBS), Network Load Balancing (NLB), Component Load Balancing (CLB), and other similar terms. In this Daily Drill Down, I will address the broad term server load balancing, which can encompass all of the above and more.
Load balancing and server clustering One way to distribute the workload is to use server clustering. A server cluster consists of two or more servers that operate and are managed as if they were a single entity. The servers must be able to access one another’s disk data. Special software (such as MSCS, Microsoft Cluster Server) is used to manage the systems, automatically detect the failure of one system, and provide failover/recovery.
Server clusters are sometimes called server farms. In some implementations, the servers have individual operating systems, while in others they share an operating system. Large Web sites such as Yahoo use multiple servers in a Web farm to handle the huge volume of traffic.
Hardware vs. software implementations Operating systems such as Windows NT/2000 and Red Hat’s High Availability Linux Server provide software-based load balancing, and there are also software packages such as Resonate. Many vendors also make hardware devices based on switching technology that include load balancing functionality.
Load balancing switches and routers, such as those made by Cisco, Radware, Foundary, Alteon, and other vendors, use a variety of algorithms to distribute TCP/IP requests among a group of servers. Load balancing switches are also often referred to as content switches and content directors.
Early load balancing solutions used a DNS round-robin algorithm; more recent methods includeleast connections and fastest response algorithms.

Advantages of server load balancing and clustering
Load balancing and clustering are part of High Availability (HA) strategy. Having two or more computers handle the workload increases performance (speeding up the process), and the redundancy also provides fault tolerance; if one of the machines goes down, the other can still continue to function. Clients see the group of servers as a single virtual server, with one IP address.
There are three big advantages of clustering servers to provide load balancing:

  • Easier and more flexible management: With clustering software, administrators can move the workload onto particular servers within a cluster (for example, to update a server without impacting accessibility of data and services to clients).
  • Uninterrupted availability and fault tolerance: If a server fails, clustering software detects the failure and fails over to a remaining server.
  • Better scalability: Load balancing can be scaled across multiple servers in a cluster. Applications that are written to run on server clusters can perform dynamic load balancing.
Load balancing and server clustering technologies are important to enterprise-level networks because of the mission-critical nature of servers such as those that provide a Web presence (and often, secure transaction services and database access) on the Internet or those that provide applications and data on the corporate intranet. Load balancing ensures high availability and little or no downtime for Web, proxy, terminal, and VPN servers.
Load balancing servers in a cluster allow companies to scale their network services in conjunction with rapid growth so that additional servers can be added to the cluster as network traffic increases. Load balancing is usually implemented in conjunction with server clustering. A load balancing cluster distributes the load of incoming TCP/IP traffic, while a server cluster provides fault tolerance.


How does server clustering work?


Server Cluster
A server cluster is a collection of servers, called nodes that communicate with each other to make a set of services highly available to clients. 

Server clusters are designed for applications that have long-running in-memory state or frequently updated data. Typical uses for server clusters include file servers, print servers, database servers, and messaging servers.


The ability to handle failure allows server clusters to meet requirements for high availability, which is the ability to provide users with access to a service for a high percentage of time while reducing unscheduled outages.

The servers that are members of a cluster are called hosts or nodes (depending on the vendor of the clustering technology). The cluster members are physically connected via network cables andprogrammatically connected via the clustering software.
The clustering software provides:

  • A means by which the cluster members can have common access to disk data.
  • A means of detecting when a server or application fails.
  • A means of recovering from a failure by shifting the work to the remaining server(s) or restarting the application.
  • An interface through which the servers in the cluster can be managed as one entity, presenting a “single system image.”
It is also useful if the cluster administration software allows you to remotely manage the server cluster.
Sharing disk data access between servers
There are several different methods that can be used to allow more than one server to have access to disk data. These include:

  • Shared disk method
  • Mirrored disk method
  • “Shared nothing” method
The shared disk method was used with the first implementations of server clustering. Software called Distributed Lock Manager (DLM) was used to give all servers in the cluster access to all physical disks. Shared disk clustering requires SCSI disks (or special cabling and switches) and applications that are modified to be aware of the disk sharing. Oracle’s Parallel Server uses shared disks.
With the mirrored disk method, each of the servers in the cluster has its own disks. The data is mirrored (an exact copy is written) to the disks on other servers. This requires special software such as that made by Veritas, NSI, and Octopus.
“Shared nothing” is a clustering method in which each server has its own disk resources. The clustering software transfers the ownership of a disk from one server to another if the server that owns the disk fails. An advantage of this method is that applications do not have to be modified. Microsoft Cluster Services (MSCS) uses this method.
Detecting server or application failure
When server clusters are used to provide fault tolerance, there must be a way for the cluster to detect when one of its member servers fails (or when an application on the cluster fails). One way, used by Microsoft in their clustering solutions, is with software “heartbeats”—messages that are sent on a regular basis between nodes. If a server fails, it will cease to emit the periodic heartbeat message, and the software will redistribute the workload among the remaining servers.
Understanding failover and failback
When a failure is detected, recovery involves failover, which is the transition that occurs when a server fails and another server(s) picks up its load. In many cases, this transition is transparent to the clients, as the applications, file shares, and other resources are restarted by the clustering software at the same IP address. If the client is browsing the Web or using some other “stateless” connection type, the user may not be aware of the failure at all. The application automatically reconnects after a failover. With some client applications, the user may receive a message that the server is unavailable and may be required to log back on. When the failed server comes back online, clustering software detects its presence and allows it to automatically rejoin the cluster.
After the failed server rejoins the cluster, failback is the process that automatically redistributes the workload again to include the newly rejoined server.
Balancing the load
Depending upon the load balancing implementations, administrators may be able to specify how much of the load each host should handle (the weight) or spread the load equally among all hosts in the load balancing cluster.
Load balancing can be integrated with other network services such as network address translation (NAT). The load sharing network address translation (LSNAT) technology allows for a router to intercept client requests directed to a server and select a node in the server pool to which the request will be sent, based on the load sharing algorithm.


Reference Link: 





WildFly Application Server

Wildfly, formerly known as the JBoss Application Server, is a free open-source application server that provides an environment in which applications can run. Wildfly is written in Java and was originally authored by JBoss but is now actively maintained by Red Hat. Wildfly implements the Java Platform, Enterprise Edition (Java EE) specification and version 10 supports Java 8. Because Wilfly is written in Java, it can run on multiple platforms.
Wildfly offers several noteworthy features:
  • Java Server Pages (JSPs)/Java Servlets
  • Clustering
  • Load Balancing
  • Enterprise Java Beans
  • Failover
  • Java Message Service (JMS) integration,
  • Java Naming and Directory Interface (JNDI),
  • Java Transaction API (JTA),
  • Java Authorization Contract for Containers,  (JACC) and JavaMail
  • Caching
  • ActiveMQ as JMS Broker
  • Server Side JavaScript
  • Migration Assistance from Older Systems
  • Automatic Pool Sizing
The main benefit of Wildfly over other application servers is that Wilfly provides a full Java Enterprise Edition (JEE) stack, including Enterprise JavaBeans and many other technologies used when building an enterprise level Java application.  The administrative console is also intuitive and easy to use.

Friday, March 3, 2017

Unix vs Linux

Key Differences

  • Linux is free and open-source, the original Unix is not (but some of its derivatives are);
  • Linux is a “clone” of the original Unix, but it doesn’t contain its code;
  • Linux is just the kernel, while Unix was/is a complete operating system;
  • Linux was developed for personal computers, while Unix was primarily for large workstations and servers. Today, Linux supports more platforms than Unix;
  • Linux also supports more filesystem types than Unix.
Reference:
http://beebom.com/unix-vs-linux-what-is-the-difference/