domingo, 29 de noviembre de 2009
Martial Arts - Part Two, Internal Kung Fu
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
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
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.