Thursday, August 11, 2011

Oracle Coherence Best Practices for Session Management (Replication) in Clustered Application Servers Environment

Oracle Coherence is a in-memory data grid product, which is also being used commonly for Session Replication across cluster of application server nodes. It supports wide variety of application servers like WebLogic, WebSphere, Tomcat, JBoss, etc. Coherence*Web is Session Management module (built on top of Coherence) used for managing session information in clustered environment.

I would recommend following best practices w.r.t. Coherence*Web & Coherence usage particularly for Session Management (it can also be applied in other Coherence scenarios):

Coherence Deployment Topology

Coherence supports three deployment modes:
¨     In-process - Application servers that run Coherence*Web are storage-enabled, so that the HTTP session storage is co-located with the application servers. No separate cache servers are used for HTTP session storage.
¨     Out-of-process - The application servers that run Coherence*Web are storage-disabled members of the Coherence cluster. Separate cache servers are used for HTTP session storage.
¨     Out-of-Process with Coherence*Extend - The application servers that run Coherence*Web are not part of a Coherence cluster; the application servers use Coherence*Extend to attach to a Coherence cluster which contains cache servers used for HTTP session storage.
Recommendation:
If there is need for Coherence to extend its boundaries beyond core Coherence TCMP (internal protocol used by Coherence), use Coherence*Extend, which supports Java, .Net & C++ clients.
In most of the scenarios, out-of-process is recommended topology because it has dedicated cache server nodes running independently promoting loose-coupled physical architecture.

For Session Replication, sharing associated application server memory (heap) with Coherence using in-process deployment creates dependability. If application server memory usage increases, it will impact Coherence performance as well & vice-versa.

Please make sure the following for Out-of-process configuration:
¨     Application Server Nodes are running in Storage-disabled mode. You need to pass both of these command-line parameters (or by using Coherence over-ride file) to application server JVM :

-Dtangosol.coherence.session.localstorage=false
-Dtangosol.coherence.distributed.localstorage=false


Please note that setting session storage property explicitely is needed as by default it is “true” in “session-cache-config.xml”:
…………………. 
<local-storage system-property="tangosol.coherence.session.localstorage"
………………….
 ¨     Coherence Dedicated Nodes need to be storage enabled (otherwise there is nobody to store session attributes) and should either use “session-cache-config.xml” or custom cache configuration file with session cache configured in it:


java –Xms512m -Xmx512m -cp /usr/local/coherence_3_6/lib/coherence.jar:/usr/local/coherence_3_6/lib/coherence-web-spi.war:/usr/local/coherence_3_6/lib/commons-logging-api.jar:/usr/local/coherence_3_6/lib/log4j-1.2.8.jar
 -Dtangosol.coherence.cacheconfig=../../../webapps/example/WEB-INF/classes/session-cache-config.xml -Dtangosol.coherence.log.level=6 -Dtangosol.coherence.ttl=2 -Dtangosol.coherence.log=log4j -Dtangosol.coherence.edition=EE
-Dtangosol.coherence.session.localstorage=true com.tangosol.net.DefaultCacheServer


Coherence Cache Topology

Coherence supports five different types of Cache based upon four cache topologies:
¨     Local Cache Topology: Local Cache
¨     Partitioned Cache Topology: Distributed (or Partitioned Cache)
¨     Replicated Cache Topology: Replicated Cache, Optimistic Cache
¨     Hybrid Topology (Local + Partitioned): Near Cache

You can use following simple guidelines in choosing appropriate type of cache:

Scenario
Recommended Cache Type
·         You need faster read & write
·         You don’t need fault tolerance (caution: no fault tolerance)
Local Cache
·         You need faster read with best fault tolerance
·         Write will be comparatively good but will have latency for copying updated data across
·         Typically used to store metadata or configuration data
Note: Scale-out (horizontal scalability) can not be linear.
Replicated Cache
·         You need faster write but best fault tolerance
·         Read will be comparatively faster but depend on whether it reads from local or remote node
Partitioned or Distributed Cache
·         You need faster write but best fault tolerance
·         Read will be comparatively faster but depend on whether it reads from local or remote node
·         Affinity boost performance of read-heavy application with moderate writes
Near Cache (backed up by Partitioned Cache)


Executing Production Checklist

Coherence recommends executing list of checklist on production environment to make sure environment & infrastructure has recommended settings/configurations particularly in following areas:
¨     Network:
·         Multicast Test: If you are using multicast clustering, this test is must to make sure multicast configuration is correct & working properly.
·         Datagram Test – Before deploying your application, you must run it to make sure that there is no packet-loss in your network. Note that in 1GbE network, you should use 100MB packets for testing & minimum (not average) success rate should be close to 100% (~98-99%)
·         TTL – It is very important setting for multicast network & usually 2-5 is recommended value in production environment
¨     Hardware, OS & JVM Settings
¨     Coherence Editions & Modes:
·         Needless to say, Coherence mode should be PROD in production environment. It needs to be specified on command-line as override configuration file can not be used for Edition & Mode.
-Dtangosol.coherence.mode=PROD
·         By default, Coherence runs in GE (Grid Edition) & it is very important to use appropriate edition (as per your license & needs) to specify the correct edition.
-Dtangosol.coherence.edition=EE
Note that all the nodes in cluster should use same edition.


Executing Performance Tuning Guidelines

Coherence suggests tuning for: OS, Network, JVM & Coherence Network.

Please refer to Coherence Performance Tuning guidelines (reference section) for more details.

Enable JMX for Monitoring Coherence

Coherence provides OOTB support for JMX-based monitoring for its cluster, nodes, caches & others.
It needs at least one node to act as manager & rest of the nodes in cluster can publish their statistics using JMX.

For management node,

-Dtangosol.coherence.management=all -Dtangosol.coherence.management.remote=true
-Dtangosol.coherence.management.jvm.all=false  -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.port= -Dcom.sun.management.jmxremote

For other nodes, you can simply remove “tangosol.coherence.management” command-line parameter.
Also, note that in above case, JMX authentication is not enabled (which needs to be secured) & JMX port needs to be specified as well.

Using Log4J for Coherence Logs

Though Coherence has its own logging mechanism, Log4J is more beneficial in terms of log rotation & controlling appropriate log levels.
Note that you can use both Coherence Log Level parameter (-Dtangosol.coherence.log.level) & Log4J configuration for logging level.

Follow these steps to enable Log4J for Coherence:
¨     Coherence does not have log4j libraries & hence you need to add following jars to classpath:
a.       Copy “commons-logging-api.jar” & “log4j-1.2.8.jar” to /lib folder
¨     Create/Modify your Log4J XML file & put that in classpath of your Coherence JVM.
¨     Set command-line parameter (or use override file) to specify log parameter value as “log4j”.


Note that Coherence assumes that Log4J XML will have Logger Name as “Coherence” otherwise you need to specify logger name by having separate parameter “tangosol.coherence.log.logger”.

Example:

Cache Server Startup Script


JAVA_OPTS="-Xms$MEMORY -Xmx$MEMORY -Dtangosol.coherence.log.level=6 -Dtangosol.coherence.log=log4j -Dtangosol.coherence.log.logger=MyCoherence"

$JAVAEXEC -server -showversion $JAVA_OPTS -cp "$COHERENCE_HOME/lib/coherence.jar:$ "$COHERENCE_HOME/lib/commons-logging-api.jar:$ COHERENCE_HOME/lib/log4j-1.2.8.jar" com.tangosol.net.DefaultCacheServer $1


Log4J XML

......................
<logger name="MyCoherence">
  <level value="3"/>
  <appender-ref ref="CoherenceAppender"/>
....................

Review Coherence*Web Context Parameter

There are several Coherence Web Context Parameters, which need to be adjusted when you are installing Coherence*Web in your web application, particularly following:
¨     coherence-enable-sessioncontext
¨     coherence-session-id-length
¨     coherence-session-urlencode-enabled
¨     coherence-session-thread-locking
¨     coherence-sticky-sessions
¨     coherence-reaperdaemon-assume-locality
¨     coherence-enable-suspect-attributes

Note: These parameters are configured in web.xml & got instrumented when Coherence*Web install utility is invoked.


Using Coherence as L2 Cache Provider

Coherence can also be used as L2 Cache provider for ORM frameworks in-use. Having Coherence as L2 cache enables enterprise level caching for your ORM L2 caches as well.

To configure the same, you need to specify Coherence as L2 Cache Provider (particularly for Hibernate L2 Cache):

¨     Specify Coherence as L2 Cache provider in Hibernate Configuration file:


<prop key="hibernate.cache.provider_class">
com.tangosol.coherence.hibernate.CoherenceCacheProvider
</prop>


¨     Configuration for Hibernate L2 Cache is loaded based on following parameter. There is default L2 Cache configuration file already in place.



-Dtangosol.coherence.hibernate.cacheconfig = /hibernate-cache-config.xml


References




Disclaimer:
All data and information provided on this site is for informational purposes only. This site makes no representations as to accuracy, completeness, currentness, suitability, or validity of any information on this site and will not be liable for any errors, omissions, or delays in this information or any losses, injuries, or damages arising from its display or use. All information is provided on an as-is basis.This is a personal weblog. The opinions expressed here represent my own and not those of my employer or any other organization.



Thursday, June 2, 2011

Is cutting-edge technology the right solution for all business problems?


Technology is fast-paced & keeping up your application stack with latest technology stack available is one of the common problems architects face in today’s world. At one end, vendors keep on pushing their clients to upgrade to latest version or latest patch to make their life easier. On the other hand, existing technology stack becomes outdated & lucrative new options baffles technology people how to go about it!!
There is no black and white answer to this problem, but these key factors help in making the right decision:
  1. Context:
Unless you understand the context, it does not make sense to make any sensible suggestion at all to any application or enterprise architecture. For example, for a travel website, there is constant competition with other websites to keep experimenting new features, which in turn needs cutting-edge technology or something latest in the market (like mashups). But it might not be a need for stock-trading application.
So, it is never “one-solution-fits-all” approach that works in technology!!

  1. Problem Area:
Regular architecture reviews of your application might reveal certain problem areas (e.g. caching system needs to move to enterprise caching) or there is a specific business problem to solve, which needs new technology (e.g. using Amazon S3 for storage).
So, 2nd point is to pinpoint strong problem area, which demands change in technology (upgrade or replacement).

  1. Business Needs:
Thirdly & most importantly is business need as business stakeholders will be paying for extra cost &  hence there has to be very strong business benefits to be realized (e.g. integration with third-party using ESB instead of hub-spoke model). Unless business gets convinced that they will get strategic benefit out of it, it is not possible to sell any technology to them.
So, 3rd  point is to discover business needs which backs up technology.

  1. Technology Needs:
Last but not least, there are technology needs as well (e.g. your Oracle 10.0 will be out of support soon & you need to upgrade to Oracle 11g to get customer support), which can also be a key driver. Also, certain business problems (like lower TCO) can only be solved by implementing strategic major technology solution (like top-down/bottom-up SOA stack).
So, 4th point is to discover technical needs in your software or application stack.

In summary, needs create technology not technology create needs & hence all the above mentioned points make sense whenever you are going to make any decision on applying new cutting-edge technology. Also, keep in mind that proven technology works best & experimentation might be risky for business continuity. But make sure that innovation (which specially need new technology) does not get killed which makes you one-step ahead in this competitive world!!

Friday, November 26, 2010

In-Memory Data Grid (IMDG) for Linear Horizontal Scalability & Extreme Transaction Processing (XTP)

IMDG products offers the capability to handle transactions in-memory (so faster) & facilitates creating a data grid (so linear scalability) for managing extreme processing (XTP) needs.
There are both commercial & open-source products available in market but before deciding upon the product or even using IMDG as technology, I would recommend considering following design/architectural points first:
1. Your needs: First & foremost, like any other solution, this is the most important factor to determine whether there is a need for such product or not. License cost for commercial product can cost a lost (~ $ 2500/- per processor for enterprise edition) and hence cost-benefit needs to be assessed first. I don’t see the need of it if there is no requirement for XTP (e.g. not needed for < 200 TPS).
2. Parallel Computing:
A distributed grid can offer processing ability similar to a mainframe processing utilizing cumulative capacity of the nodes in the grid. Processing can be seamlessly distributed across available nodes facilitating “parallel query” execution for faster response.
3. Caching Needs:
All the caching needs can be fulfilled using IMDG products and they offer support to all types of caches, e.g. distribute cache, replicated cache, partitioned cache, local cache with distribute as backup cache. But if you have just caching needs, then you are better off with specific caching related products (see at the end of the article).
4. Events based Processing Needs:
IMDG products support Complex Event Processing (CEP) based business architecture & ability to consume many events in scalable way.
5. High Availability (Failover support):
Failure of any node does not impact the cluster of nodes and as soon as failed node comes back, it starts contributing again seamlessly (without any configuration change or manual efforts). Also, real-time configuration change (e.g. changing cache high units) or product upgrade is possible without any downtime.
6. Scalability:
If there is need to add more nodes to your grid, it is seamless without any impact on existing grid. Mostly, IMDG products offer capabilities to be “linear scalable” to take full advantage of added capacity.
7. In-memory Database (IMDB) Support:
It also offers the entire database to be maintained in memory for faster response, throughput & performance. All the transactions can happen in memory and persisted asynchronously to database during non-peak hours.
8. Monitoring & Management:
Some products great real-time monitoring & management capabilities (also with JMX support) and it is very handy in troubleshooting or in finding out bottlenecks for improvements.
9. In-line with Cloud Computing:
With cloud computing as future, this is more important as it can offer “data as service” or “data virtualization”.

Commercial Products:
Oracle Coherence (earlier known as Tangosol Coherence), Gigaspaces XAP, IBM WebSphere eXtreme Scale (WXS), Tibco ActiveSpaces (recently launched), ScaleOut StateServer

Open-source Products: 
Terracotta, JBoss Infispan, Hazelcast

Other Distributed Caching Solutions are also available but in my opinion, they are not exactly offering entire IMDG capabilities, but you have only caching needs then they are worth considering (though out of context of this discussion):
NCache (only for Distributed Caching for .Net)
Apache JCS, Terracotta EhCache, OpenSymphony OSCache

Disclaimer:
All data and information provided on this site is for informational purposes only. This site makes no representations as to accuracy, completeness, correctness, suitability, or validity of any information on this site and will not be liable for any errors, omissions, or delays in this information or any losses, injuries, or damages arising from its display or use. All information is provided on an as-is basis.This is a personal weblog. The opinions expressed here represent my own and not those of my employer or any other organization.

Friday, July 2, 2010

Enterprise Architecture | Why is it important?

Enterprise Architecture practice has been there for decades but in last few years it is regaining popularity as it is one of the key initiatives driven by CxOs.

So, why is it important for an Enterprise?
Here are some of the key rationale behind the same:

1. Holistic Approach
Individual divisions across the enterprise only address business problems in their vicinity; but EA team will have holistic point-of-view and work towards in addressing the problems across the enterprise.
For example, having a Credit Card Loan Processing System for London division is addressing locale specific business demands but EA team can align this solution at enterprise level & might provide inputs to make it generic for making it reusable across the enterprise.

2. Consistency in Delivering Solutions to Business Problem
Once we have EA in place, a business solution can be delivered in more structured & consistent way. Established Reference Models for Business Demands
For example, if there is need to develop a Credit Check System, then enterprise reference model (if not available, then Industry Reference Model) will help in establishing consistent architecture for this solution.

3. Building Enterprise-wide Repository
Repository created in the process of establishing EA in an organization like Tools Repository, Architectural Artifacts Repository will encourage reuse & standardization across the enterprise.

4. IT Governance
EA goes hand-in-hand with IT Governance & collaboratively helps in establishing governance across the enterprise, which helps in building controlled & directed corporation. It acts like a framework for leadership, organizational structure, business processes, standards, practices, etc.

5. Defined Business/Technical/Information System Architecture:
Last but not least, as part of EA establishment in the organization, a clearly defined business, technical and information system architecture gets developed during the process. This also creates opportunity to business & IT people to come together & re-validate them.

Some of the popular EA frameworks are TOGAF, Zachman, FEA, Gartner, DoDAF & I have seen most of time there is a custom EA architecture extracting best of the practices/standards/tools from all of them.

Feel free to discuss it further in more detail.


Disclaimer:
All data and information provided on this site is for informational purposes only. This site makes no representations as to accuracy, completeness, currentness, suitability, or validity of any information on this site and will not be liable for any errors, omissions, or delays in this information or any losses, injuries, or damages arising from its display or use. All information is provided on an as-is basis.This is a personal weblog. The opinions expressed here represent my own and not those of my employer or any other organization.

Tuesday, May 4, 2010

Benchmarking – One of the Best Practices for Measurement of your Application Stack Performance

With growing number of “change requests” coming to your application, it is increasingly difficult task to ensure that your application is not introducing performance issues. One of the best practices to ensure this is to “baseline” your performance statistics and “make it a yardstick” to measure the performance of application post major release (having many CRs). Across the industry, it is generally called as “Benchmarking".

Benchmarking is one of the best strategies to measure your hardware performance (to know its capacity) or any OS/application server performance or any framework performance, generally for “capacity modeling” or “evaluate & choose the best hardware/software/framework” on the basis of benchmarking numbers.

For Java, Benchmarking JVM, GC (Garbage Collectors) or any JDBC library can be used to evaluate & choose the best among the pack.

Now, coming back to Benchmarking your own custom application, it will give you following benefits:

• Capacity Modeling – Knowing the capacity of your application stack

• Baseline (Yardstick) – Establishing a yardstick against which all future releases will be based upon; subsequent releases should improve these numbers, not decrease.

• Measurability

• Choosing the best alternative on the basis of stats

Suggested Benchmarking Parameters for your application:

• Response Time in Seconds

• Throughput – Requests Processed Per Second

• Memory Usage, CPU Usage, Database Connections Usage, Disk I/O Usage

One of the most important steps in establishing Benchmarking numbers is “cycles of performance runs” (at least 3 cycles, more is better as it gives more reliable data).


References:

1. Microsoft Article - Benchmarking Web Services using Doculabs

2. IBM Article – Benchmarking Method for Comparing Open Source App Servers

3. Benchmarking AOP Implementations - http://docs.codehaus.org/display/AW/AOP+Benchmark

4. Benchmarking ESB: http://esbperformance.org/wiki/ESB_Performance_Test_Framework

Sunday, January 31, 2010

Many Development Methodologies - Which one to choose, Hyrbid might be the ANSWER

Well, the time has changed like the speed of sound since the era when Waterfall model was considered to be best methodologies for Software Development.

But now in new information age, where frequently changing user requirements, challenging timelines, tight budget and competitive bids are driving factors, IT industry offers many methodologies namely Prototyping, Spiral, RAD, Rational RUP, Agile (Scrum, XP, DSDM - Dynamic System Development Method, FDD - Features Driven Development, Lean Software Development) and the list goes on.

Considering all the available options as Development Methodologies in today's world, it is increasingly difficult to choose a single methodology for all your projects inside a single organization. But having multiple methodologies in a single organization generally creates chaos and obscures roadmap for future projects.

"A slightly different approach to tackle this challenge is to adapt best practices from short-listed methodologies, which suits best for your organization and formulate a hybrid-development methodology specific to your organization."

To illustrate, lets imagine a Development Methodology, which has following features:
  • Sprint approach of Scrum for handling features/requirements in quick turnaround
  • Daily Scrum (or Standup Meeting) to check progress of the project
  • Feedback, Continuous Integration approach of XP
  • Monitoring/Control of Waterfall SDLC (specially of larger projects)
  • Eliminate Waste of Lean software development
Though it needs a considerable amount of research and analysis for any organization to formulate such a hybrid development methodologies, it will pay-off in long run and established a clear roadmap for future development.

Thursday, January 7, 2010

Compare Persistence Mechanisms in Java using factors: ease of development, performance, scalibility, extensibility & security

 
 





Ease of development




Performance




Scalability




Extensibility




Security

Entity Beans - CMP

High – Bean developer concentrates on business
logic; persistence logic provided by EJB vendor

High - Application programmers delegate the details
of persistence to the container, which can optimize data access patterns for
optimal performance.

High – Container provides scalability
(configuration based)

High

High – Container provided

Entity Beans - BMP

Low – Bean developer is responsible for providing
persistence logic.

Uncertain – Depends upon the proficiency of bean
developer

High – Container provides scalability
(configuration based)

Low – Bean developer’s persistence logic needs to
understand by others.

High – Container provided

JDO

High – Bean developer concentrates on business
logic; persistence logic provided by JDO vendor

High - Application programmers delegate the details
of persistence to the JDO implementation, which can optimize data access
patterns for optimal performance.

High

High

High

JPA

High – Bean developer concentrates on business
logic; persistence logic provided by JPA vendor

High – Best ideas from ORM (Hibernate,TopLink)
and JDO

High – Container provides scalability

High - supports the use of pluggable persistence
providers

High – Supports Standardized Security Model (Java)

ORM Frameworks

Medium – Reduces development time

Depends - some O/R mapping tools do not perform
well during bulk deletions of data

High-to-Medium – Depends on ORM vendor

Low – Non-standardized

Medium-to-High – Depends on Vendor

DAO with direct JDBC

Low – Bean developer responsible for persistence
logic.

High-to-Medium -
But Depends upon the proficiency of bean developer

Medium-to-High – Depends on expertise of Developers

Medium-to-High – Depends on expertise of Developers

Medium-to-Low – Needs to be handled by bean
developer