domingo, 29 de noviembre de 2009

Martial Arts - Part Two, Internal Kung Fu

Kung Fu is any technique or martial art with Chinese origin, thus, Chinese martial arts are commonly divided into two categories: Internal and External or hard and soft styles. The earliest distinction between the two was recorded in the "Inscription For Wang Zhen Nan", written in the early Qing Dynasty, where the Shaolin school of martial arts was called the External system because of its techniques focused on attacking the opponent. Thus, the Wudang school of martial arts founded by Zhang San Feng was called the Internal School because they used to neutralize opponent force in a tranquil manner.

Later, schools which originated from Shaolin school were generally classified as External martial arts and those who were originated from Wudang school were generally classified as Internal martial arts.
Also, those techniques that focused on physical strength were classified under the External system and those that focused on internal force were classified under the Internal System. This doesn't mean that within schools considered in general as external there are no internal elements or vice versa.

Most of known Chinese martial arts in occidental countries are considered external martial arts; in the other hand, internal martial arts are less known, some examples are Pa Kua Chang, King Yi Quan, Liu He Ba Fa and Tai Chi Chuan or Taijijuan as it is spelt in Romanized Chinese. The last one is perhaps the most known and it means "the grand ultimate", and figuratively "the cosmos" Because Tai Chi is more commonly used as a way to get relaxed and keep good health, some people don't know that it is actually a martial art at all. The amazing thing about Tai Chi Chuan is that to defend yourself against almost any form of physical aggression, you need to know only a few fighting patterns.

In an internal martial art like Tai Chi, the power is generated in the same way one would push some heavy object, for example a bookshelf, you push with your legs using your arms, this means, you are transferring the legs power to the object you want to push, using the power of the whole body, this explains why Internal martial arts power is commonly named "whole body power". The difference between pushing the loaded object and striking it, it is the speed.

Tai Chi have been characterized by meditation and spirituality, in this way, practitioners can develop and learn to control the "chi" or vital energy, which flows all over the body. Besides Tai Chi practitioners learn to use opponent's power against itself, redirecting the energy.
Even the division of martial arts into External or Internal, an important concept in Tai Chi Chuan is Ying-yang, in many ways, Tai Chi is all about it, if there is only yin and no yang, or vice versa, then that is not Tai Chi Chuan, thus a good Tai Chi practitioner has to develop both stillness and physical force to get all advantages of this Internal martial art. This same concept should be applied to all martial arts, this is why without dark, there would be nothing that could be called light.

Martial Arts

The word "martial", it's originated from Mars, the god of the war in Roman mythology. The term "Martial Art" for itself, it means the artistic expression of the combat, without losing the application of martial laws and principles. Although at the present time India hasn't any recognized modern martial art, in that country was originated the Hindu martial art "Varajmushti", the father of all the Chinese systems, and consequently of the rest of them.

The modern martial arts are mostly from the oriental region of the planet, and more specifically from China, Japan and Korea. Nowadays, the most popular and traditional China method it's the "Kung Fu" that it means "Ability", and whose origin dates from the sixth century BC, the Kung Fu has been also defined as any technique or martial art with Chinese origin, an example is "Wing Chun", created in the XVII century, which was practiced by the legendary Bruce Lee. Lee also created his own martial art, "Jeet Kune Do" or "way of the interceptor fist", which gathers philosophies of Wing Chun, such as to defend and to attack simultaneously, according Bruce Lee, the purpose of Jeet Kune Do was more philosophical than physical and it gathered the useful things of the other martial arts discarding the useless things. The main purpose was defeating the enemy with the minimum effort. On the other hand, Japan has developed great quantity of methods, "Sumo" is the traditional Japanese sport, This technique was probably originated before the Christian era; "Kendo" that literally means "Via of the sable", and it is also known as the Japanese fencing; "Kenpo" that means in Japanese language "Law of the fist", this refers to any kind of combat originated in China developed in Japan; Nin Jitsu, that used to be used by the old Ninjas and Samurais, this method taught its practitioners, how to exist or survive in any place or situation. Another Japanese method is the "Jiu Jitsu" this became the samurai's ideal defense method. Due to its complexity, another martial arts was created to be focused in specific areas. Some of them are "Karate Do" that means "Empty Hand" and was originated in the VI century at Okinawa city, Jigoro Kano's "Judo", which is characterized by the use of locks, and the Moriei Ueshiba's Aikido, which consists on a synthesis of the Karate, Judo and Jiu Jitsu. Aikido means "Method of the union or harmonization of the energy". These last two arts were originated respectively in the last two centuries. Maybe the most famous Korean martial art in the western region is "Tae Kwon Do", created by Lieutenant Choi to developing an own national martial art more superior in technical as in spirit than the Japanese Karate. This martial art began to be developed since the year 1946 until 1954. April eleventh 1955 this method took the name of Tae Kwon do, that means "Method of blocking kicking"; other Korean martial arts are "Sipa Ki Do", which has official registrations since 1.392, this consists on teaching as quick as possible to any person; "Han Mu Do" that means "The way of the Korean martial arts", this technique was created by Dr. He-Young Kimm in 1989, this is another empty hand technique; "Hap Ki Do" that is the art of the Korean personal defense, it was founded by the Great Master Ji Han Jae in the year 1.959, this uses all type of techniques to survive in a dangerous situation; and "Tang Su Do" that means "China hand way", this martial art was created by the great master Hwang Kee. This name was also used in Korea to make reference to any martial art. The North American actor Chuck Norris is an exponent of this sport.

Although the previously mentioned techniques was originated at the oriental area of Asia, the martial arts have been developed around the world, in countries like Brazil, United States, Israel, Malaysia, Thailand, Russia, Vietnam and France. Important arts developed in this other places are "Muay Thai" or "Thai boxing"; the recently developed American arts as the Kickboxing and the Full Contact, which starts since 1968; and Brazilian techniques like "Brazilian Jiu Jitsu" which is well-known by the effectiveness of their techniques in real fights, "Vale Tudo" and "Capoeira", although for some people the last one isn't a real martial art.


viernes, 27 de noviembre de 2009

Load Balancing

Load Balancing o Balanceo de Carga, es una técnica aplicada a través de software o hardware (routers, switches), para la distribución de trabajo entre dos o más dispositivos, con el fin de maximizar el rendimiento, este es un término que muchas veces se confunde con Clustering, para aclarar un poco este punto, las técnicas de Clustering son mayormente aplicadas para asegurar una alta disponibilidad y confiabilidad, y se da principalmente en los que respecta a bases de datos; en cuanto al balanceo de carga, es un concepto que es mejor conocido en aplicaciones Web, en donde se desea mejorar el rendimiento de la aplicación a través de una distribución del procesamiento a través de N servidores, conformando lo que se conoce también como granja de servidores (Web Farm).

Uno de los grandes temas cuando se habla de balanceo de carga en aplicaciones Web, es lo concerniente al manejo del estado, como es bien sabido, un sitio Web es una aplicación Stateless (o sea que no mantiene información de estado por sí sola), para esto han existido innumerables técnicas ya sean desde el lado del cliente o el servidor, donde podríamos decir que la más popular es una técnica de servidor denominada Session State. El Session State consiste el almacenar en la memoria del servidor Web información de estado por cada cliente. En un ambiente de granjas esto puede acarrear inconvenientes, debido a que si un cliente hizo una solicitud al sitio que se procesó por el Nodo X, puede ser que la siguiente solicitud se haya procesado por el Nodo Y, y al ser estos dos nodos servidores diferentes, cada uno con su memoria propia, es imposible para ellos compartir dicha información, por lo que se perdería. Algunas de las técnicas utilizadas para solventar esto es la Persistencia, que consiste en que una vez que se ha creado una sesión para un cliente, el balanceador debe ser responsable de manejar los siguientes requests en el mismo servidor que lo atendió hasta que la sesión del mismo haya expirado. Talvez los dos principales inconvenientes achacados a esta técnica son las siguientes: primero, que si el servidor que estuvo atendiendo al cliente, falla, toda la información del mismo se perdería; y segundo, que no se estaría explotando el concepto de balanceo, sobre todo en aplicaciones que manejen pocos usuario que realizan muchos requests, aunque este último caso conformarían un escenario realmente atípico. Volviendo al primer inconveniente, igualmente en un ambiente en el que no existiese balanceo de carga, el problema de pérdida de sesión en caso de fallo se daría, por lo que esta situación no es achacable al uso de un balanceador. Una técnica de balanceo muy conocida que es propietaria de Microsoft es el NLBS (Network Load Balancing Service), esta técnica es por software y maneja persistencia a través del concepto de Afinidad del Cliente (Client Affinity), la cual se puede manejar por cliente (Para Intranet) o por dirección IP de clase C (para Internet).

Otra opción para evitar el problema de pérdida de información de estado, es almacenar dicha información en un servidor dedicado; ya sea este una base de datos, otro servidor Web, o un servidor con algún tipo de servicio o demonio, accesado a través de un puerto. Principalmente con la solución de base de datos se resuelve el problema de la pérdida de información en caso de fallo. Con las otras técnicas la caída de un servidor Web no acarrearía la pérdida de información, pero sí la caída del servidor dedicado, a no ser que dicha información no se almacene en memoria, si no en algún repositorio de información persistente como un archivo o una base de datos.

Un tema interesante al que se le puede seguir el rastro es el concepto de Application Delivery Controller, que ha sido nombrado Next Generation Load Balancer (balanceador de carga de la siguiente generación), el cual consiste en un dispositivo de red que a la hora de asignar un servidor busca el servidor más rápido que esté disponible y maneja aspectos tales como caché y seguridad.

viernes, 20 de noviembre de 2009

Tracing en ASP.Net

Por muchos es bien conocido las herramientas de diagnóstico y tracing de Microsoft ASP.Net. En este contexto teníamos objetos como el Debug y el Trace. Con el objeto Trace la gente tendía mucho a confundirse, ya que existían dos tipos diferentes, el objeto trace de System.Diagnostics que era el que trabajaba con los famosos Listeners (por ejemplo, un archivo de texto, el Event Viewer, o un tipo custom, para guardar por ejemplo en una base de datos) y que tenía métodos como el “TraceInformation”, “TraceError”, “Write”, etc; y estaba el objeto Trace del contexto de la página con métodos como el “Write” y el “Warn” (que escribía un texto en rojo).

Una buena forma de tracear información tocando lo menos posible la aplicación y haciendo una combinación de estos dos objetos trace es la siguiente; en el archivo de configuración de la aplicación habilitar el trace a nivel de página dentro de la sección “system.web”:


< trace enabled="true" writeToDiagnosticsTrace ="true" pageOutput="false" traceMode="SortByTime" requestLimit="20"/>


Con valor de “false” en el atributo “pageOutput“, se evita ver la información de traceo en cada página, para utilizar la página genérica, http://servidor/directorioRaizApp/Trace.axd. Aquí el atributo clave es “writeToDiagnosticsTrace”, el cual lo estamos asignando a “true” con el fin de que todo lo que procese por el Trace de la página, se redireccione a los listeners de System.Diagnostics, que dicho sea de paso, aunque se pueden agregar por código, también se pueden agregar por archivo de configuración, dentro de la sección “configuration”, como se muestra a continuación:


< system.diagnostics>
< trace autoflush="true" indentsize="2">
< listeners>
< remove name="Default"/>
< add name="EventLogListener" type="System.Diagnostics.EventLogTraceListener" initializeData="MiSource"/>
< add name="LogFileListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="c:\TraceInfo.txt" />
< /listeners>
< /trace>
< /system.diagnostics>


Con esto estaríamos viendo la información, tanto en el Trace.axd, como en el archivo de texto y el Event Log respectivo. Y enviar información adicional sería tan fácil como utilizar la siguiente línea de código:


Trace.Warn(string.Format("Paso anterior al proceso a las {0}", DateTime.Now.Ticks));


Por supuesto esto se puede combinar también con un Switch para también contolar a través de archivo de configuración de la aplicación si se va a instrumentar o no, a través del siguiente código dentro de la sección “configuration” dentro del archivo de configuración de la aplicación, se muestra cómo hacer esto:


< system.diagnostics>
< switches>
< add name="SwitchApp" value="4"/>
< /switches>
< /system.diagnostics>


En este caso estamos asignando un nivel de “Verbose”. El código de la aplicación sería el siguiente:


TraceSwitch SwitchApp = new TraceSwitch("SwitchApp", "Switch de la aplicación");

if (SwitchApp.Level >= System.Diagnostics.TraceLevel.Verbose)
Trace.Warn(string.Format("Paso anterior al proceso a las {0}", DateTime.Now.Ticks));



Como en el caso anterior, estoy usando un nivel de “Verbose” para tomar la decisión de si instrumento o no. Obviamente este trabajo se puede hacer más simple y reutilizable a través del uso de clases utilitarias.